Merge "For non-udfps devices, use lock_icon padding specified in pixels." into main
diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index 2c78f93..0ee7ace 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -36,7 +36,9 @@
":android.location.flags-aconfig-java{.generated_srcjars}",
":android.media.tv.flags-aconfig-java{.generated_srcjars}",
":android.multiuser.flags-aconfig-java{.generated_srcjars}",
+ ":android.net.platform.flags-aconfig-java{.generated_srcjars}",
":android.net.vcn.flags-aconfig-java{.generated_srcjars}",
+ ":android.net.wifi.flags-aconfig-java{.generated_srcjars}",
":android.nfc.flags-aconfig-java{.generated_srcjars}",
":android.os.flags-aconfig-java{.generated_srcjars}",
":android.os.vibrator.flags-aconfig-java{.generated_srcjars}",
@@ -67,7 +69,6 @@
":com.android.internal.foldables.flags-aconfig-java{.generated_srcjars}",
":com.android.media.flags.bettertogether-aconfig-java{.generated_srcjars}",
":com.android.media.flags.editing-aconfig-java{.generated_srcjars}",
- ":com.android.net.flags-aconfig-java{.generated_srcjars}",
":com.android.net.thread.flags-aconfig-java{.generated_srcjars}",
":com.android.server.flags.services-aconfig-java{.generated_srcjars}",
":com.android.text.flags-aconfig-java{.generated_srcjars}",
@@ -109,7 +110,9 @@
"android.media.midi-aconfig",
"android.media.tv.flags-aconfig",
"android.multiuser.flags-aconfig",
+ "android.net.platform.flags-aconfig",
"android.net.vcn.flags-aconfig",
+ "android.net.wifi.flags-aconfig",
"android.nfc.flags-aconfig",
"android.os.flags-aconfig",
"android.os.vibrator.flags-aconfig",
@@ -137,7 +140,6 @@
"com.android.hardware.input.input-aconfig",
"com.android.input.flags-aconfig",
"com.android.media.flags.bettertogether-aconfig",
- "com.android.net.flags-aconfig",
"com.android.net.thread.flags-aconfig",
"com.android.server.flags.services-aconfig",
"com.android.text.flags-aconfig",
@@ -776,9 +778,10 @@
// Networking
aconfig_declarations {
- name: "com.android.net.flags-aconfig",
- package: "com.android.net.flags",
+ name: "android.net.platform.flags-aconfig",
+ package: "android.net.platform.flags",
srcs: ["core/java/android/net/flags.aconfig"],
+ visibility: [":__subpackages__"],
}
// Thread network
@@ -789,9 +792,10 @@
}
java_aconfig_library {
- name: "com.android.net.flags-aconfig-java",
- aconfig_declarations: "com.android.net.flags-aconfig",
+ name: "android.net.platform.flags-aconfig-java",
+ aconfig_declarations: "android.net.platform.flags-aconfig",
defaults: ["framework-minus-apex-aconfig-java-defaults"],
+ visibility: [":__subpackages__"],
}
java_aconfig_library {
@@ -1101,3 +1105,21 @@
aconfig_declarations: "backup_flags",
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}
+
+// Wifi
+aconfig_declarations {
+ name: "android.net.wifi.flags-aconfig",
+ package: "android.net.wifi.flags",
+ srcs: ["wifi/*.aconfig"],
+}
+
+java_aconfig_library {
+ name: "android.net.wifi.flags-aconfig-java",
+ aconfig_declarations: "android.net.wifi.flags-aconfig",
+ min_sdk_version: "30",
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.wifi",
+ ],
+ defaults: ["framework-minus-apex-aconfig-java-defaults"],
+}
diff --git a/OWNERS b/OWNERS
index 733157f..935b768 100644
--- a/OWNERS
+++ b/OWNERS
@@ -39,3 +39,5 @@
per-file *Ravenwood* = file:ravenwood/OWNERS
per-file PERFORMANCE_OWNERS = file:/PERFORMANCE_OWNERS
+
+per-file PACKAGE_MANAGER_OWNERS = file:/PACKAGE_MANAGER_OWNERS
\ No newline at end of file
diff --git a/PACKAGE_MANAGER_OWNERS b/PACKAGE_MANAGER_OWNERS
index e4549b4..eb5842b 100644
--- a/PACKAGE_MANAGER_OWNERS
+++ b/PACKAGE_MANAGER_OWNERS
@@ -1,3 +1,3 @@
-chiuwinson@google.com
+alexbuy@google.com
patb@google.com
schfan@google.com
\ No newline at end of file
diff --git a/apex/jobscheduler/service/java/com/android/server/AppStateTrackerImpl.java b/apex/jobscheduler/service/java/com/android/server/AppStateTrackerImpl.java
index e08200b..33f6899 100644
--- a/apex/jobscheduler/service/java/com/android/server/AppStateTrackerImpl.java
+++ b/apex/jobscheduler/service/java/com/android/server/AppStateTrackerImpl.java
@@ -743,7 +743,8 @@
private final class AppOpsWatcher extends IAppOpsCallback.Stub {
@Override
- public void opChanged(int op, int uid, String packageName) throws RemoteException {
+ public void opChanged(int op, int uid, String packageName,
+ String persistentDeviceId) throws RemoteException {
boolean restricted = false;
try {
restricted = mAppOpsService.checkOperation(TARGET_OP,
diff --git a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
index abf8008..39de0af 100644
--- a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
@@ -2026,8 +2026,8 @@
iAppOpsService.startWatchingMode(AppOpsManager.OP_SCHEDULE_EXACT_ALARM, null,
new IAppOpsCallback.Stub() {
@Override
- public void opChanged(int op, int uid, String packageName)
- throws RemoteException {
+ public void opChanged(int op, int uid, String packageName,
+ String persistentDeviceId) throws RemoteException {
final int userId = UserHandle.getUserId(uid);
if (op != AppOpsManager.OP_SCHEDULE_EXACT_ALARM
|| !isExactAlarmChangeEnabled(packageName, userId)) {
diff --git a/apex/jobscheduler/service/java/com/android/server/tare/InternalResourceService.java b/apex/jobscheduler/service/java/com/android/server/tare/InternalResourceService.java
index 357e1396..6635484 100644
--- a/apex/jobscheduler/service/java/com/android/server/tare/InternalResourceService.java
+++ b/apex/jobscheduler/service/java/com/android/server/tare/InternalResourceService.java
@@ -227,7 +227,7 @@
private final IAppOpsCallback mApbListener = new IAppOpsCallback.Stub() {
@Override
- public void opChanged(int op, int uid, String packageName) {
+ public void opChanged(int op, int uid, String packageName, String persistentDeviceId) {
boolean restricted = false;
try {
restricted = mAppOpsService.checkOperation(
diff --git a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
index e589c21..19bc716 100644
--- a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
+++ b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
@@ -671,7 +671,8 @@
/*packageName=*/ null,
new IAppOpsCallback.Stub() {
@Override
- public void opChanged(int op, int uid, String packageName) {
+ public void opChanged(int op, int uid, String packageName,
+ String persistentDeviceId) {
final int userId = UserHandle.getUserId(uid);
synchronized (mSystemExemptionAppOpMode) {
mSystemExemptionAppOpMode.delete(uid);
diff --git a/core/api/current.txt b/core/api/current.txt
index 4efb3d3..cf5a261 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -5095,10 +5095,12 @@
public static interface AppOpsManager.OnOpActiveChangedListener {
method public void onOpActiveChanged(@NonNull String, int, @NonNull String, boolean);
+ method @FlaggedApi("android.permission.flags.device_aware_permission_apis_enabled") public default void onOpActiveChanged(@NonNull String, int, @NonNull String, @Nullable String, int, boolean, int, int);
}
public static interface AppOpsManager.OnOpChangedListener {
method public void onOpChanged(String, String);
+ method @FlaggedApi("android.permission.flags.device_aware_permission_apis_enabled") public default void onOpChanged(@NonNull String, @NonNull String, int, @NonNull String);
}
public abstract static class AppOpsManager.OnOpNotedCallback {
@@ -6353,6 +6355,7 @@
field public static final String CATEGORY_STOPWATCH = "stopwatch";
field public static final String CATEGORY_SYSTEM = "sys";
field public static final String CATEGORY_TRANSPORT = "transport";
+ field @FlaggedApi("android.app.category_voicemail") public static final String CATEGORY_VOICEMAIL = "voicemail";
field public static final String CATEGORY_WORKOUT = "workout";
field @ColorInt public static final int COLOR_DEFAULT = 0; // 0x0
field @NonNull public static final android.os.Parcelable.Creator<android.app.Notification> CREATOR;
@@ -15571,6 +15574,7 @@
method public boolean clipRect(float, float, float, float);
method public boolean clipRect(int, int, int, int);
method public void concat(@Nullable android.graphics.Matrix);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void concat44(@Nullable android.graphics.Matrix44);
method public void disableZ();
method public void drawARGB(int, int, int, int);
method public void drawArc(@NonNull android.graphics.RectF, float, float, boolean, @NonNull android.graphics.Paint);
@@ -16219,6 +16223,24 @@
enum_constant public static final android.graphics.Matrix.ScaleToFit START;
}
+ @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public class Matrix44 {
+ ctor @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public Matrix44();
+ ctor @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public Matrix44(@NonNull android.graphics.Matrix);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 concat(@NonNull android.graphics.Matrix44);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public float get(int, int);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void getValues(@NonNull float[]);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public boolean invert();
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public boolean isIdentity();
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public float[] map(float, float, float, float);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void map(float, float, float, float, @NonNull float[]);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void reset();
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 rotate(float, float, float, float);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 scale(float, float, float);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void set(int, int, float);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void setValues(@NonNull float[]);
+ method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 translate(float, float, float);
+ }
+
public class Mesh {
ctor public Mesh(@NonNull android.graphics.MeshSpecification, int, @NonNull java.nio.Buffer, int, @NonNull android.graphics.RectF);
ctor public Mesh(@NonNull android.graphics.MeshSpecification, int, @NonNull java.nio.Buffer, int, @NonNull java.nio.ShortBuffer, @NonNull android.graphics.RectF);
@@ -21172,6 +21194,7 @@
method public int getStreamMinVolume(int);
method public int getStreamVolume(int);
method public float getStreamVolumeDb(int, int, int);
+ method @FlaggedApi("android.media.audio.supported_device_types_api") @NonNull public java.util.Set<java.lang.Integer> getSupportedDeviceTypes(int);
method @NonNull public java.util.List<android.media.AudioMixerAttributes> getSupportedMixerAttributes(@NonNull android.media.AudioDeviceInfo);
method @Deprecated public int getVibrateSetting(int);
method public int getVolumeGroupIdForAttributes(@NonNull android.media.AudioAttributes);
@@ -59545,7 +59568,6 @@
}
@FlaggedApi("android.appwidget.flags.draw_data_parcel") public static final class RemoteViews.DrawInstructions {
- method @FlaggedApi("android.appwidget.flags.draw_data_parcel") public void appendInstructions(@NonNull byte[]);
}
@FlaggedApi("android.appwidget.flags.draw_data_parcel") public static final class RemoteViews.DrawInstructions.Builder {
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index f101161..86f2b628 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -822,6 +822,7 @@
public static interface AppOpsManager.OnOpNotedListener {
method public void onOpNoted(@NonNull String, int, @NonNull String, @Nullable String, int, int);
+ method @FlaggedApi("android.permission.flags.device_aware_permission_apis_enabled") public default void onOpNoted(@NonNull String, int, @NonNull String, @Nullable String, int, int, int);
}
public static final class AppOpsManager.OpEntry implements android.os.Parcelable {
@@ -3208,8 +3209,14 @@
package android.companion.virtual {
+ public final class VirtualDevice implements android.os.Parcelable {
+ method @FlaggedApi("android.companion.virtual.flags.vdm_public_apis") public boolean hasCustomAudioInputSupport();
+ method @FlaggedApi("android.companion.virtual.flags.vdm_public_apis") public boolean hasCustomCameraSupport();
+ }
+
public final class VirtualDeviceManager {
method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.companion.virtual.VirtualDeviceManager.VirtualDevice createVirtualDevice(int, @NonNull android.companion.virtual.VirtualDeviceParams);
+ method @FlaggedApi("android.companion.virtual.flags.persistent_device_id_api") @NonNull public java.util.Set<java.lang.String> getAllPersistentDeviceIds();
method @FlaggedApi("android.companion.virtual.flags.persistent_device_id_api") @Nullable public CharSequence getDisplayNameForPersistentDeviceId(@NonNull String);
field public static final int LAUNCH_FAILURE_NO_ACTIVITY = 2; // 0x2
field public static final int LAUNCH_FAILURE_PENDING_INTENT_CANCELED = 1; // 0x1
@@ -9657,6 +9664,7 @@
public final class DeviceWiphyCapabilities implements android.os.Parcelable {
ctor public DeviceWiphyCapabilities();
method public int describeContents();
+ method @FlaggedApi("android.net.wifi.flags.get_device_cross_akm_roaming_support") public int getMaxNumberAkms();
method public int getMaxNumberRxSpatialStreams();
method public int getMaxNumberTxSpatialStreams();
method public boolean isChannelWidthSupported(int);
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index bb666e6..7907059 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -36,6 +36,7 @@
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.usage.UsageStatsManager;
+import android.companion.virtual.VirtualDeviceManager;
import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
@@ -7346,6 +7347,12 @@
* The default impl is to fallback onto {@link #onOpChanged(String, String)
*
+ * <p> Implement this method and not
+ * {@link #onOpChanged(String, String, int, String)} if
+ * callbacks are
+ * required only on op state changes for the default device
+ * {@link VirtualDeviceManager#PERSISTENT_DEVICE_ID_DEFAULT}.
+ *
* @param op The Op that changed.
* @param packageName Package of the app whose Op changed.
* @param userId User Space of the app whose Op changed.
@@ -7354,6 +7361,31 @@
default void onOpChanged(@NonNull String op, @NonNull String packageName, int userId) {
onOpChanged(op, packageName);
}
+
+ /**
+ * Similar to {@link #onOpChanged(String, String, int)} but includes the device for which
+ * the op mode has changed.
+ *
+ * <p> Implement this method if callbacks are required on all devices.
+ * If not implemented explicitly, the default implementation will notify for op changes
+ * on the default device {@link VirtualDeviceManager#PERSISTENT_DEVICE_ID_DEFAULT} only.
+ *
+ * <p> If implemented, {@link #onOpChanged(String, String, int)}
+ * will not be called automatically.
+ *
+ * @param op The Op that changed.
+ * @param packageName Package of the app whose Op changed.
+ * @param userId User id of the app whose Op changed.
+ * @param persistentDeviceId persistent device id whose Op changed.
+ */
+ @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED)
+ default void onOpChanged(@NonNull String op, @NonNull String packageName, int userId,
+ @NonNull String persistentDeviceId) {
+ if (Objects.equals(persistentDeviceId,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)) {
+ onOpChanged(op, packageName, userId);
+ }
+ }
}
/**
@@ -7373,6 +7405,12 @@
/**
* Called when the active state of an app-op changes.
*
+ * <p> Implement this method and not
+ * {@link #onOpActiveChanged(String, int, String, String, int, boolean, int, int)} if
+ * callbacks are
+ * required only on op state changes for the default device
+ * {@link Context#DEVICE_ID_DEFAULT}.
+ *
* @param op The operation that changed.
* @param uid The UID performing the operation.
* @param packageName The package performing the operation.
@@ -7388,6 +7426,37 @@
int attributionFlags, int attributionChainId) {
onOpActiveChanged(op, uid, packageName, active);
}
+
+ /**
+ * Similar to {@link #onOpActiveChanged(String, int, String, String, boolean, int, int)},
+ * but also includes the virtual device id of the op is now active or inactive.
+ *
+ * <p> Implement this method if callbacks are required on all devices.
+ * If not implemented explicitly, the default implementation will notify for op state
+ * changes on the default device {@link Context#DEVICE_ID_DEFAULT} only.
+ *
+ * <p> If implemented,
+ * {@link #onOpActiveChanged(String, int, String, String, boolean, int, int)}
+ * will not be called automatically.
+ *
+ * @param op The operation that changed.
+ * @param uid The UID performing the operation.
+ * @param packageName The package performing the operation.
+ * @param attributionTag The operation's attribution tag.
+ * @param virtualDeviceId the virtual device id whose operation has changed
+ * @param active Whether the operation became active or inactive.
+ * @param attributionFlags the attribution flags for this operation.
+ * @param attributionChainId the unique id of the attribution chain this op is a part of.
+ */
+ @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED)
+ default void onOpActiveChanged(@NonNull String op, int uid, @NonNull String packageName,
+ @Nullable String attributionTag, int virtualDeviceId, boolean active,
+ @AttributionFlags int attributionFlags, int attributionChainId) {
+ if (virtualDeviceId == Context.DEVICE_ID_DEFAULT) {
+ onOpActiveChanged(op, uid, packageName, attributionTag, active, attributionFlags,
+ attributionChainId);
+ }
+ }
}
/**
@@ -7400,6 +7469,10 @@
/**
* Called when an app-op is noted.
*
+ * <p> Implement this method and not
+ * {@link #onOpNoted(String, int, String, String, int, int, int)} if callbacks are
+ * required only on op notes for the default device {@link Context#DEVICE_ID_DEFAULT}.
+ *
* @param op The operation that was noted.
* @param uid The UID performing the operation.
* @param packageName The package performing the operation.
@@ -7409,6 +7482,34 @@
*/
void onOpNoted(@NonNull String op, int uid, @NonNull String packageName,
@Nullable String attributionTag, @OpFlags int flags, @Mode int result);
+
+ /**
+ * Similar to {@link #onOpNoted(String, int, String, String, int, int, int)},
+ * but also includes the virtual device id of the op is now active or inactive.
+ *
+ * <p> Implement this method if callbacks are required for op notes on all devices.
+ * If not implemented explicitly, the default implementation will notify for the
+ * default device {@link Context#DEVICE_ID_DEFAULT} only.
+ *
+ * <p> If implemented, {@link #onOpNoted(String, int, String, String, int, int)}
+ * will not be called automatically.
+ *
+ * @param op The operation that was noted.
+ * @param uid The UID performing the operation.
+ * @param packageName The package performing the operation.
+ * @param attributionTag The attribution tag performing the operation.
+ * @param virtualDeviceId the device that noted the operation
+ * @param flags The flags of this op
+ * @param result The result of the note.
+ */
+ @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED)
+ default void onOpNoted(@NonNull String op, int uid, @NonNull String packageName,
+ @Nullable String attributionTag, int virtualDeviceId, @OpFlags int flags,
+ @Mode int result) {
+ if (virtualDeviceId == Context.DEVICE_ID_DEFAULT) {
+ onOpNoted(op, uid, packageName, attributionTag, flags, result);
+ }
+ }
}
/**
@@ -7447,6 +7548,9 @@
public static class OnOpChangedInternalListener implements OnOpChangedListener {
public void onOpChanged(String op, String packageName) { }
public void onOpChanged(int op, String packageName) { }
+ public void onOpChanged(int op, String packageName, String persistentDeviceId) {
+ onOpChanged(op, packageName);
+ }
}
/**
@@ -7457,6 +7561,8 @@
public interface OnOpActiveChangedInternalListener extends OnOpActiveChangedListener {
default void onOpActiveChanged(String op, int uid, String packageName, boolean active) { }
default void onOpActiveChanged(int op, int uid, String packageName, boolean active) { }
+ default void onOpActiveChanged(int op, int uid, String packageName, int virtualDeviceId,
+ boolean active) { }
}
/**
@@ -7510,6 +7616,12 @@
/**
* Called when an op was started.
*
+ * <p> Implement this method and not
+ * {@link #onOpStarted(int, int, String, String, int, int, int, int, int, int)} if
+ * callbacks are
+ * required only on op starts for the default device
+ * {@link Context#DEVICE_ID_DEFAULT}.
+ *
* Note: This is only for op starts. It is not called when an op is noted or stopped.
* By default, unless this method is overridden, no code will be executed for resume
* events.
@@ -7530,6 +7642,37 @@
onOpStarted(op, uid, packageName, attributionTag, flags, result);
}
}
+
+ /**
+ * Similar to {@link #onOpStarted(int, int, String, String, int, int)},
+ * but also includes the virtual device id that started the op.
+ *
+ * <p> Implement this method if callbacks are required on all devices.
+ * If not implemented explicitly, the default implementation will notify for op starts on
+ * the default device {@link Context#DEVICE_ID_DEFAULT} only.
+ *
+ * <p> If implemented, {@link #onOpStarted(int, int, String, String, int, int)}
+ * will not be called automatically.
+ *
+ * @param op The op code.
+ * @param uid The UID performing the operation.
+ * @param packageName The package performing the operation.
+ * @param attributionTag The attribution tag performing the operation.
+ * @param virtualDeviceId the device that started the operation
+ * @param flags The flags of this op.
+ * @param result The result of the start.
+ * @param startType The start type of this start event. Either failed, resumed, or started.
+ * @param attributionFlags The location of this started op in an attribution chain.
+ */
+ default void onOpStarted(int op, int uid, @NonNull String packageName,
+ @Nullable String attributionTag, int virtualDeviceId, @OpFlags int flags,
+ @Mode int result, @StartedType int startType,
+ @AttributionFlags int attributionFlags, int attributionChainId) {
+ if (virtualDeviceId == Context.DEVICE_ID_DEFAULT) {
+ onOpStarted(op, uid, packageName, attributionTag, flags, result, startType,
+ attributionFlags, attributionChainId);
+ }
+ }
}
AppOpsManager(Context context, IAppOpsService service) {
@@ -8054,14 +8197,16 @@
IAppOpsCallback cb = mModeWatchers.get(callback);
if (cb == null) {
cb = new IAppOpsCallback.Stub() {
- public void opChanged(int op, int uid, String packageName) {
+ public void opChanged(int op, int uid, String packageName,
+ String persistentDeviceId) {
if (callback instanceof OnOpChangedInternalListener) {
- ((OnOpChangedInternalListener)callback).onOpChanged(op, packageName);
+ ((OnOpChangedInternalListener)callback).onOpChanged(op, packageName,
+ persistentDeviceId);
}
if (sAppOpInfos[op].name != null) {
callback.onOpChanged(sAppOpInfos[op].name, packageName,
- UserHandle.getUserId(uid));
+ UserHandle.getUserId(uid), persistentDeviceId);
}
}
};
@@ -8142,16 +8287,17 @@
cb = new IAppOpsActiveCallback.Stub() {
@Override
public void opActiveChanged(int op, int uid, String packageName,
- String attributionTag, boolean active, @AttributionFlags
- int attributionFlags, int attributionChainId) {
+ String attributionTag, int virtualDeviceId, boolean active,
+ @AttributionFlags int attributionFlags, int attributionChainId) {
executor.execute(() -> {
if (callback instanceof OnOpActiveChangedInternalListener) {
((OnOpActiveChangedInternalListener) callback).onOpActiveChanged(op,
- uid, packageName, active);
+ uid, packageName, virtualDeviceId, active);
}
if (sAppOpInfos[op].name != null) {
callback.onOpActiveChanged(sAppOpInfos[op].name, uid, packageName,
- attributionTag, active, attributionFlags, attributionChainId);
+ attributionTag, virtualDeviceId, active, attributionFlags,
+ attributionChainId);
}
});
}
@@ -8220,10 +8366,10 @@
cb = new IAppOpsStartedCallback.Stub() {
@Override
public void opStarted(int op, int uid, String packageName, String attributionTag,
- int flags, int mode, int startType, int attributionFlags,
- int attributionChainId) {
- callback.onOpStarted(op, uid, packageName, attributionTag, flags, mode,
- startType, attributionFlags, attributionChainId);
+ int virtualDeviceId, int flags, int mode, int startType,
+ int attributionFlags, int attributionChainId) {
+ callback.onOpStarted(op, uid, packageName, attributionTag, virtualDeviceId,
+ flags, mode, startType, attributionFlags, attributionChainId);
}
};
mStartedWatchers.put(callback, cb);
@@ -8391,13 +8537,13 @@
cb = new IAppOpsNotedCallback.Stub() {
@Override
public void opNoted(int op, int uid, String packageName, String attributionTag,
- int flags, int mode) {
+ int virtualDeviceId, int flags, int mode) {
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> {
if (sAppOpInfos[op].name != null) {
listener.onOpNoted(sAppOpInfos[op].name, uid, packageName,
- attributionTag,
+ attributionTag, virtualDeviceId,
flags, mode);
}
});
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index a81ad3c..d705eeb 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1061,6 +1061,12 @@
public static final String CATEGORY_MISSED_CALL = "missed_call";
/**
+ * Notification category: voicemail.
+ */
+ @FlaggedApi(Flags.FLAG_CATEGORY_VOICEMAIL)
+ public static final String CATEGORY_VOICEMAIL = "voicemail";
+
+ /**
* One of the predefined notification categories (see the <code>CATEGORY_*</code> constants)
* that best describes this Notification. May be used by the system for ranking and filtering.
*/
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index b21b0f3..ba9c895 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -1618,6 +1618,19 @@
return new ContactKeysManager(ctx);
}});
+ // DO NOT do a flag check like this unless the flag is read-only.
+ // (because this code is executed during preload in zygote.)
+ // If the flag is mutable, the check should be inside CachedServiceFetcher.
+ if (Flags.bicClient()) {
+ registerService(Context.BACKGROUND_INSTALL_CONTROL_SERVICE,
+ BackgroundInstallControlManager.class,
+ new CachedServiceFetcher<BackgroundInstallControlManager>() {
+ @Override
+ public BackgroundInstallControlManager createService(ContextImpl ctx) {
+ return new BackgroundInstallControlManager(ctx);
+ }
+ });
+ }
sInitializing = true;
try {
// Note: the following functions need to be @SystemApis, once they become mainline
diff --git a/core/java/android/app/notification.aconfig b/core/java/android/app/notification.aconfig
index d11c6c5..a5d4a14 100644
--- a/core/java/android/app/notification.aconfig
+++ b/core/java/android/app/notification.aconfig
@@ -43,3 +43,10 @@
description: "Fixes the behavior of KeyguardManager#setPrivateNotificationsAllowed()"
bug: "309920145"
}
+
+flag {
+ name: "category_voicemail"
+ namespace: "wear_sysui"
+ description: "Adds a new voicemail category for notifications"
+ bug: "322806700"
+}
diff --git a/core/java/android/companion/virtual/VirtualDevice.java b/core/java/android/companion/virtual/VirtualDevice.java
index d0c8be6..97fa2ba 100644
--- a/core/java/android/companion/virtual/VirtualDevice.java
+++ b/core/java/android/companion/virtual/VirtualDevice.java
@@ -17,11 +17,14 @@
package android.companion.virtual;
import static android.companion.virtual.VirtualDeviceParams.DEVICE_POLICY_CUSTOM;
+import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_AUDIO;
+import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_CAMERA;
import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_SENSORS;
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.companion.virtual.flags.Flags;
import android.content.Context;
import android.os.Parcel;
@@ -164,6 +167,44 @@
}
}
+ /**
+ * Returns whether this device may have custom audio input device.
+ *
+ * @hide
+ */
+ @SystemApi
+ @FlaggedApi(Flags.FLAG_VDM_PUBLIC_APIS)
+ public boolean hasCustomAudioInputSupport() {
+ try {
+ return mVirtualDevice.getDevicePolicy(POLICY_TYPE_AUDIO) == DEVICE_POLICY_CUSTOM;
+ // TODO(b/291735254): also check for a custom audio injection mix for this device id.
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns whether this device may have custom cameras.
+ *
+ * <p>Returning {@code true} does not necessarily mean that this device has cameras, it only
+ * means that a {@link android.hardware.camera2.CameraManager} instance created from a
+ * {@link Context} associated with this device will return this device's cameras, if any.</p>
+ *
+ * @see Context#getDeviceId()
+ * @see Context#createDeviceContext(int)
+ *
+ * @hide
+ */
+ @SystemApi
+ @FlaggedApi(Flags.FLAG_VDM_PUBLIC_APIS)
+ public boolean hasCustomCameraSupport() {
+ try {
+ return mVirtualDevice.getDevicePolicy(POLICY_TYPE_CAMERA) == DEVICE_POLICY_CUSTOM;
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
@Override
public int describeContents() {
return 0;
diff --git a/core/java/android/companion/virtual/VirtualDeviceManager.java b/core/java/android/companion/virtual/VirtualDeviceManager.java
index 90d251b..a16e94a 100644
--- a/core/java/android/companion/virtual/VirtualDeviceManager.java
+++ b/core/java/android/companion/virtual/VirtualDeviceManager.java
@@ -63,6 +63,7 @@
import android.os.Binder;
import android.os.Looper;
import android.os.RemoteException;
+import android.util.ArraySet;
import android.util.Log;
import android.view.Surface;
import android.view.WindowManager;
@@ -74,9 +75,11 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.IntConsumer;
@@ -389,6 +392,28 @@
}
/**
+ * Returns all current persistent device IDs, including the ones for which no virtual device
+ * exists, as long as one may have existed or can be created.
+ *
+ * @hide
+ */
+ // TODO(b/315481938): Link @see VirtualDevice#getPersistentDeviceId()
+ @FlaggedApi(Flags.FLAG_PERSISTENT_DEVICE_ID_API)
+ @SystemApi
+ @NonNull
+ public Set<String> getAllPersistentDeviceIds() {
+ if (mService == null) {
+ Log.w(TAG, "Failed to retrieve persistent ids; no virtual device manager service.");
+ return Collections.emptySet();
+ }
+ try {
+ return new ArraySet<>(mService.getAllPersistentDeviceIds());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Checks whether the passed {@code deviceId} is a valid virtual device ID or not.
* {@link Context#DEVICE_ID_DEFAULT} is not valid as it is the ID of the default
* device which is not a virtual device. {@code deviceId} must correspond to a virtual device
diff --git a/core/java/android/content/pm/verify/domain/OWNERS b/core/java/android/content/pm/verify/domain/OWNERS
index c669112..b451fe4 100644
--- a/core/java/android/content/pm/verify/domain/OWNERS
+++ b/core/java/android/content/pm/verify/domain/OWNERS
@@ -1,5 +1,4 @@
# Bug component: 36137
+include /PACKAGE_MANAGER_OWNERS
-chiuwinson@google.com
-patb@google.com
-toddke@google.com
\ No newline at end of file
+wloh@google.com
\ No newline at end of file
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 0396443..1c36a88 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -1575,7 +1575,7 @@
}
@Override
- public void opChanged(int op, int uid, String packageName) {
+ public void opChanged(int op, int uid, String packageName, String persistentDeviceId) {
if (op == AppOpsManager.OP_PLAY_AUDIO) {
final Camera camera = mWeakCamera.get();
if (camera != null) {
diff --git a/core/java/android/net/flags.aconfig b/core/java/android/net/flags.aconfig
index 0ad1804..311dc09 100644
--- a/core/java/android/net/flags.aconfig
+++ b/core/java/android/net/flags.aconfig
@@ -1,50 +1,11 @@
-package: "com.android.net.flags"
+package: "android.net.platform.flags"
-flag {
- name: "track_multiple_network_activities"
- namespace: "android_core_networking"
- description: "NetworkActivityTracker tracks multiple networks including non default networks"
- bug: "267870186"
-}
-
-flag {
- name: "forbidden_capability"
- namespace: "android_core_networking"
- description: "This flag controls the forbidden capability API"
- bug: "302997505"
-}
-
-flag {
- name: "set_data_saver_via_cm"
- namespace: "android_core_networking"
- description: "Set data saver through ConnectivityManager API"
- bug: "297836825"
-}
-
-flag {
- name: "support_is_uid_networking_blocked"
- namespace: "android_core_networking"
- description: "This flag controls whether isUidNetworkingBlocked is supported"
- bug: "297836825"
-}
-
-flag {
- name: "basic_background_restrictions_enabled"
- namespace: "android_core_networking"
- description: "Block network access for apps in a low importance background state"
- bug: "304347838"
-}
-
-flag {
- name: "register_nsd_offload_engine"
- namespace: "android_core_networking"
- description: "The flag controls the access for registerOffloadEngine API in NsdManager"
- bug: "294777050"
-}
+# This file contains aconfig flags used from platform code
+# Flags used for module APIs must be in aconfig files under each modules
flag {
name: "ipsec_transform_state"
- namespace: "android_core_networking_ipsec"
+ namespace: "core_networking_ipsec"
description: "The flag controls the access for getIpSecTransformState and IpSecTransformState"
bug: "308011229"
}
diff --git a/core/java/android/os/incremental/OWNERS b/core/java/android/os/incremental/OWNERS
index 47eee64..a925564 100644
--- a/core/java/android/os/incremental/OWNERS
+++ b/core/java/android/os/incremental/OWNERS
@@ -1,6 +1,4 @@
# Bug component: 554432
-alexbuy@google.com
-schfan@google.com
-toddke@google.com
+include /PACKAGE_MANAGER_OWNERS
+
zyy@google.com
-patb@google.com
diff --git a/core/java/android/os/vibrator/VibrationConfig.java b/core/java/android/os/vibrator/VibrationConfig.java
index 92e4967..bcdb982 100644
--- a/core/java/android/os/vibrator/VibrationConfig.java
+++ b/core/java/android/os/vibrator/VibrationConfig.java
@@ -35,6 +35,7 @@
import android.util.IndentingPrintWriter;
import java.io.PrintWriter;
+import java.util.Arrays;
/**
* List of device-specific internal vibration configuration loaded from platform config.xml.
@@ -51,6 +52,8 @@
private final float mHapticChannelMaxVibrationAmplitude;
private final int mRampStepDurationMs;
private final int mRampDownDurationMs;
+ private final int mRequestVibrationParamsTimeoutMs;
+ private final int[] mRequestVibrationParamsForUsages;
private final boolean mIgnoreVibrationsOnWirelessCharger;
@@ -75,6 +78,10 @@
com.android.internal.R.integer.config_vibrationWaveformRampDownDuration, 0);
mRampStepDurationMs = loadInteger(resources,
com.android.internal.R.integer.config_vibrationWaveformRampStepDuration, 0);
+ mRequestVibrationParamsTimeoutMs = loadInteger(resources,
+ com.android.internal.R.integer.config_requestVibrationParamsTimeout, 0);
+ mRequestVibrationParamsForUsages = loadIntArray(resources,
+ com.android.internal.R.array.config_requestVibrationParamsForUsages);
mIgnoreVibrationsOnWirelessCharger = loadBoolean(resources,
com.android.internal.R.bool.config_ignoreVibrationsOnWirelessCharger, false);
@@ -115,6 +122,10 @@
return res != null ? res.getBoolean(resId) : defaultValue;
}
+ private static int[] loadIntArray(@Nullable Resources res, int resId) {
+ return res != null ? res.getIntArray(resId) : new int[0];
+ }
+
/**
* Return the maximum amplitude the vibrator can play using the audio haptic channels.
*
@@ -140,6 +151,23 @@
}
/**
+ * The duration, in milliseconds, that the vibrator control service will wait for new
+ * vibration params.
+ */
+ public int getRequestVibrationParamsTimeoutMs() {
+ return Math.max(mRequestVibrationParamsTimeoutMs, 0);
+ }
+
+ /**
+ * The list of usages that should request vibration params before they are played. These
+ * usages don't have strong latency requirements, e.g. ringtone and notification, and can be
+ * slightly delayed.
+ */
+ public int[] getRequestVibrationParamsForUsages() {
+ return mRequestVibrationParamsForUsages;
+ }
+
+ /**
* The duration, in milliseconds, that should be applied to convert vibration effect's
* {@link android.os.vibrator.RampSegment} to a {@link android.os.vibrator.StepSegment} on
* devices without PWLE support.
@@ -204,6 +232,9 @@
+ ", mDefaultMediaIntensity=" + mDefaultMediaVibrationIntensity
+ ", mDefaultNotificationIntensity=" + mDefaultNotificationVibrationIntensity
+ ", mDefaultRingIntensity=" + mDefaultRingVibrationIntensity
+ + ", mRequestVibrationParamsTimeoutMs=" + mRequestVibrationParamsTimeoutMs
+ + ", mRequestVibrationParamsForUsages=" + Arrays.toString(
+ getRequestVibrationParamsForUsagesNames())
+ "}";
}
@@ -220,4 +251,14 @@
pw.println("rampDownDurationMs = " + mRampDownDurationMs);
pw.decreaseIndent();
}
+
+ private String[] getRequestVibrationParamsForUsagesNames() {
+ int usagesCount = mRequestVibrationParamsForUsages.length;
+ String[] names = new String[usagesCount];
+ for (int i = 0; i < usagesCount; i++) {
+ names[i] = VibrationAttributes.usageToString(mRequestVibrationParamsForUsages[i]);
+ }
+
+ return names;
+ }
}
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index 5d6dfc7..7d127ad 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -2102,7 +2102,7 @@
PhoneAccountHandle accountHandle) {
TelecomManager tm = null;
try {
- tm = TelecomManager.from(context);
+ tm = context.getSystemService(TelecomManager.class);
} catch (UnsupportedOperationException e) {
if (VERBOSE_LOG) {
Log.v(LOG_TAG, "No TelecomManager found to get account address.");
diff --git a/core/java/android/security/OWNERS b/core/java/android/security/OWNERS
index 533d459..8bd6c85 100644
--- a/core/java/android/security/OWNERS
+++ b/core/java/android/security/OWNERS
@@ -1,7 +1,7 @@
# Bug component: 36824
brambonne@google.com
-brufino@google.com
+eranm@google.com
jeffv@google.com
per-file *NetworkSecurityPolicy.java = file:net/OWNERS
diff --git a/core/java/android/text/FontConfig.java b/core/java/android/text/FontConfig.java
index 94c8eaf..783f3b7 100644
--- a/core/java/android/text/FontConfig.java
+++ b/core/java/android/text/FontConfig.java
@@ -26,7 +26,6 @@
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
-import android.graphics.fonts.FontFamily.Builder.VariableFontFamilyType;
import android.graphics.fonts.FontStyle;
import android.graphics.fonts.FontVariationAxis;
import android.icu.util.ULocale;
@@ -240,6 +239,23 @@
private final @IntRange(from = 0) int mIndex;
private final @NonNull String mFontVariationSettings;
private final @Nullable String mFontFamilyName;
+ private final @VarTypeAxes int mVarTypeAxes;
+
+ /** @hide */
+ @Retention(SOURCE)
+ @IntDef(prefix = { "VAR_TYPE_AXES_" }, value = {
+ VAR_TYPE_AXES_NONE,
+ VAR_TYPE_AXES_WGHT,
+ VAR_TYPE_AXES_ITAL,
+ })
+ public @interface VarTypeAxes {}
+
+ /** @hide */
+ public static final int VAR_TYPE_AXES_NONE = 0;
+ /** @hide */
+ public static final int VAR_TYPE_AXES_WGHT = 1;
+ /** @hide */
+ public static final int VAR_TYPE_AXES_ITAL = 2;
/**
* Construct a Font instance.
@@ -248,7 +264,8 @@
*/
public Font(@NonNull File file, @Nullable File originalFile, @NonNull String postScriptName,
@NonNull FontStyle style, @IntRange(from = 0) int index,
- @NonNull String fontVariationSettings, @Nullable String fontFamilyName) {
+ @NonNull String fontVariationSettings, @Nullable String fontFamilyName,
+ @VarTypeAxes int varTypeAxes) {
mFile = file;
mOriginalFile = originalFile;
mPostScriptName = postScriptName;
@@ -256,6 +273,7 @@
mIndex = index;
mFontVariationSettings = fontVariationSettings;
mFontFamilyName = fontFamilyName;
+ mVarTypeAxes = varTypeAxes;
}
@Override
@@ -273,6 +291,7 @@
dest.writeInt(mIndex);
dest.writeString8(mFontVariationSettings);
dest.writeString8(mFontFamilyName);
+ dest.writeInt(mVarTypeAxes);
}
public static final @NonNull Creator<Font> CREATOR = new Creator<Font>() {
@@ -288,9 +307,10 @@
int index = source.readInt();
String varSettings = source.readString8();
String fallback = source.readString8();
+ int varTypeAxes = source.readInt();
return new Font(path, originalPath, postScriptName, new FontStyle(weight, slant),
- index, varSettings, fallback);
+ index, varSettings, fallback, varTypeAxes);
}
@Override
@@ -366,6 +386,15 @@
}
/**
+ * Returns the list of supported axes tags for variable family type resolution.
+ *
+ * @hide
+ */
+ public @VarTypeAxes int getVarTypeAxes() {
+ return mVarTypeAxes;
+ }
+
+ /**
* Returns the list of axes associated to this font.
* @deprecated Use getFontVariationSettings
* @hide
@@ -408,13 +437,14 @@
&& Objects.equals(mOriginalFile, font.mOriginalFile)
&& Objects.equals(mStyle, font.mStyle)
&& Objects.equals(mFontVariationSettings, font.mFontVariationSettings)
- && Objects.equals(mFontFamilyName, font.mFontFamilyName);
+ && Objects.equals(mFontFamilyName, font.mFontFamilyName)
+ && mVarTypeAxes == font.mVarTypeAxes;
}
@Override
public int hashCode() {
return Objects.hash(mFile, mOriginalFile, mStyle, mIndex, mFontVariationSettings,
- mFontFamilyName);
+ mFontFamilyName, mVarTypeAxes);
}
@Override
@@ -426,6 +456,7 @@
+ ", mIndex=" + mIndex
+ ", mFontVariationSettings='" + mFontVariationSettings + '\''
+ ", mFontFamilyName='" + mFontFamilyName + '\''
+ + ", mVarTypeAxes='" + mVarTypeAxes + '\''
+ '}';
}
}
@@ -549,7 +580,6 @@
private final @NonNull List<Font> mFonts;
private final @NonNull LocaleList mLocaleList;
private final @Variant int mVariant;
- private final int mVariableFontFamilyType;
/** @hide */
@Retention(SOURCE)
@@ -589,11 +619,10 @@
* @hide Only system server can create this instance and passed via IPC.
*/
public FontFamily(@NonNull List<Font> fonts, @NonNull LocaleList localeList,
- @Variant int variant, int variableFontFamilyType) {
+ @Variant int variant) {
mFonts = fonts;
mLocaleList = localeList;
mVariant = variant;
- mVariableFontFamilyType = variableFontFamilyType;
}
/**
@@ -644,20 +673,6 @@
return mVariant;
}
- /**
- * Returns the font family type.
- *
- * @see Builder#VARIABLE_FONT_FAMILY_TYPE_NONE
- * @see Builder#VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ITAL
- * @see Builder#VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ONLY
- * @see Builder#VARIABLE_FONT_FAMILY_TYPE_TWO_FONTS_WGHT
- * @hide
- * @return variable font family type.
- */
- public @VariableFontFamilyType int getVariableFontFamilyType() {
- return mVariableFontFamilyType;
- }
-
@Override
public int describeContents() {
return 0;
@@ -668,7 +683,6 @@
dest.writeTypedList(mFonts, flags);
dest.writeString8(mLocaleList.toLanguageTags());
dest.writeInt(mVariant);
- dest.writeInt(mVariableFontFamilyType);
}
public static final @NonNull Creator<FontFamily> CREATOR = new Creator<FontFamily>() {
@@ -679,10 +693,8 @@
source.readTypedList(fonts, Font.CREATOR);
String langTags = source.readString8();
int variant = source.readInt();
- int varFamilyType = source.readInt();
- return new FontFamily(fonts, LocaleList.forLanguageTags(langTags), variant,
- varFamilyType);
+ return new FontFamily(fonts, LocaleList.forLanguageTags(langTags), variant);
}
@Override
diff --git a/core/java/android/text/flags/flags.aconfig b/core/java/android/text/flags/flags.aconfig
index 6e45fea..f3e0ea7 100644
--- a/core/java/android/text/flags/flags.aconfig
+++ b/core/java/android/text/flags/flags.aconfig
@@ -96,3 +96,10 @@
description: "A feature flag for fixing the crash while delete text in insert mode."
bug: "314254153"
}
+
+flag {
+ name: "insert_mode_not_update_selection"
+ namespace: "text"
+ description: "Fix that InputService#onUpdateSelection is not called when insert mode gesture is performed."
+ bug: "300850862"
+}
diff --git a/core/java/android/util/Slog.java b/core/java/android/util/Slog.java
index c0ceb9ea..9ecb4cb 100644
--- a/core/java/android/util/Slog.java
+++ b/core/java/android/util/Slog.java
@@ -217,7 +217,6 @@
* @see Log#wtf(String, String)
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- @android.ravenwood.annotation.RavenwoodThrow
public static int wtf(@Nullable String tag, @NonNull String msg) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true);
}
@@ -263,7 +262,6 @@
*
* @see Log#wtf(String, Throwable)
*/
- @android.ravenwood.annotation.RavenwoodThrow
public static int wtf(@Nullable String tag, @Nullable Throwable tr) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false, true);
}
@@ -284,7 +282,6 @@
* @see Log#wtf(String, String, Throwable)
*/
@UnsupportedAppUsage
- @android.ravenwood.annotation.RavenwoodThrow
public static int wtf(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false, true);
}
diff --git a/core/java/android/view/HdrRenderState.java b/core/java/android/view/HdrRenderState.java
index 2fbbf48..eadc507 100644
--- a/core/java/android/view/HdrRenderState.java
+++ b/core/java/android/view/HdrRenderState.java
@@ -31,9 +31,11 @@
private final ViewRootImpl mViewRoot;
+ private boolean mIsHdrEnabled = false;
private boolean mIsListenerRegistered = false;
private boolean mUpdateHdrSdrRatioInfo = false;
private float mDesiredHdrSdrRatio = 1f;
+ private float mTargetDesiredHdrSdrRatio = 1f;
private float mTargetHdrSdrRatio = 1f;
private float mRenderHdrSdrRatio = 1f;
private float mPreviousRenderRatio = 1f;
@@ -50,7 +52,7 @@
}
boolean isHdrEnabled() {
- return mDesiredHdrSdrRatio >= 1.01f;
+ return mIsHdrEnabled;
}
void stopListening() {
@@ -75,9 +77,7 @@
final float maxStep = timeDelta * TRANSITION_PER_MS;
mLastUpdateMillis = frameTimeMillis;
if (hasUpdate && FLAG_ANIMATE_ENABLED) {
- if (mTargetHdrSdrRatio == 1.0f) {
- mPreviousRenderRatio = mTargetHdrSdrRatio;
- } else {
+ if (isHdrEnabled()) {
float delta = mTargetHdrSdrRatio - mPreviousRenderRatio;
if (delta > maxStep) {
mRenderHdrSdrRatio = mPreviousRenderRatio + maxStep;
@@ -85,6 +85,19 @@
mViewRoot.invalidate();
}
mPreviousRenderRatio = mRenderHdrSdrRatio;
+
+ if (mTargetDesiredHdrSdrRatio < mDesiredHdrSdrRatio) {
+ mDesiredHdrSdrRatio = Math.max(mTargetDesiredHdrSdrRatio,
+ mDesiredHdrSdrRatio - maxStep);
+ if (mDesiredHdrSdrRatio != mTargetDesiredHdrSdrRatio) {
+ mUpdateHdrSdrRatioInfo = true;
+ mViewRoot.invalidate();
+ }
+ }
+
+ } else {
+ mPreviousRenderRatio = mTargetHdrSdrRatio;
+ mDesiredHdrSdrRatio = mTargetDesiredHdrSdrRatio;
}
}
return hasUpdate;
@@ -99,15 +112,23 @@
}
void forceUpdateHdrSdrRatio() {
- mTargetHdrSdrRatio = Math.min(mDesiredHdrSdrRatio, mViewRoot.mDisplay.getHdrSdrRatio());
+ if (isHdrEnabled()) {
+ mTargetHdrSdrRatio = Math.min(mDesiredHdrSdrRatio,
+ mViewRoot.mDisplay.getHdrSdrRatio());
+ } else {
+ mTargetHdrSdrRatio = 1.0f;
+ }
mUpdateHdrSdrRatioInfo = true;
}
- void setDesiredHdrSdrRatio(float desiredRatio) {
+ void setDesiredHdrSdrRatio(boolean isHdrEnabled, float desiredRatio) {
+ mIsHdrEnabled = isHdrEnabled;
mLastUpdateMillis = SystemClock.uptimeMillis();
- // TODO: When decreasing the desired ratio we need to animate it downwards
- if (desiredRatio != mDesiredHdrSdrRatio) {
- mDesiredHdrSdrRatio = desiredRatio;
+ if (desiredRatio != mTargetDesiredHdrSdrRatio) {
+ mTargetDesiredHdrSdrRatio = desiredRatio;
+ if (mTargetDesiredHdrSdrRatio > mDesiredHdrSdrRatio || !FLAG_ANIMATE_ENABLED) {
+ mDesiredHdrSdrRatio = mTargetDesiredHdrSdrRatio;
+ }
forceUpdateHdrSdrRatio();
mViewRoot.invalidate();
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index f9abc8a..c18aeee 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -5824,9 +5824,11 @@
if (mAttachInfo.mThreadedRenderer == null) {
return;
}
- if ((colorMode == ActivityInfo.COLOR_MODE_HDR || colorMode == ActivityInfo.COLOR_MODE_HDR10)
- && !mDisplay.isHdrSdrRatioAvailable()) {
+ boolean isHdr = colorMode == ActivityInfo.COLOR_MODE_HDR
+ || colorMode == ActivityInfo.COLOR_MODE_HDR10;
+ if (isHdr && !mDisplay.isHdrSdrRatioAvailable()) {
colorMode = ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT;
+ isHdr = false;
}
// TODO: Centralize this sanitization? Why do we let setting bad modes?
// Alternatively, can we just let HWUI figure it out? Do we need to care here?
@@ -5839,7 +5841,7 @@
desiredRatio = automaticRatio;
}
- mHdrRenderState.setDesiredHdrSdrRatio(desiredRatio);
+ mHdrRenderState.setDesiredHdrSdrRatio(isHdr, desiredRatio);
}
@Override
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 0654add..2433bd8 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -7597,14 +7597,6 @@
}
/**
- * Append additional instructions to this {@link DrawInstructions} object.
- */
- @FlaggedApi(FLAG_DRAW_DATA_PARCEL)
- public void appendInstructions(@NonNull final byte[] instructions) {
- mInstructions.add(instructions);
- }
-
- /**
* Builder class for {@link DrawInstructions} objects.
*/
@FlaggedApi(FLAG_DRAW_DATA_PARCEL)
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index e812f85..90d5140 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -243,6 +243,7 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastMath;
import com.android.internal.util.Preconditions;
+import com.android.text.flags.Flags;
import libcore.util.EmptyArray;
@@ -539,7 +540,6 @@
// System wide time for last cut, copy or text changed action.
static long sLastCutCopyOrTextChangedTime;
-
private ColorStateList mTextColor;
private ColorStateList mHintTextColor;
private ColorStateList mLinkTextColor;
@@ -2857,7 +2857,38 @@
}
if (updateText) {
- setText(mText);
+ if (Flags.insertModeNotUpdateSelection()) {
+ // Update the transformation text.
+ if (mTransformation == null) {
+ mTransformed = mText;
+ } else {
+ mTransformed = mTransformation.getTransformation(mText, this);
+ }
+ if (mTransformed == null) {
+ // Should not happen if the transformation method follows the non-null
+ // postcondition.
+ mTransformed = "";
+ }
+ final boolean isOffsetMapping = mTransformed instanceof OffsetMapping;
+
+ // If the mText is a Spannable and the new TransformationMethod needs to listen to
+ // its updates, apply the watcher on it.
+ if (mTransformation != null && mText instanceof Spannable
+ && (!mAllowTransformationLengthChange || isOffsetMapping)) {
+ Spannable sp = (Spannable) mText;
+ final int priority = isOffsetMapping ? OFFSET_MAPPING_SPAN_PRIORITY : 0;
+ sp.setSpan(mTransformation, 0, mText.length(),
+ Spanned.SPAN_INCLUSIVE_INCLUSIVE
+ | (priority << Spanned.SPAN_PRIORITY_SHIFT));
+ }
+ if (mLayout != null) {
+ nullLayouts();
+ requestLayout();
+ invalidate();
+ }
+ } else {
+ setText(mText);
+ }
}
if (hasPasswordTransformationMethod()) {
diff --git a/core/java/com/android/internal/app/IAppOpsActiveCallback.aidl b/core/java/com/android/internal/app/IAppOpsActiveCallback.aidl
index ae6ad32..94bbd72 100644
--- a/core/java/com/android/internal/app/IAppOpsActiveCallback.aidl
+++ b/core/java/com/android/internal/app/IAppOpsActiveCallback.aidl
@@ -19,5 +19,5 @@
// Iterface to observe op active changes
oneway interface IAppOpsActiveCallback {
void opActiveChanged(int op, int uid, String packageName, String attributionTag,
- boolean active, int attributionFlags, int attributionChainId);
+ int virtualDeviceId, boolean active, int attributionFlags, int attributionChainId);
}
diff --git a/core/java/com/android/internal/app/IAppOpsCallback.aidl b/core/java/com/android/internal/app/IAppOpsCallback.aidl
index 024ff66..3a9525c 100644
--- a/core/java/com/android/internal/app/IAppOpsCallback.aidl
+++ b/core/java/com/android/internal/app/IAppOpsCallback.aidl
@@ -19,5 +19,5 @@
// This interface is also used by native code, so must
// be kept in sync with frameworks/native/libs/permission/include/binder/IAppOpsCallback.h
oneway interface IAppOpsCallback {
- void opChanged(int op, int uid, String packageName);
+ void opChanged(int op, int uid, String packageName, String persistentDeviceId);
}
diff --git a/core/java/com/android/internal/app/IAppOpsNotedCallback.aidl b/core/java/com/android/internal/app/IAppOpsNotedCallback.aidl
index f3759e0..123f4f4 100644
--- a/core/java/com/android/internal/app/IAppOpsNotedCallback.aidl
+++ b/core/java/com/android/internal/app/IAppOpsNotedCallback.aidl
@@ -18,5 +18,6 @@
// Iterface to observe op note/checks of ops
oneway interface IAppOpsNotedCallback {
- void opNoted(int op, int uid, String packageName, String attributionTag, int flags, int mode);
+ void opNoted(int op, int uid, String packageName, String attributionTag, int virtualDeviceId,
+ int flags, int mode);
}
diff --git a/core/java/com/android/internal/app/IAppOpsStartedCallback.aidl b/core/java/com/android/internal/app/IAppOpsStartedCallback.aidl
index 06640cb..fdae37a 100644
--- a/core/java/com/android/internal/app/IAppOpsStartedCallback.aidl
+++ b/core/java/com/android/internal/app/IAppOpsStartedCallback.aidl
@@ -18,6 +18,6 @@
// Iterface to observe op starts
oneway interface IAppOpsStartedCallback {
- void opStarted(int op, int uid, String packageName, String attributionTag, int flags, int mode,
- int startedType, int attributionFlags, int attributionChainId);
+ void opStarted(int op, int uid, String packageName, String attributionTag, int virtualDeviceId,
+ int flags, int mode, int startedType, int attributionFlags, int attributionChainId);
}
diff --git a/core/java/com/android/internal/os/AndroidPrintStream.java b/core/java/com/android/internal/os/AndroidPrintStream.java
index a6e41ff..bb388bb 100644
--- a/core/java/com/android/internal/os/AndroidPrintStream.java
+++ b/core/java/com/android/internal/os/AndroidPrintStream.java
@@ -24,6 +24,7 @@
*
* {@hide}
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
class AndroidPrintStream extends LoggingPrintStream {
private final int priority;
diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java
index 28b98d6..cdac097 100644
--- a/core/java/com/android/internal/os/RuntimeInit.java
+++ b/core/java/com/android/internal/os/RuntimeInit.java
@@ -39,6 +39,7 @@
import libcore.content.type.MimeMap;
+import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -50,6 +51,7 @@
* public consumption.
* @hide
*/
+@android.ravenwood.annotation.RavenwoodKeepPartialClass
public class RuntimeInit {
final static String TAG = "AndroidRuntime";
final static boolean DEBUG = false;
@@ -67,7 +69,15 @@
private static volatile ApplicationWtfHandler sDefaultApplicationWtfHandler;
+ /**
+ * Stored values of System.out and System.err before they've been replaced by
+ * redirectLogStreams(). Kept open here for other Ravenwood internals to use.
+ */
+ public static PrintStream sOut$ravenwood;
+ public static PrintStream sErr$ravenwood;
+
private static final native void nativeFinishInit();
+
private static final native void nativeSetExitWithoutCleanup(boolean exitWithoutCleanup);
private static int Clog_e(String tag, String msg, Throwable tr) {
@@ -385,6 +395,7 @@
/**
* Redirect System.out and System.err to the Android log.
*/
+ @android.ravenwood.annotation.RavenwoodReplace
public static void redirectLogStreams() {
System.out.close();
System.setOut(new AndroidPrintStream(Log.INFO, "System.out"));
@@ -392,6 +403,17 @@
System.setErr(new AndroidPrintStream(Log.WARN, "System.err"));
}
+ public static void redirectLogStreams$ravenwood() {
+ if (sOut$ravenwood == null) {
+ sOut$ravenwood = System.out;
+ System.setOut(new AndroidPrintStream(Log.INFO, "System.out"));
+ }
+ if (sErr$ravenwood == null) {
+ sErr$ravenwood = System.err;
+ System.setErr(new AndroidPrintStream(Log.WARN, "System.err"));
+ }
+ }
+
/**
* Report a serious error in the current process. May or may not cause
* the process to terminate (depends on system settings).
@@ -399,6 +421,7 @@
* @param tag to record with the error
* @param t exception describing the error site and conditions
*/
+ @android.ravenwood.annotation.RavenwoodReplace
public static void wtf(String tag, Throwable t, boolean system) {
try {
boolean exit = false;
@@ -436,6 +459,11 @@
}
}
+ public static void wtf$ravenwood(String tag, Throwable t, boolean system) {
+ // We've already emitted to logs, so there's nothing more to do here,
+ // as we don't have a DropBox pipeline configured
+ }
+
/**
* Set the default {@link ApplicationWtfHandler}, in case the ActivityManager is not ready yet.
*/
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 4e3b64c..b4f9ee3 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -2583,7 +2583,7 @@
mNavigationBarDividerColor = a.getColor(R.styleable.Window_navigationBarDividerColor,
Color.TRANSPARENT);
}
- if (!targetPreQ && !mEdgeToEdgeEnforced) {
+ if (!targetPreQ) {
mEnsureStatusBarContrastWhenTransparent = a.getBoolean(
R.styleable.Window_enforceStatusBarContrast, false);
mEnsureNavigationBarContrastWhenTransparent = a.getBoolean(
@@ -3966,9 +3966,6 @@
@Override
public void setStatusBarContrastEnforced(boolean ensureContrast) {
- if (mEdgeToEdgeEnforced) {
- return;
- }
mEnsureStatusBarContrastWhenTransparent = ensureContrast;
if (mDecor != null) {
mDecor.updateColorViews(null, false /* animate */);
@@ -3982,9 +3979,6 @@
@Override
public void setNavigationBarContrastEnforced(boolean enforceContrast) {
- if (mEdgeToEdgeEnforced) {
- return;
- }
mEnsureNavigationBarContrastWhenTransparent = enforceContrast;
if (mDecor != null) {
mDecor.updateColorViews(null, false /* animate */);
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl
index 5351c6d..ed43b81 100644
--- a/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -151,8 +151,17 @@
* @param hidesStatusBar whether it is being hidden
*/
void setTopAppHidesStatusBar(boolean hidesStatusBar);
-
+ /**
+ * Add a tile to the Quick Settings Panel to the first item in the QS Panel
+ * @param tile the ComponentName of the {@link android.service.quicksettings.TileService}
+ */
void addQsTile(in ComponentName tile);
+ /**
+ * Add a tile to the Quick Settings Panel
+ * @param tile the ComponentName of the {@link android.service.quicksettings.TileService}
+ * @param end if true, the tile will be added at the end. If false, at the beginning.
+ */
+ void addQsTileToFrontOrEnd(in ComponentName tile, boolean end);
void remQsTile(in ComponentName tile);
void setQsTiles(in String[] tiles);
void clickQsTile(in ComponentName tile);
diff --git a/core/jni/Android.bp b/core/jni/Android.bp
index 656cc3e..3fc1683 100644
--- a/core/jni/Android.bp
+++ b/core/jni/Android.bp
@@ -284,7 +284,6 @@
"libscrypt_static",
"libstatssocket_lazy",
"libskia",
- "libperfetto_client_experimental",
],
shared_libs: [
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 3413ede..969e47b 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -25,6 +25,7 @@
#include <android_os_Parcel.h>
#include <audiomanager/AudioManager.h>
#include <jni.h>
+#include <media/AidlConversion.h>
#include <media/AudioContainers.h>
#include <media/AudioPolicy.h>
#include <media/AudioSystem.h>
@@ -66,6 +67,11 @@
jmethodID toArray;
} gArrayListMethods;
+static jclass gIntArrayClass;
+static struct {
+ jmethodID add;
+} gIntArrayMethods;
+
static jclass gBooleanClass;
static jmethodID gBooleanCstor;
@@ -1607,6 +1613,48 @@
return jStatus;
}
+// From AudioDeviceInfo
+static const int GET_DEVICES_INPUTS = 0x0001;
+static const int GET_DEVICES_OUTPUTS = 0x0002;
+
+static int android_media_AudioSystem_getSupportedDeviceTypes(JNIEnv *env, jobject clazz,
+ jint direction, jobject jDeviceTypes) {
+ if (jDeviceTypes == NULL) {
+ ALOGE("%s NULL Device Types IntArray", __func__);
+ return AUDIO_JAVA_BAD_VALUE;
+ }
+ if (!env->IsInstanceOf(jDeviceTypes, gIntArrayClass)) {
+ ALOGE("%s not an IntArray", __func__);
+ return AUDIO_JAVA_BAD_VALUE;
+ }
+
+ // Convert AudioManager.GET_DEVICES_ flags to AUDIO_PORT_ROLE_ constants
+ audio_port_role_t role;
+ if (direction == GET_DEVICES_INPUTS) {
+ role = AUDIO_PORT_ROLE_SOURCE;
+ } else if (direction == GET_DEVICES_OUTPUTS) {
+ role = AUDIO_PORT_ROLE_SINK;
+ } else {
+ ALOGE("%s invalid direction : 0x%X", __func__, direction);
+ return AUDIO_JAVA_BAD_VALUE;
+ }
+
+ std::vector<media::AudioPortFw> deviceList;
+ AudioSystem::listDeclaredDevicePorts(static_cast<media::AudioPortRole>(role), &deviceList);
+
+ // Walk the device list
+ for (const auto &device : deviceList) {
+ ConversionResult<audio_port_v7> result = aidl2legacy_AudioPortFw_audio_port_v7(device);
+
+ struct audio_port_v7 port = VALUE_OR_RETURN_STATUS(result);
+ assert(port.type == AUDIO_PORT_TYPE_DEVICE);
+
+ env->CallVoidMethod(jDeviceTypes, gIntArrayMethods.add, port.ext.device.type);
+ }
+
+ return AUDIO_JAVA_SUCCESS;
+}
+
static int
android_media_AudioSystem_createAudioPatch(JNIEnv *env, jobject clazz,
jobjectArray jPatches, jobjectArray jSources, jobjectArray jSinks)
@@ -3184,6 +3232,8 @@
android_media_AudioSystem_setAudioFlingerBinder),
MAKE_JNI_NATIVE_METHOD("listAudioPorts", "(Ljava/util/ArrayList;[I)I",
android_media_AudioSystem_listAudioPorts),
+ MAKE_JNI_NATIVE_METHOD("getSupportedDeviceTypes", "(ILandroid/util/IntArray;)I",
+ android_media_AudioSystem_getSupportedDeviceTypes),
MAKE_JNI_NATIVE_METHOD("createAudioPatch",
"([Landroid/media/AudioPatch;[Landroid/media/"
"AudioPortConfig;[Landroid/media/AudioPortConfig;)I",
@@ -3325,6 +3375,10 @@
gArrayListMethods.add = GetMethodIDOrDie(env, arrayListClass, "add", "(Ljava/lang/Object;)Z");
gArrayListMethods.toArray = GetMethodIDOrDie(env, arrayListClass, "toArray", "()[Ljava/lang/Object;");
+ jclass intArrayClass = FindClassOrDie(env, "android/util/IntArray");
+ gIntArrayClass = MakeGlobalRefOrDie(env, intArrayClass);
+ gIntArrayMethods.add = GetMethodIDOrDie(env, gIntArrayClass, "add", "(I)V");
+
jclass booleanClass = FindClassOrDie(env, "java/lang/Boolean");
gBooleanClass = MakeGlobalRefOrDie(env, booleanClass);
gBooleanCstor = GetMethodIDOrDie(env, booleanClass, "<init>", "(Z)V");
diff --git a/core/jni/android_tracing_PerfettoDataSource.cpp b/core/jni/android_tracing_PerfettoDataSource.cpp
index d710698..16c3ca9 100644
--- a/core/jni/android_tracing_PerfettoDataSource.cpp
+++ b/core/jni/android_tracing_PerfettoDataSource.cpp
@@ -25,7 +25,6 @@
#include <perfetto/public/producer.h>
#include <perfetto/public/protos/trace/test_event.pzc.h>
#include <perfetto/public/protos/trace/trace_packet.pzc.h>
-#include <perfetto/tracing.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
diff --git a/core/jni/android_tracing_PerfettoDataSource.h b/core/jni/android_tracing_PerfettoDataSource.h
index 4ddf1d8..61a7654 100644
--- a/core/jni/android_tracing_PerfettoDataSource.h
+++ b/core/jni/android_tracing_PerfettoDataSource.h
@@ -23,10 +23,10 @@
#include <perfetto/public/producer.h>
#include <perfetto/public/protos/trace/test_event.pzc.h>
#include <perfetto/public/protos/trace/trace_packet.pzc.h>
-#include <perfetto/tracing.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
+#include <map>
#include <sstream>
#include <thread>
diff --git a/core/jni/android_tracing_PerfettoDataSourceInstance.cpp b/core/jni/android_tracing_PerfettoDataSourceInstance.cpp
index e659bf1..3fbd5b3 100644
--- a/core/jni/android_tracing_PerfettoDataSourceInstance.cpp
+++ b/core/jni/android_tracing_PerfettoDataSourceInstance.cpp
@@ -25,7 +25,6 @@
#include <perfetto/public/producer.h>
#include <perfetto/public/protos/trace/test_event.pzc.h>
#include <perfetto/public/protos/trace/trace_packet.pzc.h>
-#include <perfetto/tracing.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
diff --git a/core/jni/android_tracing_PerfettoDataSourceInstance.h b/core/jni/android_tracing_PerfettoDataSourceInstance.h
index d577655..ebb5259 100644
--- a/core/jni/android_tracing_PerfettoDataSourceInstance.h
+++ b/core/jni/android_tracing_PerfettoDataSourceInstance.h
@@ -23,7 +23,6 @@
#include <perfetto/public/producer.h>
#include <perfetto/public/protos/trace/test_event.pzc.h>
#include <perfetto/public/protos/trace/trace_packet.pzc.h>
-#include <perfetto/tracing.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
diff --git a/core/jni/android_tracing_PerfettoProducer.cpp b/core/jni/android_tracing_PerfettoProducer.cpp
index ce72f58..f8c63c8 100644
--- a/core/jni/android_tracing_PerfettoProducer.cpp
+++ b/core/jni/android_tracing_PerfettoProducer.cpp
@@ -23,7 +23,6 @@
#include <perfetto/public/producer.h>
#include <perfetto/public/protos/trace/test_event.pzc.h>
#include <perfetto/public/protos/trace/trace_packet.pzc.h>
-#include <perfetto/tracing.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp
index d4a7462..d11166f 100644
--- a/core/jni/android_view_InputChannel.cpp
+++ b/core/jni/android_view_InputChannel.cpp
@@ -203,8 +203,10 @@
if (parcel) {
bool isInitialized = parcel->readInt32();
if (isInitialized) {
- std::unique_ptr<InputChannel> inputChannel = std::make_unique<InputChannel>();
- inputChannel->readFromParcel(parcel);
+ android::os::InputChannelCore parcelableChannel;
+ parcelableChannel.readFromParcel(parcel);
+ std::unique_ptr<InputChannel> inputChannel =
+ InputChannel::create(std::move(parcelableChannel));
NativeInputChannel* nativeInputChannel =
new NativeInputChannel(std::move(inputChannel));
return reinterpret_cast<jlong>(nativeInputChannel);
@@ -228,7 +230,9 @@
return;
}
parcel->writeInt32(1); // initialized
- nativeInputChannel->getInputChannel()->writeToParcel(parcel);
+ android::os::InputChannelCore parcelableChannel;
+ nativeInputChannel->getInputChannel()->copyTo(parcelableChannel);
+ parcelableChannel.writeToParcel(parcel);
}
static jstring android_view_InputChannel_nativeGetName(JNIEnv* env, jobject obj, jlong channel) {
diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp
index f7d8152..f93b306 100644
--- a/core/jni/android_view_InputEventReceiver.cpp
+++ b/core/jni/android_view_InputEventReceiver.cpp
@@ -189,11 +189,11 @@
void NativeInputEventReceiver::setFdEvents(int events) {
if (mFdEvents != events) {
mFdEvents = events;
- auto&& fd = mInputConsumer.getChannel()->getFd();
+ const int fd = mInputConsumer.getChannel()->getFd();
if (events) {
- mMessageQueue->getLooper()->addFd(fd.get(), 0, events, this, nullptr);
+ mMessageQueue->getLooper()->addFd(fd, 0, events, this, nullptr);
} else {
- mMessageQueue->getLooper()->removeFd(fd.get());
+ mMessageQueue->getLooper()->removeFd(fd);
}
}
}
diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp
index 6bdf821..323f7b6 100644
--- a/core/jni/android_view_InputEventSender.cpp
+++ b/core/jni/android_view_InputEventSender.cpp
@@ -102,8 +102,8 @@
}
status_t NativeInputEventSender::initialize() {
- auto&& receiveFd = mInputPublisher.getChannel()->getFd();
- mMessageQueue->getLooper()->addFd(receiveFd.get(), 0, ALOOPER_EVENT_INPUT, this, NULL);
+ const int receiveFd = mInputPublisher.getChannel()->getFd();
+ mMessageQueue->getLooper()->addFd(receiveFd, 0, ALOOPER_EVENT_INPUT, this, NULL);
return OK;
}
@@ -112,7 +112,7 @@
LOG(DEBUG) << "channel '" << getInputChannelName() << "' ~ Disposing input event sender.";
}
- mMessageQueue->getLooper()->removeFd(mInputPublisher.getChannel()->getFd().get());
+ mMessageQueue->getLooper()->removeFd(mInputPublisher.getChannel()->getFd());
}
status_t NativeInputEventSender::sendKeyEvent(uint32_t seq, const KeyEvent* event) {
diff --git a/core/proto/OWNERS b/core/proto/OWNERS
index a854e36..381580b 100644
--- a/core/proto/OWNERS
+++ b/core/proto/OWNERS
@@ -13,7 +13,7 @@
jjaggi@google.com
kwekua@google.com
roosa@google.com
-per-file package_item_info.proto = toddke@google.com,patb@google.com
+per-file package_item_info.proto = file:/PACKAGE_MANAGER_OWNERS
per-file usagestatsservice.proto, usagestatsservice_v2.proto = file:/core/java/android/app/usage/OWNERS
per-file apphibernationservice.proto = file:/core/java/android/apphibernation/OWNERS
per-file android/hardware/sensorprivacy.proto = ntmyren@google.com,evanseverson@google.com
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index ebb0d34..238f242 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -283,6 +283,20 @@
when there's no network connection. If the scan doesn't timeout, use zero -->
<integer name="config_radioScanningTimeout">0</integer>
+ <!-- The duration (in milliseconds) that the vibrator control service will wait for new
+ vibration params. -->
+ <integer name="config_requestVibrationParamsTimeout">50</integer>
+
+ <!-- Array containing the usages that should request vibration params before they are played.
+ These usages don't have strong latency requirements, e.g. ringtone and notification, and
+ can be slightly delayed. -->
+ <integer-array name="config_requestVibrationParamsForUsages">
+ <item>17</item> <!-- USAGE_ALARM -->
+ <item>33</item> <!-- USAGE_RINGTONE -->
+ <item>49</item> <!-- USAGE_NOTIFICATION -->
+ <item>65</item> <!-- USAGE_COMMUNICATION_REQUEST -->
+ </integer-array>
+
<!-- XXXXX NOTE THE FOLLOWING RESOURCES USE THE WRONG NAMING CONVENTION.
Please don't copy them, copy anything else. -->
@@ -3327,9 +3341,27 @@
<string name="config_carrierAppInstallDialogComponent" translatable="false"
>com.android.simappdialog/com.android.simappdialog.InstallCarrierAppActivity</string>
- <!-- Name of the dialog that is used to get or save an app credential -->
+ <!-- Name of the default framework dialog that is used to get or save an app credential.
+
+ This UI should be always launch-able and is used as a fallback when an oem replacement activity
+ (defined at config_oemCredentialManagerDialogComponent) is undefined / not found. -->
<string name="config_credentialManagerDialogComponent" translatable="false"
>com.android.credentialmanager/com.android.credentialmanager.CredentialSelectorActivity</string>
+ <!-- Whether to allow the credential selector activity to be replaced by an activity at
+ run-time (restricted to the privileged activity specified by
+ config_credentialSelectorActivityName).
+
+ When disabled, the fallback activity defined at
+ config_credentialManagerDialogComponent will be used instead. -->
+ <bool name="config_enableOemCredentialManagerDialogComponent" translatable="false">true</bool>
+ <!-- Fully qualified activity name providing the credential selector UI, that serves the
+ CredentialManager APIs.
+
+ Used only when config_enableOemCredentialManagerDialogComponent is true.
+
+ If the activity specified cannot be found or launched, then the fallback activity defined at
+ config_credentialManagerDialogComponent will be used instead. -->
+ <string name="config_oemCredentialManagerDialogComponent" translatable="false"></string>
<!-- Name of the broadcast receiver that is used to receive provider change events -->
<string name="config_credentialManagerReceiverComponent" translatable="false"
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index dc2f74b..8b74cbf 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2080,6 +2080,8 @@
<java-symbol type="bool" name="config_ignoreVibrationsOnWirelessCharger" />
<java-symbol type="integer" name="config_vibrationWaveformRampDownDuration" />
<java-symbol type="integer" name="config_radioScanningTimeout" />
+ <java-symbol type="integer" name="config_requestVibrationParamsTimeout" />
+ <java-symbol type="array" name="config_requestVibrationParamsForUsages" />
<java-symbol type="integer" name="config_screenBrightnessSettingMinimum" />
<java-symbol type="integer" name="config_screenBrightnessSettingMaximum" />
<java-symbol type="integer" name="config_screenBrightnessSettingDefault" />
@@ -2281,6 +2283,8 @@
<java-symbol type="string" name="config_platformVpnConfirmDialogComponent" />
<java-symbol type="string" name="config_carrierAppInstallDialogComponent" />
<java-symbol type="string" name="config_credentialManagerDialogComponent" />
+ <java-symbol type="bool" name="config_enableOemCredentialManagerDialogComponent" />
+ <java-symbol type="string" name="config_oemCredentialManagerDialogComponent" />
<java-symbol type="string" name="config_credentialManagerReceiverComponent" />
<java-symbol type="string" name="config_defaultNetworkScorerPackageName" />
<java-symbol type="string" name="config_persistentDataPackageName" />
diff --git a/core/tests/coretests/src/android/graphics/FontListParserTest.java b/core/tests/coretests/src/android/graphics/FontListParserTest.java
index 4dd5889..5f96c17 100644
--- a/core/tests/coretests/src/android/graphics/FontListParserTest.java
+++ b/core/tests/coretests/src/android/graphics/FontListParserTest.java
@@ -22,14 +22,18 @@
import static android.text.FontConfig.FontFamily.VARIANT_COMPACT;
import static android.text.FontConfig.FontFamily.VARIANT_DEFAULT;
import static android.text.FontConfig.FontFamily.VARIANT_ELEGANT;
+import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE;
+import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ONLY;
+import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ITAL;
+import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_TWO_FONTS_WGHT;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.fail;
import android.graphics.fonts.FontCustomizationParser;
-import android.graphics.fonts.FontFamily;
import android.graphics.fonts.FontStyle;
+import android.graphics.fonts.SystemFonts;
import android.os.LocaleList;
import android.text.FontConfig;
import android.util.Xml;
@@ -64,9 +68,9 @@
FontConfig.NamedFamilyList expected = new FontConfig.NamedFamilyList(
Collections.singletonList(new FontConfig.FontFamily(
Arrays.asList(new FontConfig.Font(new File("test.ttf"), null, "test",
- new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 0, "", null)),
- LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE)), "sans-serif");
+ new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 0, "", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT)), "sans-serif");
FontConfig.NamedFamilyList family = readNamedFamily(xml);
assertThat(family).isEqualTo(expected);
}
@@ -82,12 +86,11 @@
Arrays.asList(
new FontConfig.Font(new File("test.ttf"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 0, "", null),
+ 0, "", null, FontConfig.Font.VAR_TYPE_AXES_NONE),
new FontConfig.Font(new File("test.ttf"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 0, "", "serif")),
- LocaleList.forLanguageTags("en"), VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE);
+ 0, "", "serif", FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.forLanguageTags("en"), VARIANT_DEFAULT);
FontConfig.FontFamily family = readFamily(xml);
assertThat(family).isEqualTo(expected);
@@ -103,9 +106,8 @@
Arrays.asList(
new FontConfig.Font(new File("test.ttf"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 0, "", null)),
- LocaleList.forLanguageTags("en"), VARIANT_COMPACT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE);
+ 0, "", null, FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.forLanguageTags("en"), VARIANT_COMPACT);
FontConfig.FontFamily family = readFamily(xml);
assertThat(family).isEqualTo(expected);
@@ -121,9 +123,8 @@
Arrays.asList(
new FontConfig.Font(new File("test.ttf"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 0, "", null)),
- LocaleList.forLanguageTags("en"), VARIANT_ELEGANT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE);
+ 0, "", null, FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.forLanguageTags("en"), VARIANT_ELEGANT);
FontConfig.FontFamily family = readFamily(xml);
assertThat(family).isEqualTo(expected);
@@ -140,13 +141,15 @@
FontConfig.NamedFamilyList expected = new FontConfig.NamedFamilyList(
Collections.singletonList(new FontConfig.FontFamily(Arrays.asList(
new FontConfig.Font(new File("normal.ttf"), null, "test",
- new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 0, "", null),
+ new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 0, "", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE),
new FontConfig.Font(new File("weight.ttf"), null, "test",
- new FontStyle(100, FONT_SLANT_UPRIGHT), 0, "", null),
+ new FontStyle(100, FONT_SLANT_UPRIGHT), 0, "", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE),
new FontConfig.Font(new File("italic.ttf"), null, "test",
- new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_ITALIC), 0, "", null)),
- LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE)), "sans-serif");
+ new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_ITALIC), 0, "", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT)), "sans-serif");
FontConfig.NamedFamilyList family = readNamedFamily(xml);
assertThat(family).isEqualTo(expected);
}
@@ -168,12 +171,13 @@
Collections.singletonList(new FontConfig.FontFamily(Arrays.asList(
new FontConfig.Font(new File("test-VF.ttf"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 0, "'wdth' 100.0,'wght' 200.0", null),
+ 0, "'wdth' 100.0,'wght' 200.0", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE),
new FontConfig.Font(new File("test-VF.ttf"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 0, "'wdth' 400.0,'wght' 700.0", null)),
- LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE)),
+ 0, "'wdth' 400.0,'wght' 700.0", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT)),
"sans-serif");
FontConfig.NamedFamilyList family = readNamedFamily(xml);
assertThat(family).isEqualTo(expected);
@@ -190,12 +194,11 @@
Collections.singletonList(new FontConfig.FontFamily(Arrays.asList(
new FontConfig.Font(new File("test.ttc"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 0, "", null),
+ 0, "", null, FontConfig.Font.VAR_TYPE_AXES_NONE),
new FontConfig.Font(new File("test.ttc"), null, "test",
new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
- 1, "", null)),
- LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE)),
+ 1, "", null, FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT)),
"sans-serif");
FontConfig.NamedFamilyList family = readNamedFamily(xml);
assertThat(family).isEqualTo(expected);
@@ -211,11 +214,12 @@
FontConfig.NamedFamilyList expected = new FontConfig.NamedFamilyList(
Collections.singletonList(new FontConfig.FontFamily(Arrays.asList(
new FontConfig.Font(new File("test.ttc"), null, "foo",
- new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 0, "", null),
+ new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 0, "", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE),
new FontConfig.Font(new File("test.ttc"), null, "test",
- new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 1, "", null)),
- LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE)), "sans-serif");
+ new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT), 1, "", null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE)),
+ LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT)), "sans-serif");
FontConfig.NamedFamilyList family = readNamedFamily(xml);
assertThat(family).isEqualTo(expected);
}
@@ -385,14 +389,81 @@
public void varFamilyType() throws Exception {
String xml = "<?xml version='1.0' encoding='UTF-8'?>"
+ "<familyset>"
- + " <family name='sans-serif' varFamilyType='1'>"
- + " <font>test.ttf</font>"
+ + " <family name='sans-serif'>"
+ + " <font supportedAxes='wght'>test.ttf</font>"
+ + " <font supportedAxes='ital'>test.ttf</font>"
+ + " <font supportedAxes='wght,ital'>test.ttf</font>"
+ " </family>"
+ "</familyset>";
FontConfig config = readFamilies(xml, true /* include non-existing font files */);
List<FontConfig.FontFamily> families = config.getFontFamilies();
assertThat(families.size()).isEqualTo(1); // legacy one should be ignored.
- assertThat(families.get(0).getVariableFontFamilyType()).isEqualTo(1);
+ assertThat(families.get(0).getFontList().get(0).getVarTypeAxes())
+ .isEqualTo(FontConfig.Font.VAR_TYPE_AXES_WGHT);
+ assertThat(families.get(0).getFontList().get(1).getVarTypeAxes())
+ .isEqualTo(FontConfig.Font.VAR_TYPE_AXES_ITAL);
+ assertThat(families.get(0).getFontList().get(2).getVarTypeAxes())
+ .isEqualTo(FontConfig.Font.VAR_TYPE_AXES_WGHT | FontConfig.Font.VAR_TYPE_AXES_ITAL);
+ }
+
+ @Test
+ public void varFamilyTypeRsolve() throws Exception {
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>"
+ + "<familyset>"
+ + " <family name='sans-serif'>"
+ + " <font style='normal' supportedAxes='wght'>test.ttf</font>"
+ + " </family>"
+ + " <family>"
+ + " <font style='normal' supportedAxes='wght'>test.ttf</font>"
+ + " <font style='italic' supportedAxes='wght'>test.ttf</font>"
+ + " </family>"
+ + " <family>"
+ + " <font supportedAxes='wght,ital'>test.ttf</font>"
+ + " </family>"
+ + " <family>"
+ + " <font supportedAxes='ital'>test.ttf</font>"
+ + " </family>"
+ + " <family>"
+ + " <font>test.ttf</font>"
+ + " </family>"
+ + "</familyset>";
+ FontConfig config = readFamilies(xml, true /* include non-existing font files */);
+ List<FontConfig.FontFamily> families = config.getFontFamilies();
+ assertThat(families.size()).isEqualTo(5);
+ assertThat(SystemFonts.resolveVarFamilyType(families.get(0), null))
+ .isEqualTo(VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ONLY);
+ assertThat(SystemFonts.resolveVarFamilyType(families.get(1), null))
+ .isEqualTo(VARIABLE_FONT_FAMILY_TYPE_TWO_FONTS_WGHT);
+ assertThat(SystemFonts.resolveVarFamilyType(families.get(2), null))
+ .isEqualTo(VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ITAL);
+ assertThat(SystemFonts.resolveVarFamilyType(families.get(3), null))
+ .isEqualTo(VARIABLE_FONT_FAMILY_TYPE_NONE);
+ assertThat(SystemFonts.resolveVarFamilyType(families.get(4), null))
+ .isEqualTo(VARIABLE_FONT_FAMILY_TYPE_NONE);
+ }
+
+ @Test
+ public void varFamilyTypeRsolve_ForName() throws Exception {
+ String xml = "<?xml version='1.0' encoding='UTF-8'?>"
+ + "<familyset>"
+ + " <family name='sans-serif'>"
+ + " <font style='normal' supportedAxes='wght'>test.ttf</font>"
+ + " </family>"
+ + " <family name='serif'>"
+ + " <font style='normal' supportedAxes='wght'>test.ttf</font>"
+ + " </family>"
+ + " <family>"
+ + " <font style='normal' supportedAxes='wght'>test.ttf</font>"
+ + " <font fallbackFor='serif' supportedAxes='wght,ital'>test.ttf</font>"
+ + " </family>"
+ + "</familyset>";
+ FontConfig config = readFamilies(xml, true /* include non-existing font files */);
+ List<FontConfig.FontFamily> families = config.getFontFamilies();
+ assertThat(families.size()).isEqualTo(2);
+ assertThat(SystemFonts.resolveVarFamilyType(families.get(1), null))
+ .isEqualTo(VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ONLY);
+ assertThat(SystemFonts.resolveVarFamilyType(families.get(1), "serif"))
+ .isEqualTo(VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ITAL);
}
private FontConfig readFamilies(String xml, boolean allowNonExisting)
diff --git a/core/tests/coretests/src/android/util/LogTest.java b/core/tests/coretests/src/android/util/LogTest.java
index f9966a1..15caac9 100644
--- a/core/tests/coretests/src/android/util/LogTest.java
+++ b/core/tests/coretests/src/android/util/LogTest.java
@@ -37,6 +37,13 @@
private static final String LOG_TAG = "LogTest";
@Test
+ public void testWtf() {
+ Log.wtf(LOG_TAG, "Message");
+ Log.wtf(LOG_TAG, "Message", new Throwable("Throwable"));
+ Log.wtf(LOG_TAG, new Throwable("Throwable"));
+ }
+
+ @Test
@Ignore
public void testIsLoggable() {
// First clear any SystemProperty setting for our test key.
diff --git a/core/tests/coretests/src/android/widget/RemoteViewsTest.java b/core/tests/coretests/src/android/widget/RemoteViewsTest.java
index 543d73b..5862711 100644
--- a/core/tests/coretests/src/android/widget/RemoteViewsTest.java
+++ b/core/tests/coretests/src/android/widget/RemoteViewsTest.java
@@ -450,13 +450,8 @@
}
private RemoteViews.DrawInstructions getDrawInstructions() {
- final byte[] first = new byte[] {'f', 'i', 'r', 's', 't'};
- final byte[] second = new byte[] {'s', 'e', 'c', 'o', 'n', 'd'};
- final RemoteViews.DrawInstructions drawInstructions =
- new RemoteViews.DrawInstructions.Builder(
- Collections.singletonList(first)).build();
- drawInstructions.appendInstructions(second);
- return drawInstructions;
+ final byte[] bytes = new byte[] {'h', 'e', 'l', 'l', 'o'};
+ return new RemoteViews.DrawInstructions.Builder(Collections.singletonList(bytes)).build();
}
private RemoteViews createViewChained(int depth, String... texts) {
diff --git a/core/tests/utiltests/src/android/util/SlogTest.java b/core/tests/utiltests/src/android/util/SlogTest.java
index 6f761e3..738c668 100644
--- a/core/tests/utiltests/src/android/util/SlogTest.java
+++ b/core/tests/utiltests/src/android/util/SlogTest.java
@@ -44,4 +44,11 @@
Slog.w(TAG, MSG, THROWABLE);
Slog.e(TAG, MSG, THROWABLE);
}
+
+ @Test
+ public void testWtf() {
+ Slog.wtf(TAG, MSG);
+ Slog.wtf(TAG, MSG, THROWABLE);
+ Slog.wtf(TAG, THROWABLE);
+ }
}
diff --git a/data/etc/OWNERS b/data/etc/OWNERS
index ea23aba..245f216 100644
--- a/data/etc/OWNERS
+++ b/data/etc/OWNERS
@@ -1,3 +1,5 @@
+include /PACKAGE_MANAGER_OWNERS
+
alanstokes@google.com
cbrubaker@google.com
hackbod@android.com
@@ -6,11 +8,6 @@
jsharkey@android.com
jsharkey@google.com
lorenzo@google.com
-svetoslavganov@android.com
-svetoslavganov@google.com
-toddke@android.com
-toddke@google.com
-patb@google.com
yamasani@google.com
per-file preinstalled-packages* = file:/MULTIUSER_OWNERS
diff --git a/data/fonts/font_fallback.xml b/data/fonts/font_fallback.xml
index 1bd182f..15ea15a 100644
--- a/data/fonts/font_fallback.xml
+++ b/data/fonts/font_fallback.xml
@@ -11,12 +11,84 @@
effectively add 300 to the weight, this ensures that 900 is the bold
paired with the 500 weight, ensuring adequate contrast.
- TODO(rsheeter) update comment; ordering to match 800 to 900 is no longer required
+
+ The font_fallback.xml defines the list of font used by the system.
+
+ `familyset` node:
+ A `familyset` element must be a root node of the font_fallback.xml. No attributes are allowed
+ to `familyset` node.
+ The `familyset` node can contains `family` and `alias` nodes. Any other nodes will be ignored.
+
+ `family` node:
+ A `family` node defines a single font family definition.
+ A font family is a set of fonts for drawing text in various styles such as weight, slant.
+ There are three types of families, default family, named family and locale fallback family.
+
+ The default family is a special family node appeared the first node of the `familyset` node.
+ The default family is used as first priority fallback.
+ Only `name` attribute can be used for default family node. If the `name` attribute is
+ specified, This family will also works as named family.
+
+ The named family is a family that has name attribute. The named family defines a new fallback.
+ For example, if the name attribute is "serif", it creates serif fallback. Developers can
+ access the fallback by using Typeface#create API.
+ The named family can not have attribute other than `name` attribute. The `name` attribute
+ cannot be empty.
+
+ The locale fallback family is a font family that is used for fallback. The fallback family is
+ used when the named family or default family cannot be used. The locale fallback family can
+ have `lang` attribute and `variant` attribute. The `lang` attribute is an optional comma
+ separated BCP-47i language tag. The `variant` is an optional attribute that can be one one
+ `element`, `compact`. If a `variant` attribute is not specified, it is treated as default.
+
+ `alias` node:
+ An `alias` node defines a alias of named family with changing weight offset. An `alias` node
+ can have mandatory `name` and `to` attribute and optional `weight` attribute. This `alias`
+ defines new fallback that has the name of specified `name` attribute. The fallback list is
+ the same to the fallback that of the name specified with `to` attribute. If `weight` attribute
+ is specified, the base weight offset is shifted to the specified value. For example, if the
+ `weight` is 500, the output text is drawn with 500 of weight.
+
+ `font` node:
+ A `font` node defines a single font definition. There are two types of fonts, static font and
+ variable font.
+
+ A static font can have `weight`, `style`, `index` and `postScriptName` attributes. A `weight`
+ is a mandatory attribute that defines the weight of the font. Any number between 0 to 1000 is
+ valid. A `style` is a mandatory attribute that defines the style of the font. A 'style'
+ attribute can be `normal` or `italic`. An `index` is an optional attribute that defines the
+ index of the font collection. If this is not specified, it is treated as 0. If the font file
+ is not a font collection, this attribute is ignored. A `postScriptName` attribute is an
+ optional attribute. A PostScript name is used for identifying target of system font update.
+ If this is not specified, the system assumes the filename is same to PostScript name of the
+ font file. For example, if the font file is "Roboto-Regular.ttf", the system assume the
+ PostScript name of this font is "Roboto-Regular".
+
+ A variable font can be only defined for the variable font file. A variable font can have
+ `axis` child nodes for specifying axis values. A variable font can have all attribute of
+ static font and can have additional `supportedAxes` attribute. A `supportedAxes` attribute
+ is a comma separated supported axis tags. As of Android V, only `wght` and `ital` axes can
+ be specified.
+
+ If `supportedAxes` attribute is not specified, this `font` node works as static font of the
+ single instance of variable font specified with `axis` children.
+
+ If `supportedAxes` attribute is specified, the system dynamically create font instance for the
+ given weight and style value. If `wght` is specified in `supportedAxes` attribute the `weight`
+ attribute and `axis` child that has `wght` tag become optional and ignored because it is
+ determined by system at runtime. Similarly, if `ital` is specified in `supportedAxes`
+ attribute, the `style` attribute and `axis` child that has `ital` tag become optional and
+ ignored.
+
+ `axis` node:
+ An `axis` node defines a font variation value for a tag. An `axis` node can have two mandatory
+ attributes, `tag` and `value`. If the font is variable font and the same tag `axis` node is
+ specified in `supportedAxes` attribute, the style value works like a default instance.
-->
-<familyset version="23">
+<familyset>
<!-- first font is default -->
- <family name="sans-serif" varFamilyType="2">
- <font>Roboto-Regular.ttf
+ <family name="sans-serif">
+ <font supportedAxes="wght,ital">Roboto-Regular.ttf
<axis tag="wdth" stylevalue="100" />
</font>
</family>
@@ -32,8 +104,8 @@
<alias name="tahoma" to="sans-serif" />
<alias name="verdana" to="sans-serif" />
- <family name="sans-serif-condensed" varFamilyType="2">
- <font>Roboto-Regular.ttf
+ <family name="sans-serif-condensed">
+ <font supportedAxes="wght,ital">Roboto-Regular.ttf
<axis tag="wdth" stylevalue="75" />
</font>
</family>
@@ -72,8 +144,8 @@
<font weight="400" style="normal" postScriptName="ComingSoon-Regular">ComingSoon.ttf</font>
</family>
- <family name="cursive" varFamilyType="1">
- <font>DancingScript-Regular.ttf</font>
+ <family name="cursive">
+ <font supportedAxes="wght">DancingScript-Regular.ttf</font>
</family>
<family name="sans-serif-smallcaps">
@@ -90,8 +162,8 @@
</family>
<alias name="source-sans-pro-semi-bold" to="source-sans-pro" weight="600"/>
- <family name="roboto-flex" varFamilyType="2">
- <font>RobotoFlex-Regular.ttf
+ <family name="roboto-flex">
+ <font supportedAxes="wght">RobotoFlex-Regular.ttf
<axis tag="wdth" stylevalue="100" />
</font>
</family>
@@ -109,11 +181,11 @@
</font>
<font weight="700" style="normal">NotoNaskhArabicUI-Bold.ttf</font>
</family>
- <family lang="und-Ethi" varFamilyType="1">
- <font postScriptName="NotoSansEthiopic-Regular">
+ <family lang="und-Ethi">
+ <font postScriptName="NotoSansEthiopic-Regular" supportedAxes="wght">
NotoSansEthiopic-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifEthiopic-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifEthiopic-Regular" supportedAxes="wght">
NotoSerifEthiopic-VF.ttf
</font>
</family>
@@ -140,32 +212,32 @@
</font>
<font weight="700" style="normal">NotoSansThaiUI-Bold.ttf</font>
</family>
- <family lang="und-Armn" varFamilyType="1">
- <font postScriptName="NotoSansArmenian-Regular">
+ <family lang="und-Armn">
+ <font postScriptName="NotoSansArmenian-Regular" supportedAxes="wght">
NotoSansArmenian-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifArmenian-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifArmenian-Regular" supportedAxes="wght">
NotoSerifArmenian-VF.ttf
</font>
</family>
- <family lang="und-Geor,und-Geok" varFamilyType="1">
- <font postScriptName="NotoSansGeorgian-Regular">
+ <family lang="und-Geor,und-Geok">
+ <font postScriptName="NotoSansGeorgian-Regular" supportedAxes="wght">
NotoSansGeorgian-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifGeorgian-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifGeorgian-Regular" supportedAxes="wght">
NotoSerifGeorgian-VF.ttf
</font>
</family>
- <family lang="und-Deva" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansDevanagari-Regular">
+ <family lang="und-Deva" variant="elegant">
+ <font postScriptName="NotoSansDevanagari-Regular" supportedAxes="wght">
NotoSansDevanagari-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifDevanagari-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifDevanagari-Regular" supportedAxes="wght">
NotoSerifDevanagari-VF.ttf
</font>
</family>
- <family lang="und-Deva" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansDevanagariUI-Regular">
+ <family lang="und-Deva" variant="compact">
+ <font postScriptName="NotoSansDevanagariUI-Regular" supportedAxes="wght">
NotoSansDevanagariUI-VF.ttf
</font>
</family>
@@ -178,21 +250,9 @@
NotoSansGujarati-Regular.ttf
</font>
<font weight="700" style="normal">NotoSansGujarati-Bold.ttf</font>
- <font weight="400" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="400"/>
- </font>
- <font weight="500" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="500"/>
- </font>
- <font weight="600" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="600"/>
- </font>
- <font weight="700" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="700"/>
+ <font style="normal" fallbackFor="serif" postScriptName="NotoSerifGujarati-Regular"
+ supportedAxes="wght">
+ NotoSerifGujarati-VF.ttf
</font>
</family>
<family lang="und-Gujr" variant="compact">
@@ -201,81 +261,81 @@
</font>
<font weight="700" style="normal">NotoSansGujaratiUI-Bold.ttf</font>
</family>
- <family lang="und-Guru" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansGurmukhi-Regular">
+ <family lang="und-Guru" variant="elegant">
+ <font postScriptName="NotoSansGurmukhi-Regular" supportedAxes="wght">
NotoSansGurmukhi-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifGurmukhi-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifGurmukhi-Regular" supportedAxes="wght">
NotoSerifGurmukhi-VF.ttf
</font>
</family>
- <family lang="und-Guru" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansGurmukhiUI-Regular">
+ <family lang="und-Guru" variant="compact">
+ <font postScriptName="NotoSansGurmukhiUI-Regular" supportedAxes="wght">
NotoSansGurmukhiUI-VF.ttf
</font>
</family>
- <family lang="und-Taml" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansTamil-Regular">
+ <family lang="und-Taml" variant="elegant">
+ <font postScriptName="NotoSansTamil-Regular" supportedAxes="wght">
NotoSansTamil-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifTamil-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifTamil-Regular" supportedAxes="wght">
NotoSerifTamil-VF.ttf
</font>
</family>
- <family lang="und-Taml" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansTamilUI-Regular">
+ <family lang="und-Taml" variant="compact">
+ <font postScriptName="NotoSansTamilUI-Regular" supportedAxes="wght">
NotoSansTamilUI-VF.ttf
</font>
</family>
- <family lang="und-Mlym" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansMalayalam-Regular">
+ <family lang="und-Mlym" variant="elegant">
+ <font postScriptName="NotoSansMalayalam-Regular" supportedAxes="wght">
NotoSansMalayalam-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifMalayalam-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifMalayalam-Regular" supportedAxes="wght">
NotoSerifMalayalam-VF.ttf
</font>
</family>
- <family lang="und-Mlym" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansMalayalamUI-Regular">
+ <family lang="und-Mlym" variant="compact">
+ <font postScriptName="NotoSansMalayalamUI-Regular" supportedAxes="wght">
NotoSansMalayalamUI-VF.ttf
</font>
</family>
- <family lang="und-Beng" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansBengali-Regular">
+ <family lang="und-Beng" variant="elegant">
+ <font postScriptName="NotoSansBengali-Regular" supportedAxes="wght">
NotoSansBengali-VF.ttf
</font>
<font fallbackFor="serif" postScriptName="NotoSerifBengali-Regular">
NotoSerifBengali-VF.ttf
</font>
</family>
- <family lang="und-Beng" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansBengaliUI-Regular">
+ <family lang="und-Beng" variant="compact">
+ <font postScriptName="NotoSansBengaliUI-Regular" supportedAxes="wght">
NotoSansBengaliUI-VF.ttf
</font>
</family>
- <family lang="und-Telu" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansTelugu-Regular">
+ <family lang="und-Telu" variant="elegant">
+ <font postScriptName="NotoSansTelugu-Regular" supportedAxes="wght">
NotoSansTelugu-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifTelugu-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifTelugu-Regular" supportedAxes="wght">
NotoSerifTelugu-VF.ttf
</font>
</family>
- <family lang="und-Telu" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansTeluguUI-Regular">
+ <family lang="und-Telu" variant="compact">
+ <font postScriptName="NotoSansTeluguUI-Regular" supportedAxes="wght">
NotoSansTeluguUI-VF.ttf
</font>
</family>
- <family lang="und-Knda" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansKannada-Regular">
+ <family lang="und-Knda" variant="elegant">
+ <font postScriptName="NotoSansKannada-Regular" supportedAxes="wght">
NotoSansKannada-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifKannada-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifKannada-Regular" supportedAxes="wght">
NotoSerifKannada-VF.ttf
</font>
</family>
- <family lang="und-Knda" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansKannadaUI-Regular">
+ <family lang="und-Knda" variant="compact">
+ <font postScriptName="NotoSansKannadaUI-Regular" supportedAxes="wght">
NotoSansKannadaUI-VF.ttf
</font>
</family>
@@ -290,19 +350,20 @@
</font>
<font weight="700" style="normal">NotoSansOriyaUI-Bold.ttf</font>
</family>
- <family lang="und-Sinh" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansSinhala-Regular">
+ <family lang="und-Sinh" variant="elegant">
+ <font postScriptName="NotoSansSinhala-Regular" supportedAxes="wght">
NotoSansSinhala-VF.ttf
</font>
<font fallbackFor="serif" postScriptName="NotoSerifSinhala-Regular">
NotoSerifSinhala-VF.ttf
</font>
</family>
- <family lang="und-Sinh" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansSinhalaUI-Regular">
+ <family lang="und-Sinh" variant="compact">
+ <font postScriptName="NotoSansSinhalaUI-Regular" supportedAxes="wght">
NotoSansSinhalaUI-VF.ttf
</font>
</family>
+ <!-- TODO: NotoSansKhmer uses non-standard wght value, so cannot use auto-adjustment. -->
<family lang="und-Khmr" variant="elegant">
<font weight="100" style="normal" postScriptName="NotoSansKhmer-Regular">
NotoSansKhmer-VF.ttf
@@ -398,8 +459,8 @@
<family lang="und-Ahom">
<font weight="400" style="normal">NotoSansAhom-Regular.otf</font>
</family>
- <family lang="und-Adlm" varFamilyType="1">
- <font postScriptName="NotoSansAdlam-Regular">
+ <family lang="und-Adlm">
+ <font postScriptName="NotoSansAdlam-Regular" supportedAxes="wght">
NotoSansAdlam-VF.ttf
</font>
</family>
@@ -686,8 +747,8 @@
NotoSansTaiViet-Regular.ttf
</font>
</family>
- <family lang="und-Tibt" varFamilyType="1">
- <font postScriptName="NotoSerifTibetan-Regular">
+ <family lang="und-Tibt">
+ <font postScriptName="NotoSerifTibetan-Regular" supportedAxes="wght">
NotoSerifTibetan-VF.ttf
</font>
</family>
@@ -865,27 +926,27 @@
<family lang="und-Dogr">
<font weight="400" style="normal">NotoSerifDogra-Regular.ttf</font>
</family>
- <family lang="und-Medf" varFamilyType="1">
- <font postScriptName="NotoSansMedefaidrin-Regular">
+ <family lang="und-Medf">
+ <font postScriptName="NotoSansMedefaidrin-Regular" supportedAxes="wght">
NotoSansMedefaidrin-VF.ttf
</font>
</family>
- <family lang="und-Soyo" varFamilyType="1">
+ <family lang="und-Soyo" supportedAxes="wght">
<font postScriptName="NotoSansSoyombo-Regular">
NotoSansSoyombo-VF.ttf
</font>
</family>
- <family lang="und-Takr" varFamilyType="1">
+ <family lang="und-Takr" supportedAxes="wght">
<font postScriptName="NotoSansTakri-Regular">
NotoSansTakri-VF.ttf
</font>
</family>
- <family lang="und-Hmnp" varFamilyType="1">
+ <family lang="und-Hmnp" supportedAxes="wght">
<font postScriptName="NotoSerifHmongNyiakeng-Regular">
NotoSerifNyiakengPuachueHmong-VF.ttf
</font>
</family>
- <family lang="und-Yezi" varFamilyType="1">
+ <family lang="und-Yezi" supportedAxes="wght">
<font postScriptName="NotoSerifYezidi-Regular">
NotoSerifYezidi-VF.ttf
</font>
diff --git a/data/fonts/font_fallback_cjkvf.xml b/data/fonts/font_fallback_cjkvf.xml
index 75bc74e..c1ca67e 100644
--- a/data/fonts/font_fallback_cjkvf.xml
+++ b/data/fonts/font_fallback_cjkvf.xml
@@ -11,12 +11,84 @@
effectively add 300 to the weight, this ensures that 900 is the bold
paired with the 500 weight, ensuring adequate contrast.
- TODO(rsheeter) update comment; ordering to match 800 to 900 is no longer required
+
+ The font_fallback.xml defines the list of font used by the system.
+
+ `familyset` node:
+ A `familyset` element must be a root node of the font_fallback.xml. No attributes are allowed
+ to `familyset` node.
+ The `familyset` node can contains `family` and `alias` nodes. Any other nodes will be ignored.
+
+ `family` node:
+ A `family` node defines a single font family definition.
+ A font family is a set of fonts for drawing text in various styles such as weight, slant.
+ There are three types of families, default family, named family and locale fallback family.
+
+ The default family is a special family node appeared the first node of the `familyset` node.
+ The default family is used as first priority fallback.
+ Only `name` attribute can be used for default family node. If the `name` attribute is
+ specified, This family will also works as named family.
+
+ The named family is a family that has name attribute. The named family defines a new fallback.
+ For example, if the name attribute is "serif", it creates serif fallback. Developers can
+ access the fallback by using Typeface#create API.
+ The named family can not have attribute other than `name` attribute. The `name` attribute
+ cannot be empty.
+
+ The locale fallback family is a font family that is used for fallback. The fallback family is
+ used when the named family or default family cannot be used. The locale fallback family can
+ have `lang` attribute and `variant` attribute. The `lang` attribute is an optional comma
+ separated BCP-47i language tag. The `variant` is an optional attribute that can be one one
+ `element`, `compact`. If a `variant` attribute is not specified, it is treated as default.
+
+ `alias` node:
+ An `alias` node defines a alias of named family with changing weight offset. An `alias` node
+ can have mandatory `name` and `to` attribute and optional `weight` attribute. This `alias`
+ defines new fallback that has the name of specified `name` attribute. The fallback list is
+ the same to the fallback that of the name specified with `to` attribute. If `weight` attribute
+ is specified, the base weight offset is shifted to the specified value. For example, if the
+ `weight` is 500, the output text is drawn with 500 of weight.
+
+ `font` node:
+ A `font` node defines a single font definition. There are two types of fonts, static font and
+ variable font.
+
+ A static font can have `weight`, `style`, `index` and `postScriptName` attributes. A `weight`
+ is a mandatory attribute that defines the weight of the font. Any number between 0 to 1000 is
+ valid. A `style` is a mandatory attribute that defines the style of the font. A 'style'
+ attribute can be `normal` or `italic`. An `index` is an optional attribute that defines the
+ index of the font collection. If this is not specified, it is treated as 0. If the font file
+ is not a font collection, this attribute is ignored. A `postScriptName` attribute is an
+ optional attribute. A PostScript name is used for identifying target of system font update.
+ If this is not specified, the system assumes the filename is same to PostScript name of the
+ font file. For example, if the font file is "Roboto-Regular.ttf", the system assume the
+ PostScript name of this font is "Roboto-Regular".
+
+ A variable font can be only defined for the variable font file. A variable font can have
+ `axis` child nodes for specifying axis values. A variable font can have all attribute of
+ static font and can have additional `supportedAxes` attribute. A `supportedAxes` attribute
+ is a comma separated supported axis tags. As of Android V, only `wght` and `ital` axes can
+ be specified.
+
+ If `supportedAxes` attribute is not specified, this `font` node works as static font of the
+ single instance of variable font specified with `axis` children.
+
+ If `supportedAxes` attribute is specified, the system dynamically create font instance for the
+ given weight and style value. If `wght` is specified in `supportedAxes` attribute the `weight`
+ attribute and `axis` child that has `wght` tag become optional and ignored because it is
+ determined by system at runtime. Similarly, if `ital` is specified in `supportedAxes`
+ attribute, the `style` attribute and `axis` child that has `ital` tag become optional and
+ ignored.
+
+ `axis` node:
+ An `axis` node defines a font variation value for a tag. An `axis` node can have two mandatory
+ attributes, `tag` and `value`. If the font is variable font and the same tag `axis` node is
+ specified in `supportedAxes` attribute, the style value works like a default instance.
-->
-<familyset version="23">
+<familyset>
<!-- first font is default -->
- <family name="sans-serif" varFamilyType="2">
- <font>Roboto-Regular.ttf
+ <family name="sans-serif">
+ <font supportedAxes="wght,ital">Roboto-Regular.ttf
<axis tag="wdth" stylevalue="100" />
</font>
</family>
@@ -32,8 +104,8 @@
<alias name="tahoma" to="sans-serif" />
<alias name="verdana" to="sans-serif" />
- <family name="sans-serif-condensed" varFamilyType="2">
- <font>Roboto-Regular.ttf
+ <family name="sans-serif-condensed">
+ <font supportedAxes="wght,ital">Roboto-Regular.ttf
<axis tag="wdth" stylevalue="75" />
</font>
</family>
@@ -72,8 +144,8 @@
<font weight="400" style="normal" postScriptName="ComingSoon-Regular">ComingSoon.ttf</font>
</family>
- <family name="cursive" varFamilyType="1">
- <font>DancingScript-Regular.ttf</font>
+ <family name="cursive">
+ <font supportedAxes="wght">DancingScript-Regular.ttf</font>
</family>
<family name="sans-serif-smallcaps">
@@ -90,8 +162,8 @@
</family>
<alias name="source-sans-pro-semi-bold" to="source-sans-pro" weight="600"/>
- <family name="roboto-flex" varFamilyType="2">
- <font>RobotoFlex-Regular.ttf
+ <family name="roboto-flex">
+ <font supportedAxes="wght">RobotoFlex-Regular.ttf
<axis tag="wdth" stylevalue="100" />
</font>
</family>
@@ -109,11 +181,11 @@
</font>
<font weight="700" style="normal">NotoNaskhArabicUI-Bold.ttf</font>
</family>
- <family lang="und-Ethi" varFamilyType="1">
- <font postScriptName="NotoSansEthiopic-Regular">
+ <family lang="und-Ethi">
+ <font postScriptName="NotoSansEthiopic-Regular" supportedAxes="wght">
NotoSansEthiopic-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifEthiopic-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifEthiopic-Regular" supportedAxes="wght">
NotoSerifEthiopic-VF.ttf
</font>
</family>
@@ -140,32 +212,32 @@
</font>
<font weight="700" style="normal">NotoSansThaiUI-Bold.ttf</font>
</family>
- <family lang="und-Armn" varFamilyType="1">
- <font postScriptName="NotoSansArmenian-Regular">
+ <family lang="und-Armn">
+ <font postScriptName="NotoSansArmenian-Regular" supportedAxes="wght">
NotoSansArmenian-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifArmenian-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifArmenian-Regular" supportedAxes="wght">
NotoSerifArmenian-VF.ttf
</font>
</family>
- <family lang="und-Geor,und-Geok" varFamilyType="1">
- <font postScriptName="NotoSansGeorgian-Regular">
+ <family lang="und-Geor,und-Geok">
+ <font postScriptName="NotoSansGeorgian-Regular" supportedAxes="wght">
NotoSansGeorgian-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifGeorgian-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifGeorgian-Regular" supportedAxes="wght">
NotoSerifGeorgian-VF.ttf
</font>
</family>
- <family lang="und-Deva" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansDevanagari-Regular">
+ <family lang="und-Deva" variant="elegant">
+ <font postScriptName="NotoSansDevanagari-Regular" supportedAxes="wght">
NotoSansDevanagari-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifDevanagari-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifDevanagari-Regular" supportedAxes="wght">
NotoSerifDevanagari-VF.ttf
</font>
</family>
- <family lang="und-Deva" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansDevanagariUI-Regular">
+ <family lang="und-Deva" variant="compact">
+ <font postScriptName="NotoSansDevanagariUI-Regular" supportedAxes="wght">
NotoSansDevanagariUI-VF.ttf
</font>
</family>
@@ -178,21 +250,9 @@
NotoSansGujarati-Regular.ttf
</font>
<font weight="700" style="normal">NotoSansGujarati-Bold.ttf</font>
- <font weight="400" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="400"/>
- </font>
- <font weight="500" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="500"/>
- </font>
- <font weight="600" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="600"/>
- </font>
- <font weight="700" style="normal" fallbackFor="serif"
- postScriptName="NotoSerifGujarati-Regular">NotoSerifGujarati-VF.ttf
- <axis tag="wght" stylevalue="700"/>
+ <font style="normal" fallbackFor="serif" postScriptName="NotoSerifGujarati-Regular"
+ supportedAxes="wght">
+ NotoSerifGujarati-VF.ttf
</font>
</family>
<family lang="und-Gujr" variant="compact">
@@ -201,81 +261,81 @@
</font>
<font weight="700" style="normal">NotoSansGujaratiUI-Bold.ttf</font>
</family>
- <family lang="und-Guru" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansGurmukhi-Regular">
+ <family lang="und-Guru" variant="elegant">
+ <font postScriptName="NotoSansGurmukhi-Regular" supportedAxes="wght">
NotoSansGurmukhi-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifGurmukhi-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifGurmukhi-Regular" supportedAxes="wght">
NotoSerifGurmukhi-VF.ttf
</font>
</family>
- <family lang="und-Guru" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansGurmukhiUI-Regular">
+ <family lang="und-Guru" variant="compact">
+ <font postScriptName="NotoSansGurmukhiUI-Regular" supportedAxes="wght">
NotoSansGurmukhiUI-VF.ttf
</font>
</family>
- <family lang="und-Taml" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansTamil-Regular">
+ <family lang="und-Taml" variant="elegant">
+ <font postScriptName="NotoSansTamil-Regular" supportedAxes="wght">
NotoSansTamil-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifTamil-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifTamil-Regular" supportedAxes="wght">
NotoSerifTamil-VF.ttf
</font>
</family>
- <family lang="und-Taml" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansTamilUI-Regular">
+ <family lang="und-Taml" variant="compact">
+ <font postScriptName="NotoSansTamilUI-Regular" supportedAxes="wght">
NotoSansTamilUI-VF.ttf
</font>
</family>
- <family lang="und-Mlym" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansMalayalam-Regular">
+ <family lang="und-Mlym" variant="elegant">
+ <font postScriptName="NotoSansMalayalam-Regular" supportedAxes="wght">
NotoSansMalayalam-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifMalayalam-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifMalayalam-Regular" supportedAxes="wght">
NotoSerifMalayalam-VF.ttf
</font>
</family>
- <family lang="und-Mlym" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansMalayalamUI-Regular">
+ <family lang="und-Mlym" variant="compact">
+ <font postScriptName="NotoSansMalayalamUI-Regular" supportedAxes="wght">
NotoSansMalayalamUI-VF.ttf
</font>
</family>
- <family lang="und-Beng" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansBengali-Regular">
+ <family lang="und-Beng" variant="elegant">
+ <font postScriptName="NotoSansBengali-Regular" supportedAxes="wght">
NotoSansBengali-VF.ttf
</font>
<font fallbackFor="serif" postScriptName="NotoSerifBengali-Regular">
NotoSerifBengali-VF.ttf
</font>
</family>
- <family lang="und-Beng" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansBengaliUI-Regular">
+ <family lang="und-Beng" variant="compact">
+ <font postScriptName="NotoSansBengaliUI-Regular" supportedAxes="wght">
NotoSansBengaliUI-VF.ttf
</font>
</family>
- <family lang="und-Telu" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansTelugu-Regular">
+ <family lang="und-Telu" variant="elegant">
+ <font postScriptName="NotoSansTelugu-Regular" supportedAxes="wght">
NotoSansTelugu-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifTelugu-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifTelugu-Regular" supportedAxes="wght">
NotoSerifTelugu-VF.ttf
</font>
</family>
- <family lang="und-Telu" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansTeluguUI-Regular">
+ <family lang="und-Telu" variant="compact">
+ <font postScriptName="NotoSansTeluguUI-Regular" supportedAxes="wght">
NotoSansTeluguUI-VF.ttf
</font>
</family>
- <family lang="und-Knda" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansKannada-Regular">
+ <family lang="und-Knda" variant="elegant">
+ <font postScriptName="NotoSansKannada-Regular" supportedAxes="wght">
NotoSansKannada-VF.ttf
</font>
- <font fallbackFor="serif" postScriptName="NotoSerifKannada-Regular">
+ <font fallbackFor="serif" postScriptName="NotoSerifKannada-Regular" supportedAxes="wght">
NotoSerifKannada-VF.ttf
</font>
</family>
- <family lang="und-Knda" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansKannadaUI-Regular">
+ <family lang="und-Knda" variant="compact">
+ <font postScriptName="NotoSansKannadaUI-Regular" supportedAxes="wght">
NotoSansKannadaUI-VF.ttf
</font>
</family>
@@ -290,19 +350,20 @@
</font>
<font weight="700" style="normal">NotoSansOriyaUI-Bold.ttf</font>
</family>
- <family lang="und-Sinh" variant="elegant" varFamilyType="1">
- <font postScriptName="NotoSansSinhala-Regular">
+ <family lang="und-Sinh" variant="elegant">
+ <font postScriptName="NotoSansSinhala-Regular" supportedAxes="wght">
NotoSansSinhala-VF.ttf
</font>
<font fallbackFor="serif" postScriptName="NotoSerifSinhala-Regular">
NotoSerifSinhala-VF.ttf
</font>
</family>
- <family lang="und-Sinh" variant="compact" varFamilyType="1">
- <font postScriptName="NotoSansSinhalaUI-Regular">
+ <family lang="und-Sinh" variant="compact">
+ <font postScriptName="NotoSansSinhalaUI-Regular" supportedAxes="wght">
NotoSansSinhalaUI-VF.ttf
</font>
</family>
+ <!-- TODO: NotoSansKhmer uses non-standard wght value, so cannot use auto-adjustment. -->
<family lang="und-Khmr" variant="elegant">
<font weight="100" style="normal" postScriptName="NotoSansKhmer-Regular">
NotoSansKhmer-VF.ttf
@@ -398,8 +459,8 @@
<family lang="und-Ahom">
<font weight="400" style="normal">NotoSansAhom-Regular.otf</font>
</family>
- <family lang="und-Adlm" varFamilyType="1">
- <font postScriptName="NotoSansAdlam-Regular">
+ <family lang="und-Adlm">
+ <font postScriptName="NotoSansAdlam-Regular" supportedAxes="wght">
NotoSansAdlam-VF.ttf
</font>
</family>
@@ -686,8 +747,8 @@
NotoSansTaiViet-Regular.ttf
</font>
</family>
- <family lang="und-Tibt" varFamilyType="1">
- <font postScriptName="NotoSerifTibetan-Regular">
+ <family lang="und-Tibt">
+ <font postScriptName="NotoSerifTibetan-Regular" supportedAxes="wght">
NotoSerifTibetan-VF.ttf
</font>
</family>
@@ -707,123 +768,36 @@
<font weight="400" style="normal">NotoSansSymbols-Regular-Subsetted.ttf</font>
</family>
<family lang="zh-Hans">
- <font weight="100" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
+ <font weight="400" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin"
+ supportedAxes="wght">
NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="100"/>
- </font>
- <font weight="200" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="200"/>
- </font>
- <font weight="300" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="300"/>
- </font>
- <font weight="400" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="400"/>
- </font>
- <font weight="500" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="500"/>
- </font>
- <font weight="600" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="600"/>
- </font>
- <font weight="700" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="700"/>
- </font>
- <font weight="800" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="800"/>
- </font>
- <font weight="900" style="normal" index="2" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="900"/>
+ <!-- The default instance of NotoSansCJK-Regular.ttc is wght=100, so specify wght=400
+ for making regular style as default. -->
+ <axis tag="wght" stylevalue="400" />
</font>
<font weight="400" style="normal" index="2" fallbackFor="serif"
postScriptName="NotoSerifCJKjp-Regular">NotoSerifCJK-Regular.ttc
</font>
</family>
<family lang="zh-Hant,zh-Bopo">
- <font weight="100" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
+ <font weight="400" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin"
+ supportedAxes="wght">
NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="100"/>
- </font>
- <font weight="200" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="200"/>
- </font>
- <font weight="300" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="300"/>
- </font>
- <font weight="400" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="400"/>
- </font>
- <font weight="500" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="500"/>
- </font>
- <font weight="600" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="600"/>
- </font>
- <font weight="700" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="700"/>
- </font>
- <font weight="800" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="800"/>
- </font>
- <font weight="900" style="normal" index="3" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="900"/>
+ <!-- The default instance of NotoSansCJK-Regular.ttc is wght=100, so specify wght=400
+ for making regular style as default. -->
+ <axis tag="wght" stylevalue="400" />
</font>
<font weight="400" style="normal" index="3" fallbackFor="serif"
postScriptName="NotoSerifCJKjp-Regular">NotoSerifCJK-Regular.ttc
</font>
</family>
<family lang="ja">
- <font weight="100" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
+ <font weight="400" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin"
+ supportedAxes="wght">
NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="100"/>
- </font>
- <font weight="200" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="200"/>
- </font>
- <font weight="300" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="300"/>
- </font>
- <font weight="400" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="400"/>
- </font>
- <font weight="500" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="500"/>
- </font>
- <font weight="600" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="600"/>
- </font>
- <font weight="700" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="700"/>
- </font>
- <font weight="800" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="800"/>
- </font>
- <font weight="900" style="normal" index="0" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="900"/>
+ <!-- The default instance of NotoSansCJK-Regular.ttc is wght=100, so specify wght=400
+ for making regular style as default. -->
+ <axis tag="wght" stylevalue="400" />
</font>
<font weight="400" style="normal" index="0" fallbackFor="serif"
postScriptName="NotoSerifCJKjp-Regular">NotoSerifCJK-Regular.ttc
@@ -840,41 +814,12 @@
</font>
</family>
<family lang="ko">
- <font weight="100" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
+ <font weight="400" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin"
+ supportedAxes="wght">
NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="100"/>
- </font>
- <font weight="200" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="200"/>
- </font>
- <font weight="300" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="300"/>
- </font>
- <font weight="400" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="400"/>
- </font>
- <font weight="500" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="500"/>
- </font>
- <font weight="600" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="600"/>
- </font>
- <font weight="700" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="700"/>
- </font>
- <font weight="800" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="800"/>
- </font>
- <font weight="900" style="normal" index="1" postScriptName="NotoSansCJKjp-Thin">
- NotoSansCJK-Regular.ttc
- <axis tag="wght" stylevalue="900"/>
+ <!-- The default instance of NotoSansCJK-Regular.ttc is wght=100, so specify wght=400
+ for making regular style as default. -->
+ <axis tag="wght" stylevalue="400" />
</font>
<font weight="400" style="normal" index="1" fallbackFor="serif"
postScriptName="NotoSerifCJKjp-Regular">NotoSerifCJK-Regular.ttc
@@ -997,27 +942,27 @@
<family lang="und-Dogr">
<font weight="400" style="normal">NotoSerifDogra-Regular.ttf</font>
</family>
- <family lang="und-Medf" varFamilyType="1">
- <font postScriptName="NotoSansMedefaidrin-Regular">
+ <family lang="und-Medf">
+ <font postScriptName="NotoSansMedefaidrin-Regular" supportedAxes="wght">
NotoSansMedefaidrin-VF.ttf
</font>
</family>
- <family lang="und-Soyo" varFamilyType="1">
+ <family lang="und-Soyo" supportedAxes="wght">
<font postScriptName="NotoSansSoyombo-Regular">
NotoSansSoyombo-VF.ttf
</font>
</family>
- <family lang="und-Takr" varFamilyType="1">
+ <family lang="und-Takr" supportedAxes="wght">
<font postScriptName="NotoSansTakri-Regular">
NotoSansTakri-VF.ttf
</font>
</family>
- <family lang="und-Hmnp" varFamilyType="1">
+ <family lang="und-Hmnp" supportedAxes="wght">
<font postScriptName="NotoSerifHmongNyiakeng-Regular">
NotoSerifNyiakengPuachueHmong-VF.ttf
</font>
</family>
- <family lang="und-Yezi" varFamilyType="1">
+ <family lang="und-Yezi" supportedAxes="wght">
<font postScriptName="NotoSerifYezidi-Regular">
NotoSerifYezidi-VF.ttf
</font>
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index d1aceaf..b33a5d2 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -18,6 +18,7 @@
import android.annotation.ColorInt;
import android.annotation.ColorLong;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
@@ -30,6 +31,8 @@
import android.os.Build;
import android.text.TextShaper;
+import com.android.graphics.hwui.flags.Flags;
+
import dalvik.annotation.optimization.CriticalNative;
import dalvik.annotation.optimization.FastNative;
@@ -766,6 +769,21 @@
}
/**
+ * Preconcat the current matrix with the specified matrix. If the specified
+ * matrix is null, this method does nothing. If the canvas's matrix is changed in the z-axis
+ * through this function, the deprecated {@link #getMatrix()} method will return a 3x3 with
+ * z-axis info stripped away.
+ *
+ * @param m The 4x4 matrix to preconcatenate with the current matrix
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public void concat44(@Nullable Matrix44 m) {
+ if (m != null) {
+ nConcat(mNativeCanvasWrapper, m.mBackingArray);
+ }
+ }
+
+ /**
* Completely replace the current matrix with the specified matrix. If the
* matrix parameter is null, then the current matrix is reset to identity.
*
@@ -1444,6 +1462,8 @@
private static native void nSkew(long canvasHandle, float sx, float sy);
@CriticalNative
private static native void nConcat(long nativeCanvas, long nativeMatrix);
+ @FastNative
+ private static native void nConcat(long nativeCanvas, float[] mat);
@CriticalNative
private static native void nSetMatrix(long nativeCanvas, long nativeMatrix);
@CriticalNative
diff --git a/graphics/java/android/graphics/FontListParser.java b/graphics/java/android/graphics/FontListParser.java
index 52b0b95..17c2dd9 100644
--- a/graphics/java/android/graphics/FontListParser.java
+++ b/graphics/java/android/graphics/FontListParser.java
@@ -16,10 +16,6 @@
package android.graphics;
-import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE;
-import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ITAL;
-import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ONLY;
-import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_TWO_FONTS_WGHT;
import static android.text.FontConfig.NamedFamilyList;
import android.annotation.NonNull;
@@ -32,7 +28,6 @@
import android.os.LocaleList;
import android.text.FontConfig;
import android.util.ArraySet;
-import android.util.Log;
import android.util.Xml;
import org.xmlpull.v1.XmlPullParser;
@@ -65,6 +60,7 @@
private static final String VARIANT_ELEGANT = "elegant";
// XML constants for Font.
+ public static final String ATTR_SUPPORTED_AXES = "supportedAxes";
public static final String ATTR_INDEX = "index";
public static final String ATTR_WEIGHT = "weight";
public static final String ATTR_POSTSCRIPT_NAME = "postScriptName";
@@ -78,6 +74,10 @@
public static final String ATTR_TAG = "tag";
public static final String ATTR_STYLEVALUE = "stylevalue";
+ // The tag string for variable font type resolution.
+ private static final String TAG_WGHT = "wght";
+ private static final String TAG_ITAL = "ital";
+
/* Parse fallback list (no names) */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static FontConfig parse(InputStream in) throws XmlPullParserException, IOException {
@@ -263,7 +263,6 @@
final String lang = parser.getAttributeValue("", "lang");
final String variant = parser.getAttributeValue(null, "variant");
final String ignore = parser.getAttributeValue(null, "ignore");
- final String varFamilyTypeStr = parser.getAttributeValue(null, "varFamilyType");
final List<FontConfig.Font> fonts = new ArrayList<>();
while (keepReading(parser)) {
if (parser.getEventType() != XmlPullParser.START_TAG) continue;
@@ -286,45 +285,12 @@
intVariant = FontConfig.FontFamily.VARIANT_ELEGANT;
}
}
- int varFamilyType = VARIABLE_FONT_FAMILY_TYPE_NONE;
- if (varFamilyTypeStr != null) {
- varFamilyType = Integer.parseInt(varFamilyTypeStr);
- if (varFamilyType <= -1 || varFamilyType > 3) {
- Log.e(TAG, "Error: unexpected varFamilyType value: " + varFamilyTypeStr);
- varFamilyType = VARIABLE_FONT_FAMILY_TYPE_NONE;
- }
-
- // validation but don't read font content for performance reasons.
- switch (varFamilyType) {
- case VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ONLY:
- if (fonts.size() != 1) {
- Log.e(TAG, "Error: Single font support wght axis, but two or more fonts are"
- + " included in the font family.");
- varFamilyType = VARIABLE_FONT_FAMILY_TYPE_NONE;
- }
- break;
- case VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ITAL:
- if (fonts.size() != 1) {
- Log.e(TAG, "Error: Single font support both ital and wght axes, but two or"
- + " more fonts are included in the font family.");
- varFamilyType = VARIABLE_FONT_FAMILY_TYPE_NONE;
- }
- break;
- case VARIABLE_FONT_FAMILY_TYPE_TWO_FONTS_WGHT:
- if (fonts.size() != 2) {
- Log.e(TAG, "Error: two fonts that support wght axis, but one or three or"
- + " more fonts are included in the font family.");
- varFamilyType = VARIABLE_FONT_FAMILY_TYPE_NONE;
- }
- }
- }
boolean skip = (ignore != null && (ignore.equals("true") || ignore.equals("1")));
if (skip || fonts.isEmpty()) {
return null;
}
- return new FontConfig.FontFamily(fonts, LocaleList.forLanguageTags(lang), intVariant,
- varFamilyType);
+ return new FontConfig.FontFamily(fonts, LocaleList.forLanguageTags(lang), intVariant);
}
private static void throwIfAttributeExists(String attrName, XmlPullParser parser) {
@@ -407,6 +373,7 @@
boolean isItalic = STYLE_ITALIC.equals(parser.getAttributeValue(null, ATTR_STYLE));
String fallbackFor = parser.getAttributeValue(null, ATTR_FALLBACK_FOR);
String postScriptName = parser.getAttributeValue(null, ATTR_POSTSCRIPT_NAME);
+ final String supportedAxes = parser.getAttributeValue(null, ATTR_SUPPORTED_AXES);
StringBuilder filename = new StringBuilder();
while (keepReading(parser)) {
if (parser.getEventType() == XmlPullParser.TEXT) {
@@ -422,6 +389,18 @@
}
String sanitizedName = FILENAME_WHITESPACE_PATTERN.matcher(filename).replaceAll("");
+ int varTypeAxes = 0;
+ if (supportedAxes != null) {
+ for (String tag : supportedAxes.split(",")) {
+ String strippedTag = tag.strip();
+ if (strippedTag.equals(TAG_WGHT)) {
+ varTypeAxes |= FontConfig.Font.VAR_TYPE_AXES_WGHT;
+ } else if (strippedTag.equals(TAG_ITAL)) {
+ varTypeAxes |= FontConfig.Font.VAR_TYPE_AXES_ITAL;
+ }
+ }
+ }
+
if (postScriptName == null) {
// If post script name was not provided, assume the file name is same to PostScript
// name.
@@ -462,7 +441,8 @@
),
index,
varSettings,
- fallbackFor);
+ fallbackFor,
+ varTypeAxes);
}
private static String findUpdatedFontFile(String psName,
diff --git a/graphics/java/android/graphics/Matrix44.java b/graphics/java/android/graphics/Matrix44.java
new file mode 100644
index 0000000..7cc0eb7
--- /dev/null
+++ b/graphics/java/android/graphics/Matrix44.java
@@ -0,0 +1,472 @@
+/*
+ * Copyright 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 android.graphics;
+
+import android.annotation.FlaggedApi;
+import android.annotation.NonNull;
+
+import com.android.graphics.hwui.flags.Flags;
+
+import java.util.Arrays;
+
+/**
+ * The Matrix44 class holds a 4x4 matrix for transforming coordinates. It is similar to
+ * {@link Matrix}, and should be used when you want to manipulate the canvas in 3D. Values are kept
+ * in row-major order. The values and operations are treated as column vectors.
+ */
+@FlaggedApi(Flags.FLAG_MATRIX_44)
+public class Matrix44 {
+ final float[] mBackingArray;
+ /**
+ * The default Matrix44 constructor will instantiate an identity matrix.
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public Matrix44() {
+ mBackingArray = new float[]{1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f};
+ }
+
+ /**
+ * Creates and returns a Matrix44 by taking the 3x3 Matrix and placing it on the 0 of the z-axis
+ * by setting row {@code 2} and column {@code 2} to the identity as seen in the following
+ * operation:
+ * <pre class="prettyprint">
+ * [ a b c ] [ a b 0 c ]
+ * [ d e f ] -> [ d e 0 f ]
+ * [ g h i ] [ 0 0 1 0 ]
+ * [ g h 0 i ]
+ * </pre>
+ *
+ * @param mat A 3x3 Matrix to be converted (original Matrix will not be changed)
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public Matrix44(@NonNull Matrix mat) {
+ float[] m = new float[9];
+ mat.getValues(m);
+ mBackingArray = new float[]{m[0], m[1], 0.0f, m[2],
+ m[3], m[4], 0.0f, m[5],
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ m[6], m[7], 0.0f, m[8]};
+ }
+
+ /**
+ * Copies matrix values into the provided array in row-major order.
+ *
+ * @param dst The float array where values will be copied, must be of length 16
+ * @throws IllegalArgumentException if the destination float array is not of length 16
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public void getValues(@NonNull float [] dst) {
+ if (dst.length == 16) {
+ System.arraycopy(mBackingArray, 0, dst, 0, mBackingArray.length);
+ } else {
+ throw new IllegalArgumentException("Dst array must be of length 16");
+ }
+ }
+
+ /**
+ * Replaces the Matrix's values with the values in the provided array.
+ *
+ * @param src A float array of length 16. Floats are treated in row-major order
+ * @throws IllegalArgumentException if the destination float array is not of length 16
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public void setValues(@NonNull float[] src) {
+ if (src.length == 16) {
+ System.arraycopy(src, 0, mBackingArray, 0, mBackingArray.length);
+ } else {
+ throw new IllegalArgumentException("Src array must be of length 16");
+ }
+ }
+
+ /**
+ * Gets the value at the matrix's row and column.
+ *
+ * @param row An integer from 0 to 4 indicating the row of the value to get
+ * @param col An integer from 0 to 4 indicating the column of the value to get
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public float get(int row, int col) {
+ if (row >= 0 && row < 4 && col >= 0 && col < 4) {
+ return mBackingArray[row * 4 + col];
+ }
+ throw new IllegalArgumentException("invalid row and column values");
+ }
+
+ /**
+ * Sets the value at the matrix's row and column to the provided value.
+ *
+ * @param row An integer from 0 to 4 indicating the row of the value to change
+ * @param col An integer from 0 to 4 indicating the column of the value to change
+ * @param val The value the element at the specified index will be set to
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public void set(int row, int col, float val) {
+ if (row >= 0 && row < 4 && col >= 0 && col < 4) {
+ mBackingArray[row * 4 + col] = val;
+ } else {
+ throw new IllegalArgumentException("invalid row and column values");
+ }
+ }
+
+ /**
+ * Sets the Matrix44 to the identity matrix.
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public void reset() {
+ for (int i = 0; i < mBackingArray.length; i++) {
+ mBackingArray[i] = (i % 4 == i / 4) ? 1.0f : 0.0f;
+ }
+ }
+
+ /**
+ * Inverts the Matrix44, then return true if successful, false if unable to invert.
+ *
+ * @return {@code true} on success, {@code false} otherwise
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public boolean invert() {
+ float a00 = mBackingArray[0];
+ float a01 = mBackingArray[1];
+ float a02 = mBackingArray[2];
+ float a03 = mBackingArray[3];
+ float a10 = mBackingArray[4];
+ float a11 = mBackingArray[5];
+ float a12 = mBackingArray[6];
+ float a13 = mBackingArray[7];
+ float a20 = mBackingArray[8];
+ float a21 = mBackingArray[9];
+ float a22 = mBackingArray[10];
+ float a23 = mBackingArray[11];
+ float a30 = mBackingArray[12];
+ float a31 = mBackingArray[13];
+ float a32 = mBackingArray[14];
+ float a33 = mBackingArray[15];
+ float b00 = a00 * a11 - a01 * a10;
+ float b01 = a00 * a12 - a02 * a10;
+ float b02 = a00 * a13 - a03 * a10;
+ float b03 = a01 * a12 - a02 * a11;
+ float b04 = a01 * a13 - a03 * a11;
+ float b05 = a02 * a13 - a03 * a12;
+ float b06 = a20 * a31 - a21 * a30;
+ float b07 = a20 * a32 - a22 * a30;
+ float b08 = a20 * a33 - a23 * a30;
+ float b09 = a21 * a32 - a22 * a31;
+ float b10 = a21 * a33 - a23 * a31;
+ float b11 = a22 * a33 - a23 * a32;
+ float det = (b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06);
+ if (det == 0.0f) {
+ return false;
+ }
+ float invDet = 1.0f / det;
+ mBackingArray[0] = ((a11 * b11 - a12 * b10 + a13 * b09) * invDet);
+ mBackingArray[1] = ((-a01 * b11 + a02 * b10 - a03 * b09) * invDet);
+ mBackingArray[2] = ((a31 * b05 - a32 * b04 + a33 * b03) * invDet);
+ mBackingArray[3] = ((-a21 * b05 + a22 * b04 - a23 * b03) * invDet);
+ mBackingArray[4] = ((-a10 * b11 + a12 * b08 - a13 * b07) * invDet);
+ mBackingArray[5] = ((a00 * b11 - a02 * b08 + a03 * b07) * invDet);
+ mBackingArray[6] = ((-a30 * b05 + a32 * b02 - a33 * b01) * invDet);
+ mBackingArray[7] = ((a20 * b05 - a22 * b02 + a23 * b01) * invDet);
+ mBackingArray[8] = ((a10 * b10 - a11 * b08 + a13 * b06) * invDet);
+ mBackingArray[9] = ((-a00 * b10 + a01 * b08 - a03 * b06) * invDet);
+ mBackingArray[10] = ((a30 * b04 - a31 * b02 + a33 * b00) * invDet);
+ mBackingArray[11] = ((-a20 * b04 + a21 * b02 - a23 * b00) * invDet);
+ mBackingArray[12] = ((-a10 * b09 + a11 * b07 - a12 * b06) * invDet);
+ mBackingArray[13] = ((a00 * b09 - a01 * b07 + a02 * b06) * invDet);
+ mBackingArray[14] = ((-a30 * b03 + a31 * b01 - a32 * b00) * invDet);
+ mBackingArray[15] = ((a20 * b03 - a21 * b01 + a22 * b00) * invDet);
+ return true;
+ }
+
+ /**
+ * Returns true if Matrix44 is equal to identity matrix.
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public boolean isIdentity() {
+ for (int i = 0; i < mBackingArray.length; i++) {
+ float expected = (i % 4 == i / 4) ? 1.0f : 0.0f;
+ if (expected != mBackingArray[i]) return false;
+ }
+ return true;
+ }
+
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ private static float dot(Matrix44 a, Matrix44 b, int row, int col) {
+ return (a.get(row, 0) * b.get(0, col))
+ + (a.get(row, 1) * b.get(1, col))
+ + (a.get(row, 2) * b.get(2, col))
+ + (a.get(row, 3) * b.get(3, col));
+ }
+
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ private static float dot(float r0, float r1, float r2, float r3,
+ float c0, float c1, float c2, float c3) {
+ return (r0 * c0) + (r1 * c1) + (r2 * c2) + (r3 * c3);
+ }
+
+ /**
+ * Multiplies (x, y, z, w) vector by the Matrix44, then returns the new (x, y, z, w). Users
+ * should set {@code w} to 1 to indicate the coordinates are normalized.
+ *
+ * @return An array of length 4 that represents the x, y, z, w (where w is perspective) value
+ * after multiplying x, y, z, 1 by the matrix
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public @NonNull float[] map(float x, float y, float z, float w) {
+ float[] dst = new float[4];
+ this.map(x, y, z, w, dst);
+ return dst;
+ }
+
+ /**
+ * Multiplies (x, y, z, w) vector by the Matrix44, then returns the new (x, y, z, w). Users
+ * should set {@code w} to 1 to indicate the coordinates are normalized.
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public void map(float x, float y, float z, float w, @NonNull float[] dst) {
+ if (dst.length != 4) {
+ throw new IllegalArgumentException("Dst array must be of length 4");
+ }
+ dst[0] = x * mBackingArray[0] + y * mBackingArray[1]
+ + z * mBackingArray[2] + w * mBackingArray[3];
+ dst[1] = x * mBackingArray[4] + y * mBackingArray[5]
+ + z * mBackingArray[6] + w * mBackingArray[7];
+ dst[2] = x * mBackingArray[8] + y * mBackingArray[9]
+ + z * mBackingArray[10] + w * mBackingArray[11];
+ dst[3] = x * mBackingArray[12] + y * mBackingArray[13]
+ + z * mBackingArray[14] + w * mBackingArray[15];
+ }
+
+ /**
+ * Multiplies `this` matrix (A) and provided Matrix (B) in the order of A * B.
+ * The result is saved in `this` Matrix.
+ *
+ * @param b The second Matrix in the concatenation operation
+ * @return A reference to this Matrix, which can be used to chain Matrix operations
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public @NonNull Matrix44 concat(@NonNull Matrix44 b) {
+ float val00 = dot(this, b, 0, 0);
+ float val01 = dot(this, b, 0, 1);
+ float val02 = dot(this, b, 0, 2);
+ float val03 = dot(this, b, 0, 3);
+ float val10 = dot(this, b, 1, 0);
+ float val11 = dot(this, b, 1, 1);
+ float val12 = dot(this, b, 1, 2);
+ float val13 = dot(this, b, 1, 3);
+ float val20 = dot(this, b, 2, 0);
+ float val21 = dot(this, b, 2, 1);
+ float val22 = dot(this, b, 2, 2);
+ float val23 = dot(this, b, 2, 3);
+ float val30 = dot(this, b, 3, 0);
+ float val31 = dot(this, b, 3, 1);
+ float val32 = dot(this, b, 3, 2);
+ float val33 = dot(this, b, 3, 3);
+
+ mBackingArray[0] = val00;
+ mBackingArray[1] = val01;
+ mBackingArray[2] = val02;
+ mBackingArray[3] = val03;
+ mBackingArray[4] = val10;
+ mBackingArray[5] = val11;
+ mBackingArray[6] = val12;
+ mBackingArray[7] = val13;
+ mBackingArray[8] = val20;
+ mBackingArray[9] = val21;
+ mBackingArray[10] = val22;
+ mBackingArray[11] = val23;
+ mBackingArray[12] = val30;
+ mBackingArray[13] = val31;
+ mBackingArray[14] = val32;
+ mBackingArray[15] = val33;
+
+ return this;
+ }
+
+ /**
+ * Applies a rotation around a given axis, then returns self.
+ * {@code x}, {@code y}, {@code z} represent the axis by which to rotate around.
+ * For example, pass in {@code 1, 0, 0} to rotate around the x-axis.
+ * The axis provided will be normalized.
+ *
+ * @param deg Amount in degrees to rotate the matrix about the x-axis
+ * @param xComp X component of the rotation axis
+ * @param yComp Y component of the rotation axis
+ * @param zComp Z component of the rotation axis
+ * @return A reference to this Matrix, which can be used to chain Matrix operations
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public @NonNull Matrix44 rotate(float deg, float xComp, float yComp, float zComp) {
+ float sum = xComp + yComp + zComp;
+ float x = xComp / sum;
+ float y = yComp / sum;
+ float z = zComp / sum;
+
+ float c = (float) Math.cos(deg * Math.PI / 180.0f);
+ float s = (float) Math.sin(deg * Math.PI / 180.0f);
+ float t = 1 - c;
+
+ float rotVals00 = t * x * x + c;
+ float rotVals01 = t * x * y - s * z;
+ float rotVals02 = t * x * z + s * y;
+ float rotVals10 = t * x * y + s * z;
+ float rotVals11 = t * y * y + c;
+ float rotVals12 = t * y * z - s * x;
+ float rotVals20 = t * x * z - s * y;
+ float rotVals21 = t * y * z + s * x;
+ float rotVals22 = t * z * z + c;
+
+ float v00 = dot(mBackingArray[0], mBackingArray[1], mBackingArray[2], mBackingArray[3],
+ rotVals00, rotVals10, rotVals20, 0);
+ float v01 = dot(mBackingArray[0], mBackingArray[1], mBackingArray[2], mBackingArray[3],
+ rotVals01, rotVals11, rotVals21, 0);
+ float v02 = dot(mBackingArray[0], mBackingArray[1], mBackingArray[2], mBackingArray[3],
+ rotVals02, rotVals12, rotVals22, 0);
+ float v03 = dot(mBackingArray[0], mBackingArray[1], mBackingArray[2], mBackingArray[3],
+ 0, 0, 0, 1);
+ float v10 = dot(mBackingArray[4], mBackingArray[5], mBackingArray[6], mBackingArray[7],
+ rotVals00, rotVals10, rotVals20, 0);
+ float v11 = dot(mBackingArray[4], mBackingArray[5], mBackingArray[6], mBackingArray[7],
+ rotVals01, rotVals11, rotVals21, 0);
+ float v12 = dot(mBackingArray[4], mBackingArray[5], mBackingArray[6], mBackingArray[7],
+ rotVals02, rotVals12, rotVals22, 0);
+ float v13 = dot(mBackingArray[4], mBackingArray[5], mBackingArray[6], mBackingArray[7],
+ 0, 0, 0, 1);
+ float v20 = dot(mBackingArray[8], mBackingArray[9], mBackingArray[10], mBackingArray[11],
+ rotVals00, rotVals10, rotVals20, 0);
+ float v21 = dot(mBackingArray[8], mBackingArray[9], mBackingArray[10], mBackingArray[11],
+ rotVals01, rotVals11, rotVals21, 0);
+ float v22 = dot(mBackingArray[8], mBackingArray[9], mBackingArray[10], mBackingArray[11],
+ rotVals02, rotVals12, rotVals22, 0);
+ float v23 = dot(mBackingArray[8], mBackingArray[9], mBackingArray[10], mBackingArray[11],
+ 0, 0, 0, 1);
+ float v30 = dot(mBackingArray[12], mBackingArray[13], mBackingArray[14], mBackingArray[15],
+ rotVals00, rotVals10, rotVals20, 0);
+ float v31 = dot(mBackingArray[12], mBackingArray[13], mBackingArray[14], mBackingArray[15],
+ rotVals01, rotVals11, rotVals21, 0);
+ float v32 = dot(mBackingArray[12], mBackingArray[13], mBackingArray[14], mBackingArray[15],
+ rotVals02, rotVals12, rotVals22, 0);
+ float v33 = dot(mBackingArray[12], mBackingArray[13], mBackingArray[14], mBackingArray[15],
+ 0, 0, 0, 1);
+
+ mBackingArray[0] = v00;
+ mBackingArray[1] = v01;
+ mBackingArray[2] = v02;
+ mBackingArray[3] = v03;
+ mBackingArray[4] = v10;
+ mBackingArray[5] = v11;
+ mBackingArray[6] = v12;
+ mBackingArray[7] = v13;
+ mBackingArray[8] = v20;
+ mBackingArray[9] = v21;
+ mBackingArray[10] = v22;
+ mBackingArray[11] = v23;
+ mBackingArray[12] = v30;
+ mBackingArray[13] = v31;
+ mBackingArray[14] = v32;
+ mBackingArray[15] = v33;
+
+ return this;
+ }
+
+ /**
+ * Applies scaling factors to `this` Matrix44, then returns self. Pass 1s for no change.
+ *
+ * @param x Scaling factor for the x-axis
+ * @param y Scaling factor for the y-axis
+ * @param z Scaling factor for the z-axis
+ * @return A reference to this Matrix, which can be used to chain Matrix operations
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public @NonNull Matrix44 scale(float x, float y, float z) {
+ mBackingArray[0] *= x;
+ mBackingArray[4] *= x;
+ mBackingArray[8] *= x;
+ mBackingArray[12] *= x;
+ mBackingArray[1] *= y;
+ mBackingArray[5] *= y;
+ mBackingArray[9] *= y;
+ mBackingArray[13] *= y;
+ mBackingArray[2] *= z;
+ mBackingArray[6] *= z;
+ mBackingArray[10] *= z;
+ mBackingArray[14] *= z;
+
+ return this;
+ }
+
+ /**
+ * Applies a translation to `this` Matrix44, then returns self.
+ *
+ * @param x Translation for the x-axis
+ * @param y Translation for the y-axis
+ * @param z Translation for the z-axis
+ * @return A reference to this Matrix, which can be used to chain Matrix operations
+ */
+ @FlaggedApi(Flags.FLAG_MATRIX_44)
+ public @NonNull Matrix44 translate(float x, float y, float z) {
+ float newX = x * mBackingArray[0] + y * mBackingArray[1]
+ + z * mBackingArray[2] + mBackingArray[3];
+ float newY = x * mBackingArray[4] + y * mBackingArray[5]
+ + z * mBackingArray[6] + mBackingArray[7];
+ float newZ = x * mBackingArray[8] + y * mBackingArray[9]
+ + z * mBackingArray[10] + mBackingArray[11];
+ float newW = x * mBackingArray[12] + y * mBackingArray[13]
+ + z * mBackingArray[14] + mBackingArray[15];
+
+ mBackingArray[3] = newX;
+ mBackingArray[7] = newY;
+ mBackingArray[11] = newZ;
+ mBackingArray[15] = newW;
+
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("""
+ | %f %f %f %f |
+ | %f %f %f %f |
+ | %f %f %f %f |
+ | %f %f %f %f |
+ """, mBackingArray[0], mBackingArray[1], mBackingArray[2], mBackingArray[3],
+ mBackingArray[4], mBackingArray[5], mBackingArray[6], mBackingArray[7],
+ mBackingArray[8], mBackingArray[9], mBackingArray[10], mBackingArray[11],
+ mBackingArray[12], mBackingArray[13], mBackingArray[14], mBackingArray[15]);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Matrix44) {
+ return Arrays.equals(mBackingArray, ((Matrix44) obj).mBackingArray);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) mBackingArray[0] + (int) mBackingArray[1] + (int) mBackingArray[2]
+ + (int) mBackingArray[3] + (int) mBackingArray[4] + (int) mBackingArray[5]
+ + (int) mBackingArray[6] + (int) mBackingArray[7] + (int) mBackingArray[8]
+ + (int) mBackingArray[9] + (int) mBackingArray[10] + (int) mBackingArray[11]
+ + (int) mBackingArray[12] + (int) mBackingArray[13] + (int) mBackingArray[14]
+ + (int) mBackingArray[15];
+ }
+
+}
diff --git a/graphics/java/android/graphics/fonts/SystemFonts.java b/graphics/java/android/graphics/fonts/SystemFonts.java
index 3ef714ed..a90961e 100644
--- a/graphics/java/android/graphics/fonts/SystemFonts.java
+++ b/graphics/java/android/graphics/fonts/SystemFonts.java
@@ -100,6 +100,71 @@
}
}
+ /** @hide */
+ @VisibleForTesting
+ public static @FontFamily.Builder.VariableFontFamilyType int resolveVarFamilyType(
+ @NonNull FontConfig.FontFamily xmlFamily,
+ @Nullable String familyName) {
+ int wghtCount = 0;
+ int italCount = 0;
+ int targetFonts = 0;
+ boolean hasItalicFont = false;
+
+ List<FontConfig.Font> fonts = xmlFamily.getFontList();
+ for (int i = 0; i < fonts.size(); ++i) {
+ FontConfig.Font font = fonts.get(i);
+
+ if (familyName == null) { // for default family
+ if (font.getFontFamilyName() != null) {
+ continue; // this font is not for the default family.
+ }
+ } else { // for the specific family
+ if (!familyName.equals(font.getFontFamilyName())) {
+ continue; // this font is not for given family.
+ }
+ }
+
+ final int varTypeAxes = font.getVarTypeAxes();
+ if (varTypeAxes == 0) {
+ // If we see static font, we can immediately return as VAR_TYPE_NONE.
+ return FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE;
+ }
+
+ if ((varTypeAxes & FontConfig.Font.VAR_TYPE_AXES_WGHT) != 0) {
+ wghtCount++;
+ }
+
+ if ((varTypeAxes & FontConfig.Font.VAR_TYPE_AXES_ITAL) != 0) {
+ italCount++;
+ }
+
+ if (font.getStyle().getSlant() == FontStyle.FONT_SLANT_ITALIC) {
+ hasItalicFont = true;
+ }
+ targetFonts++;
+ }
+
+ if (italCount == 0) { // No ital font.
+ if (targetFonts == 1 && wghtCount == 1) {
+ // If there is only single font that has wght, use it for regular style and
+ // use synthetic bolding for italic.
+ return FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ONLY;
+ } else if (targetFonts == 2 && wghtCount == 2 && hasItalicFont) {
+ // If there are two fonts and italic font is available, use them for regular and
+ // italic separately. (It is impossible to have two italic fonts. It will end up
+ // with Typeface creation failure.)
+ return FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_TWO_FONTS_WGHT;
+ }
+ } else if (italCount == 1) {
+ // If ital font is included, a single font should support both wght and ital.
+ if (wghtCount == 1 && targetFonts == 1) {
+ return FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_SINGLE_FONT_WGHT_ITAL;
+ }
+ }
+ // Otherwise, unsupported.
+ return FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE;
+ }
+
private static void pushFamilyToFallback(@NonNull FontConfig.FontFamily xmlFamily,
@NonNull ArrayMap<String, NativeFamilyListSet> fallbackMap,
@NonNull Map<String, ByteBuffer> cache) {
@@ -126,7 +191,7 @@
}
final FontFamily defaultFamily = defaultFonts.isEmpty() ? null : createFontFamily(
- defaultFonts, languageTags, variant, xmlFamily.getVariableFontFamilyType(), false,
+ defaultFonts, languageTags, variant, resolveVarFamilyType(xmlFamily, null), false,
cache);
// Insert family into fallback map.
for (int i = 0; i < fallbackMap.size(); i++) {
@@ -145,7 +210,7 @@
}
} else {
final FontFamily family = createFontFamily(fallback, languageTags, variant,
- xmlFamily.getVariableFontFamilyType(), false, cache);
+ resolveVarFamilyType(xmlFamily, name), false, cache);
if (family != null) {
familyListSet.familyList.add(family);
} else if (defaultFamily != null) {
@@ -217,7 +282,8 @@
final FontFamily family = createFontFamily(
xmlFamily.getFontList(),
xmlFamily.getLocaleList().toLanguageTags(), xmlFamily.getVariant(),
- xmlFamily.getVariableFontFamilyType(),
+ resolveVarFamilyType(xmlFamily,
+ null /* all fonts under named family should be treated as default */),
true, // named family is always default
bufferCache);
if (family == null) {
diff --git a/libs/WindowManager/Shell/Android.bp b/libs/WindowManager/Shell/Android.bp
index 4cdc06a..a12fa5f 100644
--- a/libs/WindowManager/Shell/Android.bp
+++ b/libs/WindowManager/Shell/Android.bp
@@ -39,6 +39,7 @@
}
// Sources that have no dependencies that can be used directly downstream of this library
+// TODO(b/322791067): move these sources to WindowManager-Shell-shared
filegroup {
name: "wm_shell_util-sources",
srcs: [
@@ -137,6 +138,12 @@
},
}
+java_library {
+ name: "WindowManager-Shell-shared",
+
+ srcs: ["shared/**/*.java"],
+}
+
android_library {
name: "WindowManager-Shell",
srcs: [
@@ -162,6 +169,7 @@
"com_android_wm_shell_flags_lib",
"com.android.window.flags.window-aconfig-java",
"WindowManager-Shell-proto",
+ "WindowManager-Shell-shared",
"perfetto_trace_java_protos",
"dagger2",
"jsr330",
diff --git a/libs/WindowManager/Shell/aconfig/multitasking.aconfig b/libs/WindowManager/Shell/aconfig/multitasking.aconfig
index 1cc8a8f..2b95f30 100644
--- a/libs/WindowManager/Shell/aconfig/multitasking.aconfig
+++ b/libs/WindowManager/Shell/aconfig/multitasking.aconfig
@@ -50,3 +50,10 @@
description: "Enables new animations for expand and collapse for bubbles"
bug: "311450609"
}
+
+flag {
+ name: "enable_pip_umo_experience"
+ namespace: "multitasking"
+ description: "Enables new UMO experience for PiP menu"
+ bug: "307998712"
+}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/util/CounterRotator.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/CounterRotator.java
similarity index 98%
rename from libs/WindowManager/Shell/src/com/android/wm/shell/util/CounterRotator.java
rename to libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/CounterRotator.java
index 7e95814..fd3a749 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/util/CounterRotator.java
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/CounterRotator.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.wm.shell.util;
+package com.android.wm.shell.shared;
import android.graphics.Point;
import android.util.RotationUtils;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/TransitionUtil.java
similarity index 98%
rename from libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java
rename to libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/TransitionUtil.java
index 936faa3..dcd4062 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/TransitionUtil.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.wm.shell.util;
+package com.android.wm.shell.shared;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.view.RemoteAnimationTarget.MODE_CHANGING;
@@ -28,14 +28,13 @@
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
+import static android.window.TransitionInfo.FLAG_FIRST_CUSTOM;
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP;
import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
-import static com.android.wm.shell.common.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR;
-
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
@@ -53,6 +52,8 @@
/** Various utility functions for transitions. */
public class TransitionUtil {
+ /** Flag applied to a transition change to identify it as a divider bar for animation. */
+ public static final int FLAG_IS_DIVIDER_BAR = FLAG_FIRST_CUSTOM;
/** @return true if the transition was triggered by opening something vs closing something */
public static boolean isOpeningType(@WindowManager.TransitionType int type) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java
index 8241e1a..8d30db6 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationAdapter.java
@@ -29,7 +29,7 @@
import androidx.annotation.NonNull;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
/**
* Wrapper to handle the ActivityEmbedding animation update in one
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java
index 44ee561..539832e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationRunner.java
@@ -46,7 +46,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.wm.shell.activityembedding.ActivityEmbeddingAnimationAdapter.SnapshotAdapter;
import com.android.wm.shell.common.ScreenshotUtils;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
import java.util.ArrayList;
import java.util.List;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
index efa5a1a..0272f1c 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingAnimationSpec.java
@@ -38,7 +38,7 @@
import android.window.TransitionInfo;
import com.android.internal.policy.TransitionAnimation;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
/** Animation spec for ActivityEmbedding transition. */
// TODO(b/206557124): provide an easier way to customize animation
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java
index b4e852c..1f9358e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/activityembedding/ActivityEmbeddingController.java
@@ -38,9 +38,9 @@
import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.List;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index 1a6bf28..aea3ca1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -1276,9 +1276,17 @@
mBubbleData.setExpanded(true);
}
} else {
- // App bubble does not exist, lets add and expand it
- Log.i(TAG, " showOrHideAppBubble, creating and expanding app bubble");
- Bubble b = Bubble.createAppBubble(intent, user, icon, mMainExecutor);
+ // Check if it exists in the overflow
+ Bubble b = mBubbleData.getOverflowBubbleWithKey(appBubbleKey);
+ if (b != null) {
+ // It's in the overflow, so remove it & reinflate
+ Log.i(TAG, " showOrHideAppBubble, expanding app bubble from overflow");
+ mBubbleData.removeOverflowBubble(b);
+ } else {
+ // App bubble does not exist, lets add and expand it
+ Log.i(TAG, " showOrHideAppBubble, creating and expanding app bubble");
+ b = Bubble.createAppBubble(intent, user, icon, mMainExecutor);
+ }
b.setShouldAutoExpand(true);
inflateAndAdd(b, /* suppressFlyout= */ true, /* showInShade= */ false);
}
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 6e0c804..127c7e8 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
@@ -491,6 +491,19 @@
}
/**
+ * Explicitly removes a bubble from the overflow, if it exists.
+ *
+ * @param bubble the bubble to remove.
+ */
+ public void removeOverflowBubble(Bubble bubble) {
+ if (bubble == null) return;
+ if (mOverflowBubbles.remove(bubble)) {
+ mStateChange.removedOverflowBubble = bubble;
+ dispatchPendingChanges();
+ }
+ }
+
+ /**
* Adds a group key indicating that the summary for this group should be suppressed.
*
* @param groupKey the group key of the group whose summary should be suppressed.
@@ -1145,7 +1158,6 @@
return null;
}
- @VisibleForTesting(visibility = PRIVATE)
public Bubble getOverflowBubbleWithKey(String key) {
for (int i = 0; i < mOverflowBubbles.size(); i++) {
Bubble bubble = mOverflowBubbles.get(i);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblesTransitionObserver.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblesTransitionObserver.java
index 9e8a385..c1f704a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblesTransitionObserver.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblesTransitionObserver.java
@@ -24,8 +24,8 @@
import androidx.annotation.NonNull;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.TransitionUtil;
/**
* Observer used to identify tasks that are opening or moving to front. If a bubble activity is
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java
index 49db8d9..e8c809e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java
@@ -20,10 +20,11 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
-import static android.window.TransitionInfo.FLAG_FIRST_CUSTOM;
import android.annotation.IntDef;
+import com.android.wm.shell.shared.TransitionUtil;
+
/** Helper utility class of methods and constants that are available to be imported in Launcher. */
public class SplitScreenConstants {
/** Duration used for every split fade-in or fade-out. */
@@ -126,7 +127,7 @@
WINDOWING_MODE_FREEFORM};
/** Flag applied to a transition change to identify it as a divider bar for animation. */
- public static final int FLAG_IS_DIVIDER_BAR = FLAG_FIRST_CUSTOM;
+ public static final int FLAG_IS_DIVIDER_BAR = TransitionUtil.FLAG_IS_DIVIDER_BAR;
public static final String splitPositionToString(@SplitPosition int pos) {
switch (pos) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
index 731fec7..39610e3 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DragToDesktopTransitionHandler.kt
@@ -26,6 +26,7 @@
import android.window.WindowContainerTransaction
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.protolog.ShellProtoLogGroup
+import com.android.wm.shell.shared.TransitionUtil
import com.android.wm.shell.splitscreen.SplitScreenController
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.transition.Transitions.TRANSIT_DESKTOP_MODE_CANCEL_DRAG_TO_DESKTOP
@@ -33,7 +34,6 @@
import com.android.wm.shell.transition.Transitions.TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP
import com.android.wm.shell.transition.Transitions.TransitionHandler
import com.android.wm.shell.util.KtProtoLog
-import com.android.wm.shell.util.TransitionUtil
import com.android.wm.shell.windowdecor.DesktopModeWindowDecoration
import com.android.wm.shell.windowdecor.MoveToDesktopAnimator
import com.android.wm.shell.windowdecor.MoveToDesktopAnimator.Companion.DRAG_FREEFORM_SCALE
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 e63bbc0..73de231 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
@@ -27,7 +27,7 @@
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_UNOCCLUDING;
import static android.view.WindowManager.TRANSIT_SLEEP;
-import static com.android.wm.shell.util.TransitionUtil.isOpeningType;
+import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;
import android.annotation.NonNull;
import android.annotation.Nullable;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
index e739266..896ca96 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
@@ -71,11 +71,11 @@
import com.android.wm.shell.common.pip.PipMenuController;
import com.android.wm.shell.common.pip.PipUtils;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.CounterRotatorHelper;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.TransitionUtil;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipTransition.java
index d16a692..c2f4d72a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipTransition.java
@@ -71,9 +71,9 @@
import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip.PipTransitionState;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
import java.util.List;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
index 1232baa..97d3457 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
@@ -58,10 +58,10 @@
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.HomeTransitionObserver;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
import java.util.function.Consumer;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java
index 5de8a9b..e8894a83 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java
@@ -48,9 +48,9 @@
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.common.split.SplitDecorManager;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.transition.OneShotRemoteHandler;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
index af05aa2..e5045ae 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
@@ -44,6 +44,8 @@
import static com.android.wm.shell.common.split.SplitScreenConstants.splitPositionToString;
import static com.android.wm.shell.common.split.SplitScreenUtils.reverseSplitPosition;
import static com.android.wm.shell.common.split.SplitScreenUtils.splitFailureMessage;
+import static com.android.wm.shell.shared.TransitionUtil.isClosingType;
+import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_MAIN;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_SIDE;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_UNDEFINED;
@@ -64,8 +66,6 @@
import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS;
import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE;
import static com.android.wm.shell.transition.Transitions.TRANSIT_SPLIT_SCREEN_PAIR_OPEN;
-import static com.android.wm.shell.util.TransitionUtil.isClosingType;
-import static com.android.wm.shell.util.TransitionUtil.isOpeningType;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -135,13 +135,13 @@
import com.android.wm.shell.common.split.SplitWindowManager;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.recents.RecentTasksController;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.splitscreen.SplitScreen.StageType;
import com.android.wm.shell.splitscreen.SplitScreenController.ExitReason;
import com.android.wm.shell.transition.DefaultMixedHandler;
import com.android.wm.shell.transition.LegacyTransitions;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.util.SplitBounds;
-import com.android.wm.shell.util.TransitionUtil;
import com.android.wm.shell.windowdecor.WindowDecorViewModel;
import dalvik.annotation.optimization.NeverCompile;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java
index 84f21f6..198ec82 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/taskview/TaskViewTransitions.java
@@ -37,8 +37,8 @@
import androidx.annotation.VisibleForTesting;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
import java.util.Objects;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/CounterRotatorHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/CounterRotatorHelper.java
index 628ce27..b03daaa 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/CounterRotatorHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/CounterRotatorHelper.java
@@ -27,8 +27,8 @@
import androidx.annotation.NonNull;
-import com.android.wm.shell.util.CounterRotator;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.CounterRotator;
+import com.android.wm.shell.shared.TransitionUtil;
import java.util.List;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java
index 8c2203e..8746b8c 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java
@@ -24,7 +24,7 @@
import static android.view.WindowManager.TRANSIT_PIP;
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
-import static com.android.wm.shell.util.TransitionUtil.isOpeningType;
+import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -48,11 +48,11 @@
import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.recents.RecentsTransitionHandler;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.splitscreen.StageCoordinator;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.unfold.UnfoldTransitionHandler;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
import java.util.Map;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
index 193a4fb..c70a821 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultTransitionHandler.java
@@ -109,8 +109,8 @@
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.sysui.ShellInit;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
import java.util.List;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/HomeTransitionObserver.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/HomeTransitionObserver.java
index af31f5f..cb2944c 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/HomeTransitionObserver.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/HomeTransitionObserver.java
@@ -32,7 +32,7 @@
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SingleInstanceRemoteListener;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
/**
* The {@link TransitionObserver} that observes for transitions involving the home
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java
index 293b660..4c4c580 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java
@@ -39,7 +39,7 @@
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
import java.util.ArrayList;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java
index b012d35..1be85d0 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/TransitionAnimationHelper.java
@@ -56,7 +56,7 @@
import com.android.internal.policy.TransitionAnimation;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
/** The helper class that provides methods for adding styles to transition animations. */
public class TransitionAnimationHelper {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
index 67fc7e2..5e79681 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
@@ -37,9 +37,9 @@
import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTaskPermission;
+import static com.android.wm.shell.shared.TransitionUtil.isClosingType;
+import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_SHELL_TRANSITIONS;
-import static com.android.wm.shell.util.TransitionUtil.isClosingType;
-import static com.android.wm.shell.util.TransitionUtil.isOpeningType;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -80,13 +80,13 @@
import com.android.wm.shell.common.annotations.ExternalThread;
import com.android.wm.shell.keyguard.KeyguardTransitionHandler;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.sysui.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.tracing.LegacyTransitionTracer;
import com.android.wm.shell.transition.tracing.PerfettoTransitionTracer;
import com.android.wm.shell.transition.tracing.TransitionTracer;
-import com.android.wm.shell.util.TransitionUtil;
import java.io.PrintWriter;
import java.util.ArrayList;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/UnfoldTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/UnfoldTransitionHandler.java
index 98d343b..c26604a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/UnfoldTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/unfold/UnfoldTransitionHandler.java
@@ -35,6 +35,7 @@
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.common.TransactionPool;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.transition.Transitions.TransitionFinishCallback;
@@ -43,7 +44,6 @@
import com.android.wm.shell.unfold.animation.FullscreenUnfoldTaskAnimator;
import com.android.wm.shell.unfold.animation.SplitTaskUnfoldAnimator;
import com.android.wm.shell.unfold.animation.UnfoldTaskAnimator;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
import java.util.List;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataTest.java
index dab762f..fa0aba5 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleDataTest.java
@@ -1190,6 +1190,23 @@
assertThat(mBubbleData.getBubbleInStackWithKey(appBubbleKey)).isNull();
}
+ @Test
+ public void test_removeOverflowBubble() {
+ sendUpdatedEntryAtTime(mEntryA1, 2000);
+ mBubbleData.setListener(mListener);
+
+ mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_USER_GESTURE);
+ verifyUpdateReceived();
+ assertOverflowChangedTo(ImmutableList.of(mBubbleA1));
+
+ mBubbleData.removeOverflowBubble(mBubbleA1);
+ verifyUpdateReceived();
+
+ BubbleData.Update update = mUpdateCaptor.getValue();
+ assertThat(update.removedOverflowBubble).isEqualTo(mBubbleA1);
+ assertOverflowChangedTo(ImmutableList.of());
+ }
+
private void verifyUpdateReceived() {
verify(mListener).applyUpdate(mUpdateCaptor.capture());
reset(mListener);
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 008ea3a..14b8d8d 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -341,6 +341,10 @@
mCanvas->concat(matrix);
}
+void SkiaCanvas::concat(const SkM44& matrix) {
+ mCanvas->concat(matrix);
+}
+
void SkiaCanvas::rotate(float degrees) {
mCanvas->rotate(degrees);
}
diff --git a/libs/hwui/SkiaCanvas.h b/libs/hwui/SkiaCanvas.h
index 4bf1790..5e3553b 100644
--- a/libs/hwui/SkiaCanvas.h
+++ b/libs/hwui/SkiaCanvas.h
@@ -86,6 +86,7 @@
virtual void getMatrix(SkMatrix* outMatrix) const override;
virtual void setMatrix(const SkMatrix& matrix) override;
virtual void concat(const SkMatrix& matrix) override;
+ virtual void concat(const SkM44& matrix) override;
virtual void rotate(float degrees) override;
virtual void scale(float sx, float sy) override;
virtual void skew(float sx, float sy) override;
diff --git a/libs/hwui/hwui/Canvas.h b/libs/hwui/hwui/Canvas.h
index 9ec023b..20e3ad2 100644
--- a/libs/hwui/hwui/Canvas.h
+++ b/libs/hwui/hwui/Canvas.h
@@ -175,6 +175,7 @@
virtual void setMatrix(const SkMatrix& matrix) = 0;
virtual void concat(const SkMatrix& matrix) = 0;
+ virtual void concat(const SkM44& matrix) = 0;
virtual void rotate(float degrees) = 0;
virtual void scale(float sx, float sy) = 0;
virtual void skew(float sx, float sy) = 0;
diff --git a/libs/hwui/jni/android_graphics_Canvas.cpp b/libs/hwui/jni/android_graphics_Canvas.cpp
index d572593..295f4dc 100644
--- a/libs/hwui/jni/android_graphics_Canvas.cpp
+++ b/libs/hwui/jni/android_graphics_Canvas.cpp
@@ -158,6 +158,13 @@
get_canvas(canvasHandle)->concat(*matrix);
}
+static void concat44(JNIEnv* env, jobject obj, jlong canvasHandle, jfloatArray arr) {
+ jfloat* matVals = env->GetFloatArrayElements(arr, 0);
+ const SkM44 matrix = SkM44::RowMajor(matVals);
+ get_canvas(canvasHandle)->concat(matrix);
+ env->ReleaseFloatArrayElements(arr, matVals, 0);
+}
+
static void rotate(CRITICAL_JNI_PARAMS_COMMA jlong canvasHandle, jfloat degrees) {
get_canvas(canvasHandle)->rotate(degrees);
}
@@ -781,6 +788,7 @@
{"nGetMatrix", "(JJ)V", (void*)CanvasJNI::getMatrix},
{"nSetMatrix","(JJ)V", (void*) CanvasJNI::setMatrix},
{"nConcat","(JJ)V", (void*) CanvasJNI::concat},
+ {"nConcat","(J[F)V", (void*) CanvasJNI::concat44},
{"nRotate","(JF)V", (void*) CanvasJNI::rotate},
{"nScale","(JFF)V", (void*) CanvasJNI::scale},
{"nSkew","(JFF)V", (void*) CanvasJNI::skew},
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 4918289..69708ec 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -23,6 +23,7 @@
import static android.media.audio.Flags.automaticBtDeviceType;
import static android.media.audio.Flags.FLAG_FOCUS_EXCLUSIVE_WITH_RECORDING;
import static android.media.audio.Flags.FLAG_FOCUS_FREEZE_TEST_API;
+import static android.media.audio.Flags.FLAG_SUPPORTED_DEVICE_TYPES_API;
import static android.media.audiopolicy.Flags.FLAG_ENABLE_FADE_MANAGER_CONFIGURATION;
import android.Manifest;
@@ -80,6 +81,7 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
+import android.util.IntArray;
import android.util.Log;
import android.util.Pair;
import android.view.KeyEvent;
@@ -100,6 +102,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
@@ -7838,6 +7841,51 @@
}
/**
+ * Returns a Set of unique Integers corresponding to audio device type identifiers that can
+ * <i>potentially</i> be connected to the system and meeting the criteria specified in the
+ * <code>direction</code> parameter.
+ * Note that this set contains {@link AudioDeviceInfo} device type identifiers for both devices
+ * currently available <i>and</i> those that can be available if the user connects an audio
+ * peripheral. Examples include TYPE_WIRED_HEADSET if the Android device supports an analog
+ * headset jack or TYPE_USB_DEVICE if the Android device supports a USB host-mode port.
+ * These are generally a superset of device type identifiers associated with the
+ * AudioDeviceInfo objects returned from AudioManager.getDevices().
+ * @param direction The constant specifying whether input or output devices are queried.
+ * @see #GET_DEVICES_OUTPUTS
+ * @see #GET_DEVICES_INPUTS
+ * @return A (possibly zero-length) Set of Integer objects corresponding to the audio
+ * device types of devices supported by the implementation.
+ * @throws IllegalArgumentException If an invalid direction constant is specified.
+ */
+ @FlaggedApi(FLAG_SUPPORTED_DEVICE_TYPES_API)
+ public @NonNull Set<Integer>
+ getSupportedDeviceTypes(int direction) {
+ if (direction != GET_DEVICES_OUTPUTS && direction != GET_DEVICES_INPUTS) {
+ throw new IllegalArgumentException("AudioManager.getSupportedDeviceTypes("
+ + Integer.toHexString(direction) + ") - Invalid.");
+ }
+
+ IntArray internalDeviceTypes = new IntArray();
+ int status = AudioSystem.getSupportedDeviceTypes(direction, internalDeviceTypes);
+ if (status != AudioManager.SUCCESS) {
+ Log.e(TAG, "AudioManager.getSupportedDeviceTypes(" + direction + ") failed. status:"
+ + status);
+ }
+
+ // convert to external (AudioDeviceInfo.getType()) device IDs
+ HashSet<Integer> externalDeviceTypes = new HashSet<Integer>();
+ for (int index = 0; index < internalDeviceTypes.size(); index++) {
+ // Set will eliminate any duplicates which AudioSystem.getSupportedDeviceTypes()
+ // returns
+ externalDeviceTypes.add(
+ AudioDeviceInfo.convertInternalDeviceToDeviceType(
+ internalDeviceTypes.get(index)));
+ }
+
+ return externalDeviceTypes;
+ }
+
+ /**
* Returns an array of {@link AudioDeviceInfo} objects corresponding to the audio devices
* currently connected to the system and meeting the criteria specified in the
* <code>flags</code> parameter.
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 0f6cbff..f73be35f 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -36,6 +36,7 @@
import android.os.Parcel;
import android.os.Vibrator;
import android.telephony.TelephonyManager;
+import android.util.IntArray;
import android.util.Log;
import android.util.Pair;
@@ -1947,6 +1948,8 @@
/** @hide */
public static native int listAudioPorts(ArrayList<AudioPort> ports, int[] generation);
/** @hide */
+ public static native int getSupportedDeviceTypes(int flags, IntArray internalDeviceTypes);
+ /** @hide */
public static native int createAudioPatch(AudioPatch[] patch,
AudioPortConfig[] sources, AudioPortConfig[] sinks);
/** @hide */
diff --git a/media/java/android/media/tv/ITvInputClient.aidl b/media/java/android/media/tv/ITvInputClient.aidl
index 8978277..b644621 100644
--- a/media/java/android/media/tv/ITvInputClient.aidl
+++ b/media/java/android/media/tv/ITvInputClient.aidl
@@ -69,4 +69,6 @@
// For ad response
void onAdResponse(in AdResponse response, int seq);
void onAdBufferConsumed(in AdBuffer buffer, int seq);
+
+ void onTvInputSessionData(in String type, in Bundle data, int seq);
}
diff --git a/media/java/android/media/tv/ITvInputManager.aidl b/media/java/android/media/tv/ITvInputManager.aidl
index 2f6575e..84c197d 100644
--- a/media/java/android/media/tv/ITvInputManager.aidl
+++ b/media/java/android/media/tv/ITvInputManager.aidl
@@ -152,4 +152,6 @@
// For freezing video playback
void setVideoFrozen(in IBinder sessionToken, boolean isFrozen, int userId);
+
+ void notifyTvAdSessionData(in IBinder sessionToken, in String type, in Bundle data, int userId);
}
diff --git a/media/java/android/media/tv/ITvInputSession.aidl b/media/java/android/media/tv/ITvInputSession.aidl
index a93f18d..7b20c39 100644
--- a/media/java/android/media/tv/ITvInputSession.aidl
+++ b/media/java/android/media/tv/ITvInputSession.aidl
@@ -86,4 +86,6 @@
// For freezing video
void setVideoFrozen(boolean isFrozen);
+
+ void notifyTvAdSessionData(in String type, in Bundle data);
}
diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl
index 8e2702a..76e079f 100644
--- a/media/java/android/media/tv/ITvInputSessionCallback.aidl
+++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl
@@ -68,4 +68,6 @@
// For messages sent from the TV input
void onTvMessage(int type, in Bundle data);
+
+ void onTvInputSessionData(in String type, in Bundle data);
}
diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java
index 921104d..999e2cf 100644
--- a/media/java/android/media/tv/ITvInputSessionWrapper.java
+++ b/media/java/android/media/tv/ITvInputSessionWrapper.java
@@ -82,6 +82,7 @@
private static final int DO_STOP_PLAYBACK = 33;
private static final int DO_START_PLAYBACK = 34;
private static final int DO_SET_VIDEO_FROZEN = 35;
+ private static final int DO_NOTIFY_AD_SESSION_DATA = 36;
private final boolean mIsRecordingSession;
private final HandlerCaller mCaller;
@@ -287,6 +288,7 @@
case DO_NOTIFY_TV_MESSAGE: {
SomeArgs args = (SomeArgs) msg.obj;
mTvInputSessionImpl.onTvMessageReceived((Integer) args.arg1, (Bundle) args.arg2);
+ args.recycle();
break;
}
case DO_STOP_PLAYBACK: {
@@ -301,6 +303,12 @@
mTvInputSessionImpl.setVideoFrozen((Boolean) msg.obj);
break;
}
+ case DO_NOTIFY_AD_SESSION_DATA: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ mTvInputSessionImpl.notifyTvAdSessionData((String) args.arg1, (Bundle) args.arg2);
+ args.recycle();
+ break;
+ }
default: {
Log.w(TAG, "Unhandled message code: " + msg.what);
break;
@@ -488,6 +496,12 @@
}
@Override
+ public void notifyTvAdSessionData(String type, Bundle data) {
+ mCaller.executeOrSendMessage(
+ mCaller.obtainMessageOO(DO_NOTIFY_AD_SESSION_DATA, type, data));
+ }
+
+ @Override
public void setVideoFrozen(boolean isFrozen) {
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_VIDEO_FROZEN, isFrozen));
}
diff --git a/media/java/android/media/tv/SignalingDataInfo.aidl b/media/java/android/media/tv/SignalingDataInfo.aidl
new file mode 100644
index 0000000..7108f36
--- /dev/null
+++ b/media/java/android/media/tv/SignalingDataInfo.aidl
@@ -0,0 +1,3 @@
+package android.media.tv;
+
+parcelable SignalingDataInfo;
diff --git a/media/java/android/media/tv/SignalingDataInfo.java b/media/java/android/media/tv/SignalingDataInfo.java
new file mode 100644
index 0000000..b29ea5c
--- /dev/null
+++ b/media/java/android/media/tv/SignalingDataInfo.java
@@ -0,0 +1,117 @@
+/*
+ * 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 android.media.tv;
+
+import android.annotation.NonNull;
+import android.os.Parcelable;
+
+/** @hide */
+public class SignalingDataInfo implements Parcelable {
+ public static final @NonNull Parcelable.Creator<SignalingDataInfo> CREATOR =
+ new Parcelable.Creator<SignalingDataInfo>() {
+ @Override
+ public SignalingDataInfo[] newArray(int size) {
+ return new SignalingDataInfo[size];
+ }
+
+ @Override
+ public SignalingDataInfo createFromParcel(@NonNull android.os.Parcel in) {
+ return new SignalingDataInfo(in);
+ }
+ };
+
+ private int mTableId;
+ private @NonNull String mTable;
+ private int mMetadataType;
+ private int mVersion;
+ private int mGroup;
+ private @NonNull String mEncoding;
+
+ public SignalingDataInfo(
+ int tableId,
+ @NonNull String table,
+ int metadataType,
+ int version,
+ int group,
+ @NonNull String encoding) {
+ this.mTableId = tableId;
+ this.mTable = table;
+ com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mTable);
+ this.mMetadataType = metadataType;
+ this.mVersion = version;
+ this.mGroup = group;
+ this.mEncoding = encoding;
+ com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mEncoding);
+ }
+
+ public int getTableId() {
+ return mTableId;
+ }
+
+ public @NonNull String getTable() {
+ return mTable;
+ }
+
+ public int getMetadataType() {
+ return mMetadataType;
+ }
+
+ public int getVersion() {
+ return mVersion;
+ }
+
+ public int getGroup() {
+ return mGroup;
+ }
+
+ public @NonNull String getEncoding() {
+ return mEncoding;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
+ dest.writeInt(mTableId);
+ dest.writeString(mTable);
+ dest.writeInt(mMetadataType);
+ dest.writeInt(mVersion);
+ dest.writeInt(mGroup);
+ dest.writeString(mEncoding);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ SignalingDataInfo(@NonNull android.os.Parcel in) {
+ int tableId = in.readInt();
+ String table = in.readString();
+ int metadataType = in.readInt();
+ int version = in.readInt();
+ int group = in.readInt();
+ String encoding = in.readString();
+
+ this.mTableId = tableId;
+ this.mTable = table;
+ com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mTable);
+ this.mMetadataType = metadataType;
+ this.mVersion = version;
+ this.mGroup = group;
+ this.mEncoding = encoding;
+ com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mEncoding);
+ }
+}
diff --git a/media/java/android/media/tv/SignalingDataResponse.aidl b/media/java/android/media/tv/SignalingDataResponse.aidl
new file mode 100644
index 0000000..a548e4e
--- /dev/null
+++ b/media/java/android/media/tv/SignalingDataResponse.aidl
@@ -0,0 +1,3 @@
+package android.media.tv;
+
+parcelable SignalingDataResponse;
diff --git a/media/java/android/media/tv/SignalingDataResponse.java b/media/java/android/media/tv/SignalingDataResponse.java
new file mode 100644
index 0000000..3e4c790
--- /dev/null
+++ b/media/java/android/media/tv/SignalingDataResponse.java
@@ -0,0 +1,100 @@
+/*
+ * 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 android.media.tv;
+
+import android.annotation.NonNull;
+import android.os.Parcelable;
+
+import java.util.List;
+
+/** @hide */
+public class SignalingDataResponse extends BroadcastInfoResponse implements Parcelable {
+ public static final @NonNull Parcelable.Creator<SignalingDataResponse> CREATOR =
+ new Parcelable.Creator<SignalingDataResponse>() {
+ @Override
+ public SignalingDataResponse[] newArray(int size) {
+ return new SignalingDataResponse[size];
+ }
+
+ @Override
+ public SignalingDataResponse createFromParcel(@NonNull android.os.Parcel in) {
+ return new SignalingDataResponse(in);
+ }
+ };
+ private static final @TvInputManager.BroadcastInfoType int RESPONSE_TYPE =
+ TvInputManager.BROADCAST_INFO_TYPE_SIGNALING_DATA;
+ private final @NonNull int[] mTableIds;
+ private final int mMetadataTypes;
+ private final @NonNull List<SignalingDataInfo> mSignalingDataInfoList;
+
+ public SignalingDataResponse(
+ int requestId,
+ int sequence,
+ @ResponseResult int responseResult,
+ @NonNull int[] tableIds,
+ int metadataTypes,
+ @NonNull List<SignalingDataInfo> signalingDataInfoList) {
+ super(RESPONSE_TYPE, requestId, sequence, responseResult);
+ this.mTableIds = tableIds;
+ com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mTableIds);
+ this.mMetadataTypes = metadataTypes;
+ this.mSignalingDataInfoList = signalingDataInfoList;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mSignalingDataInfoList);
+ }
+
+ public @NonNull int[] getTableIds() {
+ return mTableIds;
+ }
+
+ public int getMetadataTypes() {
+ return mMetadataTypes;
+ }
+
+ public @NonNull List<SignalingDataInfo> getSignalingDataInfoList() {
+ return mSignalingDataInfoList;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeIntArray(mTableIds);
+ dest.writeInt(mMetadataTypes);
+ dest.writeParcelableList(mSignalingDataInfoList, flags);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ SignalingDataResponse(@NonNull android.os.Parcel in) {
+ super(RESPONSE_TYPE, in);
+
+ int[] tableIds = in.createIntArray();
+ int metadataTypes = in.readInt();
+ List<SignalingDataInfo> signalingDataInfoList = new java.util.ArrayList<>();
+ in.readParcelableList(signalingDataInfoList, SignalingDataInfo.class.getClassLoader());
+
+ this.mTableIds = tableIds;
+ com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mTableIds);
+ this.mMetadataTypes = metadataTypes;
+ this.mSignalingDataInfoList = signalingDataInfoList;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mSignalingDataInfoList);
+ }
+}
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index be1b675..8720bfe 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -22,6 +22,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.annotation.StringDef;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
@@ -535,6 +536,220 @@
*/
public static final int SIGNAL_STRENGTH_STRONG = 3;
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @StringDef(prefix = "SESSION_DATA_TYPE_", value = {
+ SESSION_DATA_TYPE_TUNED,
+ SESSION_DATA_TYPE_TRACK_SELECTED,
+ SESSION_DATA_TYPE_TRACKS_CHANGED,
+ SESSION_DATA_TYPE_VIDEO_AVAILABLE,
+ SESSION_DATA_TYPE_VIDEO_UNAVAILABLE,
+ SESSION_DATA_TYPE_BROADCAST_INFO_RESPONSE,
+ SESSION_DATA_TYPE_AD_RESPONSE,
+ SESSION_DATA_TYPE_AD_BUFFER_CONSUMED,
+ SESSION_DATA_TYPE_TV_MESSAGE})
+ public @interface SessionDataType {}
+
+ /**
+ * Informs the application that the session has been tuned to the given channel.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_CHANNEL_URI
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_TUNED = "tuned";
+
+ /**
+ * Sends the type and ID of a selected track. This is used to inform the application that a
+ * specific track is selected.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_TRACK_TYPE
+ * @see SESSION_DATA_KEY_TRACK_ID
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_TRACK_SELECTED = "track_selected";
+
+ /**
+ * Sends the list of all audio/video/subtitle tracks.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_TRACKS
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_TRACKS_CHANGED = "tracks_changed";
+
+ /**
+ * Informs the application that the video is now available for watching.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_VIDEO_AVAILABLE = "video_available";
+
+ /**
+ * Informs the application that the video became unavailable for some reason.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_VIDEO_UNAVAILABLE_REASON
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_VIDEO_UNAVAILABLE = "video_unavailable";
+
+ /**
+ * Notifies response for broadcast info.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_BROADCAST_INFO_RESPONSE
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_BROADCAST_INFO_RESPONSE =
+ "broadcast_info_response";
+
+ /**
+ * Notifies response for advertisement.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_AD_RESPONSE
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_AD_RESPONSE = "ad_response";
+
+ /**
+ * Notifies the advertisement buffer is consumed.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_AD_BUFFER
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_AD_BUFFER_CONSUMED = "ad_buffer_consumed";
+
+ /**
+ * Sends the TV message.
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @see TvInputService.Session#notifyTvMessage(int, Bundle)
+ * @see SESSION_DATA_KEY_TV_MESSAGE_TYPE
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_TV_MESSAGE = "tv_message";
+
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @StringDef(prefix = "SESSION_DATA_KEY_", value = {
+ SESSION_DATA_KEY_CHANNEL_URI,
+ SESSION_DATA_KEY_TRACK_TYPE,
+ SESSION_DATA_KEY_TRACK_ID,
+ SESSION_DATA_KEY_TRACKS,
+ SESSION_DATA_KEY_VIDEO_UNAVAILABLE_REASON,
+ SESSION_DATA_KEY_BROADCAST_INFO_RESPONSE,
+ SESSION_DATA_KEY_AD_RESPONSE,
+ SESSION_DATA_KEY_AD_BUFFER,
+ SESSION_DATA_KEY_TV_MESSAGE_TYPE})
+ public @interface SessionDataKey {}
+
+ /**
+ * The URI of a channel.
+ *
+ * <p> Type: android.net.Uri
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_CHANNEL_URI = "channel_uri";
+
+ /**
+ * The type of the track.
+ *
+ * <p>One of {@link TvTrackInfo#TYPE_AUDIO}, {@link TvTrackInfo#TYPE_VIDEO},
+ * {@link TvTrackInfo#TYPE_SUBTITLE}.
+ *
+ * <p> Type: Integer
+ *
+ * @see TvTrackInfo#getType()
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_TRACK_TYPE = "track_type";
+
+ /**
+ * The ID of the track.
+ *
+ * <p> Type: String
+ *
+ * @see TvTrackInfo#getId()
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_TRACK_ID = "track_id";
+
+ /**
+ * A list which includes track information.
+ *
+ * <p> Type: {@code java.util.List<android.media.tv.TvTrackInfo> }
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_TRACKS = "tracks";
+
+ /**
+ * The reason why the video became unavailable.
+ * <p>The value can be {@link VIDEO_UNAVAILABLE_REASON_BUFFERING},
+ * {@link VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY}, etc.
+ *
+ * <p> Type: Integer
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_VIDEO_UNAVAILABLE_REASON =
+ "video_unavailable_reason";
+
+ /**
+ * An object of {@link BroadcastInfoResponse}.
+ *
+ * <p> Type: android.media.tv.BroadcastInfoResponse
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_BROADCAST_INFO_RESPONSE = "broadcast_info_response";
+
+ /**
+ * An object of {@link AdResponse}.
+ *
+ * <p> Type: android.media.tv.AdResponse
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_AD_RESPONSE = "ad_response";
+
+ /**
+ * An object of {@link AdBuffer}.
+ *
+ * <p> Type: android.media.tv.AdBuffer
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_AD_BUFFER = "ad_buffer";
+
+ /**
+ * The type of TV message.
+ * <p>It can be one of {@link TV_MESSAGE_TYPE_WATERMARK},
+ * {@link TV_MESSAGE_TYPE_CLOSED_CAPTION}, {@link TV_MESSAGE_TYPE_OTHER}
+ *
+ * <p> Type: Integer
+ *
+ * @see TvInputService.Session#notifyTvInputSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_TV_MESSAGE_TYPE = "tv_message_type";
+
+
/**
* An unknown state of the client pid gets from the TvInputManager. Client gets this value when
* query through {@link getClientPid(String sessionId)} fails.
@@ -1271,6 +1486,17 @@
});
}
}
+
+ void postTvInputSessionData(String type, Bundle data) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mSession.getAdSession() != null) {
+ mSession.getAdSession().notifyTvInputSessionData(type, data);
+ }
+ }
+ });
+ }
}
/**
@@ -1820,6 +2046,18 @@
record.postAdBufferConsumed(buffer);
}
}
+
+ @Override
+ public void onTvInputSessionData(String type, Bundle data, int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postTvInputSessionData(type, data);
+ }
+ }
};
ITvInputManagerCallback managerCallback = new ITvInputManagerCallback.Stub() {
@Override
@@ -3844,6 +4082,21 @@
}
}
+ /**
+ * Notifies data from session of linked TvAdService.
+ */
+ public void notifyTvAdSessionData(String type, Bundle data) {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.notifyTvAdSessionData(mToken, type, data, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
private final class InputEventHandler extends Handler {
public static final int MSG_SEND_INPUT_EVENT = 1;
public static final int MSG_TIMEOUT_INPUT_EVENT = 2;
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index 6301a27..a022b1c 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -34,6 +34,7 @@
import android.hardware.hdmi.HdmiDeviceInfo;
import android.media.AudioPresentation;
import android.media.PlaybackParams;
+import android.media.tv.ad.TvAdManager;
import android.media.tv.interactive.TvInteractiveAppService;
import android.net.Uri;
import android.os.AsyncTask;
@@ -1259,6 +1260,37 @@
}
/**
+ * Notifies data related to this session to corresponding linked
+ * {@link android.media.tv.ad.TvAdService} object via TvAdView.
+ *
+ * <p>Methods like {@link #notifyBroadcastInfoResponse(BroadcastInfoResponse)} sends the
+ * related data to linked {@link android.media.tv.interactive.TvInteractiveAppService}, but
+ * don't work for {@link android.media.tv.ad.TvAdService}. The method is used specifically
+ * for {@link android.media.tv.ad.TvAdService} use cases.
+ *
+ * @param type data type
+ * @param data the related data values
+ * @hide
+ */
+ public void notifyTvInputSessionData(
+ @NonNull @TvInputManager.SessionDataType String type, @NonNull Bundle data) {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) Log.d(TAG, "notifyTvInputSessionData");
+ if (mSessionCallback != null) {
+ mSessionCallback.onTvInputSessionData(type, data);
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in notifyTvInputSessionData", e);
+ }
+ }
+ });
+ }
+
+ /**
* Assigns a size and position to the surface passed in {@link #onSetSurface}. The position
* is relative to the overlay view that sits on top of this surface.
*
@@ -1401,6 +1433,20 @@
public void onAdBufferReady(@NonNull AdBuffer buffer) {
}
+
+ /**
+ * Called when data from the linked {@link android.media.tv.ad.TvAdService} is received.
+ *
+ * @param type the type of the data
+ * @param data a bundle contains the data received
+ * @see android.media.tv.ad.TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @see android.media.tv.ad.TvAdView#setTvView(TvView)
+ * @hide
+ */
+ public void onTvAdSessionData(
+ @NonNull @TvAdManager.SessionDataType String type, @NonNull Bundle data) {
+ }
+
/**
* Tunes to a given channel.
*
@@ -2166,6 +2212,10 @@
onAdBufferReady(buffer);
}
+ void notifyTvAdSessionData(String type, Bundle data) {
+ onTvAdSessionData(type, data);
+ }
+
void onTvMessageReceived(int type, Bundle data) {
onTvMessage(type, data);
}
diff --git a/media/java/android/media/tv/ad/ITvAdClient.aidl b/media/java/android/media/tv/ad/ITvAdClient.aidl
index 34d96b3..49046d0 100644
--- a/media/java/android/media/tv/ad/ITvAdClient.aidl
+++ b/media/java/android/media/tv/ad/ITvAdClient.aidl
@@ -16,6 +16,7 @@
package android.media.tv.ad;
+import android.os.Bundle;
import android.view.InputChannel;
/**
@@ -27,4 +28,11 @@
void onSessionCreated(in String serviceId, IBinder token, in InputChannel channel, int seq);
void onSessionReleased(int seq);
void onLayoutSurface(int left, int top, int right, int bottom, int seq);
+ void onRequestCurrentVideoBounds(int seq);
+ void onRequestCurrentChannelUri(int seq);
+ void onRequestTrackInfoList(int seq);
+ void onRequestCurrentTvInputId(int seq);
+ void onRequestSigning(
+ in String id, in String algorithm, in String alias, in byte[] data, int seq);
+ void onTvAdSessionData(in String type, in Bundle data, int seq);
}
\ No newline at end of file
diff --git a/media/java/android/media/tv/ad/ITvAdManager.aidl b/media/java/android/media/tv/ad/ITvAdManager.aidl
index 9620065..5c5f095 100644
--- a/media/java/android/media/tv/ad/ITvAdManager.aidl
+++ b/media/java/android/media/tv/ad/ITvAdManager.aidl
@@ -31,6 +31,7 @@
*/
interface ITvAdManager {
List<TvAdServiceInfo> getTvAdServiceList(int userId);
+ void sendAppLinkCommand(String serviceId, in Bundle command, int userId);
void createSession(
in ITvAdClient client, in String serviceId, in String type, int seq, int userId);
void releaseSession(in IBinder sessionToken, int userId);
@@ -58,4 +59,7 @@
int userId);
void relayoutMediaView(in IBinder sessionToken, in Rect frame, int userId);
void removeMediaView(in IBinder sessionToken, int userId);
+
+ void notifyTvInputSessionData(
+ in IBinder sessionToken, in String type, in Bundle data, int userId);
}
diff --git a/media/java/android/media/tv/ad/ITvAdSession.aidl b/media/java/android/media/tv/ad/ITvAdSession.aidl
index 69afb17..eba0bc8 100644
--- a/media/java/android/media/tv/ad/ITvAdSession.aidl
+++ b/media/java/android/media/tv/ad/ITvAdSession.aidl
@@ -46,4 +46,6 @@
void createMediaView(in IBinder windowToken, in Rect frame);
void relayoutMediaView(in Rect frame);
void removeMediaView();
+
+ void notifyTvInputSessionData(in String type, in Bundle data);
}
diff --git a/media/java/android/media/tv/ad/ITvAdSessionCallback.aidl b/media/java/android/media/tv/ad/ITvAdSessionCallback.aidl
index f21ef19..e4e5cbb 100644
--- a/media/java/android/media/tv/ad/ITvAdSessionCallback.aidl
+++ b/media/java/android/media/tv/ad/ITvAdSessionCallback.aidl
@@ -17,6 +17,7 @@
package android.media.tv.ad;
import android.media.tv.ad.ITvAdSession;
+import android.os.Bundle;
/**
* Helper interface for ITvAdSession to allow TvAdService to notify the system service when there is
@@ -26,4 +27,10 @@
oneway interface ITvAdSessionCallback {
void onSessionCreated(in ITvAdSession session);
void onLayoutSurface(int left, int top, int right, int bottom);
+ void onRequestCurrentVideoBounds();
+ void onRequestCurrentChannelUri();
+ void onRequestTrackInfoList();
+ void onRequestCurrentTvInputId();
+ void onRequestSigning(in String id, in String algorithm, in String alias, in byte[] data);
+ void onTvAdSessionData(in String type, in Bundle data);
}
\ No newline at end of file
diff --git a/media/java/android/media/tv/ad/ITvAdSessionWrapper.java b/media/java/android/media/tv/ad/ITvAdSessionWrapper.java
index 251351d..e10a20e 100644
--- a/media/java/android/media/tv/ad/ITvAdSessionWrapper.java
+++ b/media/java/android/media/tv/ad/ITvAdSessionWrapper.java
@@ -65,6 +65,7 @@
private static final int DO_SEND_SIGNING_RESULT = 14;
private static final int DO_NOTIFY_ERROR = 15;
private static final int DO_NOTIFY_TV_MESSAGE = 16;
+ private static final int DO_NOTIFY_INPUT_SESSION_DATA = 17;
private final HandlerCaller mCaller;
private TvAdService.Session mSessionImpl;
@@ -180,6 +181,12 @@
args.recycle();
break;
}
+ case DO_NOTIFY_INPUT_SESSION_DATA: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ mSessionImpl.notifyTvInputSessionData((String) args.arg1, (Bundle) args.arg2);
+ args.recycle();
+ break;
+ }
default: {
Log.w(TAG, "Unhandled message code: " + msg.what);
break;
@@ -280,6 +287,12 @@
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_REMOVE_MEDIA_VIEW));
}
+ @Override
+ public void notifyTvInputSessionData(String type, Bundle data) {
+ mCaller.executeOrSendMessage(
+ mCaller.obtainMessageOO(DO_NOTIFY_INPUT_SESSION_DATA, type, data));
+ }
+
private final class TvAdEventReceiver extends InputEventReceiver {
TvAdEventReceiver(InputChannel inputChannel, Looper looper) {
super(inputChannel, looper);
diff --git a/media/java/android/media/tv/ad/TvAdManager.java b/media/java/android/media/tv/ad/TvAdManager.java
index 4dce72f..02c0d75 100644
--- a/media/java/android/media/tv/ad/TvAdManager.java
+++ b/media/java/android/media/tv/ad/TvAdManager.java
@@ -16,12 +16,15 @@
package android.media.tv.ad;
+import android.annotation.CallbackExecutor;
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.StringDef;
import android.annotation.SystemService;
import android.content.Context;
import android.graphics.Rect;
+import android.media.tv.AdBuffer;
import android.media.tv.TvInputManager;
import android.media.tv.TvTrackInfo;
import android.media.tv.flags.Flags;
@@ -43,7 +46,10 @@
import com.android.internal.util.Preconditions;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Executor;
@@ -57,6 +63,198 @@
// TODO: implement more methods and unhide APIs.
private static final String TAG = "TvAdManager";
+ /**
+ * Key for package name in app link.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @hide
+ */
+ public static final String APP_LINK_KEY_PACKAGE_NAME = "package_name";
+
+ /**
+ * Key for class name in app link.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @hide
+ */
+ public static final String APP_LINK_KEY_CLASS_NAME = "class_name";
+
+ /**
+ * Key for command type in app link command.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @hide
+ */
+ public static final String APP_LINK_KEY_COMMAND_TYPE = "command_type";
+
+ /**
+ * Key for service ID in app link command.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @hide
+ */
+ public static final String APP_LINK_KEY_SERVICE_ID = "service_id";
+
+ /**
+ * Key for back URI in app link command.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @hide
+ */
+ public static final String APP_LINK_KEY_BACK_URI = "back_uri";
+
+ /**
+ * Broadcast intent action to send app command to TV app.
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @hide
+ */
+ public static final String ACTION_APP_LINK_COMMAND =
+ "android.media.tv.ad.action.APP_LINK_COMMAND";
+
+ /**
+ * Intent key for TV input ID. It's used to send app command to TV app.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @hide
+ */
+ public static final String INTENT_KEY_TV_INPUT_ID = "tv_input_id";
+
+ /**
+ * Intent key for TV AD service ID. It's used to send app command to TV app.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @see TvAdServiceInfo#getId()
+ * @hide
+ */
+ public static final String INTENT_KEY_AD_SERVICE_ID = "ad_service_id";
+
+ /**
+ * Intent key for TV channel URI. It's used to send app command to TV app.
+ * <p>Type: android.net.Uri
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @hide
+ */
+ public static final String INTENT_KEY_CHANNEL_URI = "channel_uri";
+
+ /**
+ * Intent key for command type. It's used to send app command to TV app. The value of this key
+ * could vary according to TV apps.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @hide
+ */
+ public static final String INTENT_KEY_COMMAND_TYPE = "command_type";
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @StringDef(prefix = "SESSION_DATA_TYPE_", value = {
+ SESSION_DATA_TYPE_AD_REQUEST,
+ SESSION_DATA_TYPE_AD_BUFFER_READY,
+ SESSION_DATA_TYPE_BROADCAST_INFO_REQUEST,
+ SESSION_DATA_TYPE_REMOVE_BROADCAST_INFO_REQUEST})
+ public @interface SessionDataType {}
+
+ /**
+ * Sends an advertisement request to be processed by the related TV input.
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_AD_REQUEST
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_AD_REQUEST = "ad_request";
+
+ /**
+ * Notifies the advertisement buffer is ready.
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_AD_BUFFER
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_AD_BUFFER_READY = "ad_buffer_ready";
+
+ /**
+ * Sends request for broadcast info.
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_BROADCAST_INFO_RESQUEST
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_BROADCAST_INFO_REQUEST = "broadcast_info_request";
+
+ /**
+ * Removes request for broadcast info.
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @see SESSION_DATA_KEY_BROADCAST_INFO_REQUEST_ID
+ * @hide
+ */
+ public static final String SESSION_DATA_TYPE_REMOVE_BROADCAST_INFO_REQUEST =
+ "remove_broadcast_info_request";
+
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @StringDef(prefix = "SESSION_DATA_KEY_", value = {
+ SESSION_DATA_KEY_AD_REQUEST,
+ SESSION_DATA_KEY_AD_BUFFER,
+ SESSION_DATA_KEY_BROADCAST_INFO_REQUEST,
+ SESSION_DATA_KEY_REQUEST_ID})
+ public @interface SessionDataKey {}
+
+ /**
+ * An object of {@link android.media.tv.AdRequest}.
+ *
+ * <p> Type: android.media.tv.AdRequest
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_AD_REQUEST = "ad_request";
+
+ /**
+ * An object of {@link AdBuffer}.
+ *
+ * <p> Type: android.media.tv.AdBuffer
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_AD_BUFFER = "ad_buffer";
+
+ /**
+ * An object of {@link android.media.tv.BroadcastInfoRequest}.
+ *
+ * <p> Type: android.media.tv.BroadcastInfoRequest
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_BROADCAST_INFO_REQUEST = "broadcast_info_request";
+
+ /**
+ * The ID of {@link android.media.tv.BroadcastInfoRequest}.
+ *
+ * <p> Type: Integer
+ *
+ * @see TvAdService.Session#notifyTvAdSessionData(String, Bundle)
+ * @hide
+ */
+ public static final String SESSION_DATA_KEY_REQUEST_ID = "request_id";
+
private final ITvAdManager mService;
private final int mUserId;
@@ -125,6 +323,79 @@
}
}
+ @Override
+ public void onRequestCurrentVideoBounds(int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postRequestCurrentVideoBounds();
+ }
+ }
+
+ @Override
+ public void onRequestCurrentChannelUri(int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postRequestCurrentChannelUri();
+ }
+ }
+
+ @Override
+ public void onRequestTrackInfoList(int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postRequestTrackInfoList();
+ }
+ }
+
+ @Override
+ public void onRequestCurrentTvInputId(int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postRequestCurrentTvInputId();
+ }
+ }
+
+ @Override
+ public void onRequestSigning(
+ String id, String algorithm, String alias, byte[] data, int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postRequestSigning(id, algorithm, alias, data);
+ }
+ }
+
+ @Override
+ public void onTvAdSessionData(String type, Bundle data, int seq) {
+ synchronized (mSessionCallbackRecordMap) {
+ SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
+ if (record == null) {
+ Log.e(TAG, "Callback not found for seq " + seq);
+ return;
+ }
+ record.postTvAdSessionData(type, data);
+ }
+ }
+
};
ITvAdManagerCallback managerCallback =
@@ -220,6 +491,59 @@
}
/**
+ * Sends app link command.
+ *
+ * @param serviceId The ID of TV AD service which the command to be sent to. The ID can be found
+ * in {@link TvAdServiceInfo#getId()}.
+ * @param command The command to be sent.
+ * @hide
+ */
+ public void sendAppLinkCommand(@NonNull String serviceId, @NonNull Bundle command) {
+ try {
+ mService.sendAppLinkCommand(serviceId, command, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Registers a {@link TvAdServiceCallback}.
+ *
+ * @param callback A callback used to monitor status of the TV AD services.
+ * @param executor A {@link Executor} that the status change will be delivered to.
+ * @hide
+ */
+ public void registerCallback(
+ @CallbackExecutor @NonNull Executor executor,
+ @NonNull TvAdServiceCallback callback) {
+ Preconditions.checkNotNull(callback);
+ Preconditions.checkNotNull(executor);
+ synchronized (mLock) {
+ mCallbackRecords.add(new TvAdServiceCallbackRecord(callback, executor));
+ }
+ }
+
+ /**
+ * Unregisters the existing {@link TvAdServiceCallback}.
+ *
+ * @param callback The existing callback to remove.
+ * @hide
+ */
+ public void unregisterCallback(@NonNull final TvAdServiceCallback callback) {
+ Preconditions.checkNotNull(callback);
+ synchronized (mLock) {
+ for (Iterator<TvAdServiceCallbackRecord> it = mCallbackRecords.iterator();
+ it.hasNext(); ) {
+ TvAdServiceCallbackRecord record = it.next();
+ if (record.getCallback() == callback) {
+ it.remove();
+ break;
+ }
+ }
+ }
+ }
+
+ /**
* The Session provides the per-session functionality of AD service.
* @hide
*/
@@ -533,6 +857,88 @@
}
}
+ /**
+ * Notifies data from session of linked TvInputService.
+ */
+ public void notifyTvInputSessionData(String type, Bundle data) {
+ if (mToken == null) {
+ Log.w(TAG, "The session has been already released");
+ return;
+ }
+ try {
+ mService.notifyTvInputSessionData(mToken, type, data, mUserId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Dispatches an input event to this session.
+ *
+ * @param event An {@link InputEvent} to dispatch. Cannot be {@code null}.
+ * @param token A token used to identify the input event later in the callback.
+ * @param callback A callback used to receive the dispatch result. Cannot be {@code null}.
+ * @param handler A {@link Handler} that the dispatch result will be delivered to. Cannot be
+ * {@code null}.
+ * @return Returns {@link #DISPATCH_HANDLED} if the event was handled. Returns
+ * {@link #DISPATCH_NOT_HANDLED} if the event was not handled. Returns
+ * {@link #DISPATCH_IN_PROGRESS} if the event is in progress and the callback will
+ * be invoked later.
+ * @hide
+ */
+ public int dispatchInputEvent(@NonNull InputEvent event, Object token,
+ @NonNull FinishedInputEventCallback callback, @NonNull Handler handler) {
+ Preconditions.checkNotNull(event);
+ Preconditions.checkNotNull(callback);
+ Preconditions.checkNotNull(handler);
+ synchronized (mHandler) {
+ if (mInputChannel == null) {
+ return DISPATCH_NOT_HANDLED;
+ }
+ PendingEvent p = obtainPendingEventLocked(event, token, callback, handler);
+ if (Looper.myLooper() == Looper.getMainLooper()) {
+ // Already running on the main thread so we can send the event immediately.
+ return sendInputEventOnMainLooperLocked(p);
+ }
+
+ // Post the event to the main thread.
+ Message msg = mHandler.obtainMessage(InputEventHandler.MSG_SEND_INPUT_EVENT, p);
+ msg.setAsynchronous(true);
+ mHandler.sendMessage(msg);
+ return DISPATCH_IN_PROGRESS;
+ }
+ }
+
+ private PendingEvent obtainPendingEventLocked(InputEvent event, Object token,
+ FinishedInputEventCallback callback, Handler handler) {
+ PendingEvent p = mPendingEventPool.acquire();
+ if (p == null) {
+ p = new PendingEvent();
+ }
+ p.mEvent = event;
+ p.mEventToken = token;
+ p.mCallback = callback;
+ p.mEventHandler = handler;
+ return p;
+ }
+
+ /**
+ * Callback that is invoked when an input event that was dispatched to this session has been
+ * finished.
+ *
+ * @hide
+ */
+ public interface FinishedInputEventCallback {
+ /**
+ * Called when the dispatched input event is finished.
+ *
+ * @param token A token passed to {@link #dispatchInputEvent}.
+ * @param handled {@code true} if the dispatched input event was handled properly.
+ * {@code false} otherwise.
+ */
+ void onFinishedInputEvent(Object token, boolean handled);
+ }
+
private final class InputEventHandler extends Handler {
public static final int MSG_SEND_INPUT_EVENT = 1;
public static final int MSG_TIMEOUT_INPUT_EVENT = 2;
@@ -639,23 +1045,6 @@
mPendingEventPool.release(p);
}
- /**
- * Callback that is invoked when an input event that was dispatched to this session has been
- * finished.
- *
- * @hide
- */
- public interface FinishedInputEventCallback {
- /**
- * Called when the dispatched input event is finished.
- *
- * @param token A token passed to {@link #dispatchInputEvent}.
- * @param handled {@code true} if the dispatched input event was handled properly.
- * {@code false} otherwise.
- */
- void onFinishedInputEvent(Object token, boolean handled);
- }
-
private final class TvInputEventSender extends InputEventSender {
TvInputEventSender(InputChannel inputChannel, Looper looper) {
super(inputChannel, looper);
@@ -730,6 +1119,58 @@
public void onLayoutSurface(Session session, int left, int top, int right, int bottom) {
}
+ /**
+ * This is called when {@link TvAdService.Session#requestCurrentVideoBounds} is
+ * called.
+ *
+ * @param session A {@link TvAdService.Session} associated with this callback.
+ */
+ public void onRequestCurrentVideoBounds(Session session) {
+ }
+
+ /**
+ * This is called when {@link TvAdService.Session#requestCurrentChannelUri} is
+ * called.
+ *
+ * @param session A {@link TvAdService.Session} associated with this callback.
+ */
+ public void onRequestCurrentChannelUri(Session session) {
+ }
+
+ /**
+ * This is called when {@link TvAdService.Session#requestTrackInfoList} is
+ * called.
+ *
+ * @param session A {@link TvAdService.Session} associated with this callback.
+ */
+ public void onRequestTrackInfoList(Session session) {
+ }
+
+ /**
+ * This is called when {@link TvAdService.Session#requestCurrentTvInputId} is
+ * called.
+ *
+ * @param session A {@link TvAdService.Session} associated with this callback.
+ */
+ public void onRequestCurrentTvInputId(Session session) {
+ }
+
+ /**
+ * This is called when
+ * {@link TvAdService.Session#requestSigning(String, String, String, byte[])} is
+ * called.
+ *
+ * @param session A {@link TvAdService.Session} associated with this callback.
+ * @param signingId the ID to identify the request.
+ * @param algorithm the standard name of the signature algorithm requested, such as
+ * MD5withRSA, SHA256withDSA, etc.
+ * @param alias the alias of the corresponding {@link java.security.KeyStore}.
+ * @param data the original bytes to be signed.
+ */
+ public void onRequestSigning(
+ Session session, String signingId, String algorithm, String alias, byte[] data) {
+ }
+
}
/**
@@ -810,6 +1251,62 @@
}
});
}
+
+ void postRequestCurrentVideoBounds() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onRequestCurrentVideoBounds(mSession);
+ }
+ });
+ }
+
+ void postRequestCurrentChannelUri() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onRequestCurrentChannelUri(mSession);
+ }
+ });
+ }
+
+ void postRequestTrackInfoList() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onRequestTrackInfoList(mSession);
+ }
+ });
+ }
+
+ void postRequestCurrentTvInputId() {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onRequestCurrentTvInputId(mSession);
+ }
+ });
+ }
+
+ void postRequestSigning(String id, String algorithm, String alias, byte[] data) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mSessionCallback.onRequestSigning(mSession, id, algorithm, alias, data);
+ }
+ });
+ }
+
+ void postTvAdSessionData(String type, Bundle data) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mSession.getInputSession() != null) {
+ mSession.getInputSession().notifyTvAdSessionData(type, data);
+ }
+ }
+ });
+ }
}
private static final class TvAdServiceCallbackRecord {
diff --git a/media/java/android/media/tv/ad/TvAdService.java b/media/java/android/media/tv/ad/TvAdService.java
index 5d81837..4d8f5c8b 100644
--- a/media/java/android/media/tv/ad/TvAdService.java
+++ b/media/java/android/media/tv/ad/TvAdService.java
@@ -31,6 +31,7 @@
import android.graphics.Rect;
import android.media.tv.TvInputManager;
import android.media.tv.TvTrackInfo;
+import android.media.tv.TvView;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -132,6 +133,9 @@
/**
* Called when app link command is received.
+ *
+ * @see TvAdManager#sendAppLinkCommand(String, Bundle)
+ * @hide
*/
public void onAppLinkCommand(@NonNull Bundle command) {
}
@@ -279,6 +283,143 @@
onResetAdService();
}
+ /**
+ * Requests the bounds of the current video.
+ * @hide
+ */
+ @CallSuper
+ public void requestCurrentVideoBounds() {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "requestCurrentVideoBounds");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onRequestCurrentVideoBounds();
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in requestCurrentVideoBounds", e);
+ }
+ }
+ });
+ }
+
+ /**
+ * Requests the URI of the current channel.
+ * @hide
+ */
+ @CallSuper
+ public void requestCurrentChannelUri() {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "requestCurrentChannelUri");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onRequestCurrentChannelUri();
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in requestCurrentChannelUri", e);
+ }
+ }
+ });
+ }
+
+ /**
+ * Requests the list of {@link TvTrackInfo}.
+ * @hide
+ */
+ @CallSuper
+ public void requestTrackInfoList() {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "requestTrackInfoList");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onRequestTrackInfoList();
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in requestTrackInfoList", e);
+ }
+ }
+ });
+ }
+
+ /**
+ * Requests current TV input ID.
+ *
+ * @see android.media.tv.TvInputInfo
+ * @hide
+ */
+ @CallSuper
+ public void requestCurrentTvInputId() {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "requestCurrentTvInputId");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onRequestCurrentTvInputId();
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in requestCurrentTvInputId", e);
+ }
+ }
+ });
+ }
+
+ /**
+ * Requests signing of the given data.
+ *
+ * <p>This is used when the corresponding server of the AD service app requires signing
+ * during handshaking, and the service doesn't have the built-in private key. The private
+ * key is provided by the content providers and pre-built in the related app, such as TV
+ * app.
+ *
+ * @param signingId the ID to identify the request. When a result is received, this ID can
+ * be used to correlate the result with the request.
+ * @param algorithm the standard name of the signature algorithm requested, such as
+ * MD5withRSA, SHA256withDSA, etc. The name is from standards like
+ * FIPS PUB 186-4 and PKCS #1.
+ * @param alias the alias of the corresponding {@link java.security.KeyStore}.
+ * @param data the original bytes to be signed.
+ *
+ * @see #onSigningResult(String, byte[])
+ */
+ @CallSuper
+ public void requestSigning(@NonNull String signingId, @NonNull String algorithm,
+ @NonNull String alias, @NonNull byte[] data) {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) {
+ Log.d(TAG, "requestSigning");
+ }
+ if (mSessionCallback != null) {
+ mSessionCallback.onRequestSigning(signingId, algorithm, alias, data);
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in requestSigning", e);
+ }
+ }
+ });
+ }
+
@Override
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
return false;
@@ -470,6 +611,19 @@
}
/**
+ * Called when data from the linked {@link android.media.tv.TvInputService} is received.
+ *
+ * @param type the type of the data
+ * @param data a bundle contains the data received
+ * @see android.media.tv.TvInputService.Session#notifyTvAdSessionData(String, Bundle)
+ * @see android.media.tv.ad.TvAdView#setTvView(TvView)
+ * @hide
+ */
+ public void onTvInputSessionData(
+ @NonNull @TvInputManager.SessionDataType String type, @NonNull Bundle data) {
+ }
+
+ /**
* Called when the size of the media view is changed by the application.
*
* <p>This is always called at least once when the session is created regardless of whether
@@ -497,6 +651,33 @@
}
/**
+ * Notifies data related to this session to corresponding linked
+ * {@link android.media.tv.TvInputService} object via TvView.
+ *
+ * @param type data type
+ * @param data the related data values
+ * @see TvAdView#setTvView(TvView)
+ * @hide
+ */
+ public void notifyTvAdSessionData(
+ @NonNull @TvAdManager.SessionDataType String type, @NonNull Bundle data) {
+ executeOrPostRunnableOnMainThread(new Runnable() {
+ @MainThread
+ @Override
+ public void run() {
+ try {
+ if (DEBUG) Log.d(TAG, "notifyTvAdSessionData");
+ if (mSessionCallback != null) {
+ mSessionCallback.onTvAdSessionData(type, data);
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "error in notifyTvAdSessionData", e);
+ }
+ }
+ });
+ }
+
+ /**
* Takes care of dispatching incoming input events and tells whether the event was handled.
*/
int dispatchInputEvent(InputEvent event, InputEventReceiver receiver) {
@@ -594,6 +775,10 @@
onTvMessage(type, data);
}
+ void notifyTvInputSessionData(String type, Bundle data) {
+ onTvInputSessionData(type, data);
+ }
+
private void executeOrPostRunnableOnMainThread(Runnable action) {
synchronized (mLock) {
if (mSessionCallback == null) {
diff --git a/media/java/android/media/tv/ad/TvAdView.java b/media/java/android/media/tv/ad/TvAdView.java
index ec23b7c..604dbd5 100644
--- a/media/java/android/media/tv/ad/TvAdView.java
+++ b/media/java/android/media/tv/ad/TvAdView.java
@@ -28,17 +28,21 @@
import android.media.tv.TvInputManager;
import android.media.tv.TvTrackInfo;
import android.media.tv.TvView;
+import android.media.tv.ad.TvAdManager.Session.FinishedInputEventCallback;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
+import android.view.InputEvent;
+import android.view.KeyEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewRootImpl;
import java.util.List;
import java.util.concurrent.Executor;
@@ -88,6 +92,7 @@
private boolean mMediaViewCreated;
private Rect mMediaViewFrame;
+ private OnUnhandledInputEventListener mOnUnhandledInputEventListener;
@@ -327,6 +332,109 @@
mSession.dispatchSurfaceChanged(format, width, height);
}
+ private final FinishedInputEventCallback mFinishedInputEventCallback =
+ new FinishedInputEventCallback() {
+ @Override
+ public void onFinishedInputEvent(Object token, boolean handled) {
+ if (DEBUG) {
+ Log.d(TAG, "onFinishedInputEvent(token=" + token + ", handled="
+ + handled + ")");
+ }
+ if (handled) {
+ return;
+ }
+ // TODO: Re-order unhandled events.
+ InputEvent event = (InputEvent) token;
+ if (dispatchUnhandledInputEvent(event)) {
+ return;
+ }
+ ViewRootImpl viewRootImpl = getViewRootImpl();
+ if (viewRootImpl != null) {
+ viewRootImpl.dispatchUnhandledInputEvent(event);
+ }
+ }
+ };
+
+ /**
+ * Dispatches an unhandled input event to the next receiver.
+ *
+ * It gives the host application a chance to dispatch the unhandled input events.
+ *
+ * @param event The input event.
+ * @return {@code true} if the event was handled by the view, {@code false} otherwise.
+ * @hide
+ */
+ public boolean dispatchUnhandledInputEvent(@NonNull InputEvent event) {
+ if (mOnUnhandledInputEventListener != null) {
+ if (mOnUnhandledInputEventListener.onUnhandledInputEvent(event)) {
+ return true;
+ }
+ }
+ return onUnhandledInputEvent(event);
+ }
+
+ /**
+ * Called when an unhandled input event also has not been handled by the user provided
+ * callback. This is the last chance to handle the unhandled input event in the
+ * TvAdView.
+ *
+ * @param event The input event.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to be
+ * handled by the next receiver, return {@code false}.
+ */
+ public boolean onUnhandledInputEvent(@NonNull InputEvent event) {
+ return false;
+ }
+
+ /**
+ * Sets a listener to be invoked when an input event is not handled
+ * by the TV AD service.
+ *
+ * @param listener The callback to be invoked when the unhandled input event is received.
+ * @hide
+ */
+ public void setOnUnhandledInputEventListener(
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OnUnhandledInputEventListener listener) {
+ mOnUnhandledInputEventListener = listener;
+ // TODO: handle CallbackExecutor
+ }
+
+ /**
+ * Gets the {@link OnUnhandledInputEventListener}.
+ * <p>Returns {@code null} if the listener is not set or is cleared.
+ *
+ * @see #setOnUnhandledInputEventListener(Executor, OnUnhandledInputEventListener)
+ * @see #clearOnUnhandledInputEventListener()
+ * @hide
+ */
+ @Nullable
+ public OnUnhandledInputEventListener getOnUnhandledInputEventListener() {
+ return mOnUnhandledInputEventListener;
+ }
+
+ /**
+ * Clears the {@link OnUnhandledInputEventListener}.
+ * @hide
+ */
+ public void clearOnUnhandledInputEventListener() {
+ mOnUnhandledInputEventListener = null;
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
+ if (super.dispatchKeyEvent(event)) {
+ return true;
+ }
+ if (mSession == null) {
+ return false;
+ }
+ InputEvent copiedEvent = event.copy();
+ int ret = mSession.dispatchInputEvent(copiedEvent, copiedEvent, mFinishedInputEventCallback,
+ mHandler);
+ return ret != TvAdManager.Session.DISPATCH_NOT_HANDLED;
+ }
+
/**
* Prepares the AD service of corresponding {@link TvAdService}.
*
@@ -504,6 +612,24 @@
}
/**
+ * Interface definition for a callback to be invoked when the unhandled input event is received.
+ * @hide
+ */
+ public interface OnUnhandledInputEventListener {
+ /**
+ * Called when an input event was not handled by the TV AD service.
+ *
+ * <p>This is called asynchronously from where the event is dispatched. It gives the host
+ * application a chance to handle the unhandled input events.
+ *
+ * @param event The input event.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to
+ * be handled by the next receiver, return {@code false}.
+ */
+ boolean onUnhandledInputEvent(@NonNull InputEvent event);
+ }
+
+ /**
* Sets the callback to be invoked when an event is dispatched to this TvAdView.
*
* @param callback the callback to receive events. MUST NOT be {@code null}.
@@ -606,6 +732,117 @@
mUseRequestedSurfaceLayout = true;
requestLayout();
}
+
+ @Override
+ public void onRequestCurrentVideoBounds(TvAdManager.Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onRequestCurrentVideoBounds");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onRequestCurrentVideoBounds - session not created");
+ return;
+ }
+ synchronized (mCallbackLock) {
+ if (mCallbackExecutor != null) {
+ mCallbackExecutor.execute(() -> {
+ synchronized (mCallbackLock) {
+ if (mCallback != null) {
+ mCallback.onRequestCurrentVideoBounds(mServiceId);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ public void onRequestCurrentChannelUri(TvAdManager.Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onRequestCurrentChannelUri");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onRequestCurrentChannelUri - session not created");
+ return;
+ }
+ synchronized (mCallbackLock) {
+ if (mCallbackExecutor != null) {
+ mCallbackExecutor.execute(() -> {
+ synchronized (mCallbackLock) {
+ if (mCallback != null) {
+ mCallback.onRequestCurrentChannelUri(mServiceId);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ public void onRequestTrackInfoList(TvAdManager.Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onRequestTrackInfoList");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onRequestTrackInfoList - session not created");
+ return;
+ }
+ synchronized (mCallbackLock) {
+ if (mCallbackExecutor != null) {
+ mCallbackExecutor.execute(() -> {
+ synchronized (mCallbackLock) {
+ if (mCallback != null) {
+ mCallback.onRequestTrackInfoList(mServiceId);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ public void onRequestCurrentTvInputId(TvAdManager.Session session) {
+ if (DEBUG) {
+ Log.d(TAG, "onRequestCurrentTvInputId");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onRequestCurrentTvInputId - session not created");
+ return;
+ }
+ synchronized (mCallbackLock) {
+ if (mCallbackExecutor != null) {
+ mCallbackExecutor.execute(() -> {
+ synchronized (mCallbackLock) {
+ if (mCallback != null) {
+ mCallback.onRequestCurrentTvInputId(mServiceId);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ public void onRequestSigning(TvAdManager.Session session, String id, String algorithm,
+ String alias, byte[] data) {
+ if (DEBUG) {
+ Log.d(TAG, "onRequestSigning");
+ }
+ if (this != mSessionCallback) {
+ Log.w(TAG, "onRequestSigning - session not created");
+ return;
+ }
+ synchronized (mCallbackLock) {
+ if (mCallbackExecutor != null) {
+ mCallbackExecutor.execute(() -> {
+ synchronized (mCallbackLock) {
+ if (mCallback != null) {
+ mCallback.onRequestSigning(mServiceId, id, algorithm, alias, data);
+ }
+ }
+ });
+ }
+ }
+ }
}
/**
@@ -613,5 +850,55 @@
* @hide
*/
public abstract static class TvAdCallback {
+
+ /**
+ * This is called when {@link TvAdService.Session#requestCurrentVideoBounds()}
+ * is called.
+ *
+ * @param serviceId The ID of the TV AD service bound to this view.
+ */
+ public void onRequestCurrentVideoBounds(@NonNull String serviceId) {
+ }
+
+ /**
+ * This is called when {@link TvAdService.Session#requestCurrentChannelUri()} is
+ * called.
+ *
+ * @param serviceId The ID of the AD service bound to this view.
+ */
+ public void onRequestCurrentChannelUri(@NonNull String serviceId) {
+ }
+
+ /**
+ * This is called when {@link TvAdService.Session#requestTrackInfoList()} is called.
+ *
+ * @param serviceId The ID of the AD service bound to this view.
+ */
+ public void onRequestTrackInfoList(@NonNull String serviceId) {
+ }
+
+ /**
+ * This is called when {@link TvAdService.Session#requestCurrentTvInputId()} is called.
+ *
+ * @param serviceId The ID of the AD service bound to this view.
+ */
+ public void onRequestCurrentTvInputId(@NonNull String serviceId) {
+ }
+
+ /**
+ * This is called when
+ * {@link TvAdService.Session#requestSigning(String, String, String, byte[])} is called.
+ *
+ * @param serviceId The ID of the AD service bound to this view.
+ * @param signingId the ID to identify the request.
+ * @param algorithm the standard name of the signature algorithm requested, such as
+ * MD5withRSA, SHA256withDSA, etc.
+ * @param alias the alias of the corresponding {@link java.security.KeyStore}.
+ * @param data the original bytes to be signed.
+ *
+ */
+ public void onRequestSigning(@NonNull String serviceId, @NonNull String signingId,
+ @NonNull String algorithm, @NonNull String alias, @NonNull byte[] data) {
+ }
}
}
diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt
index 3524f8c..f8b640c7 100644
--- a/nfc/api/system-current.txt
+++ b/nfc/api/system-current.txt
@@ -17,7 +17,7 @@
method @FlaggedApi("android.nfc.enable_nfc_charging") public void registerWlcStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.nfc.NfcAdapter.WlcStateListener);
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean removeNfcUnlockHandler(android.nfc.NfcAdapter.NfcUnlockHandler);
method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean setControllerAlwaysOn(boolean);
- method @FlaggedApi("android.nfc.enable_nfc_mainline") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setReaderMode(boolean);
+ method @FlaggedApi("android.nfc.enable_nfc_mainline") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setReaderModePollingEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int setTagIntentAppPreferenceForUser(int, @NonNull String, boolean);
method @FlaggedApi("android.nfc.enable_nfc_charging") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean setWlcEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public void unregisterControllerAlwaysOnListener(@NonNull android.nfc.NfcAdapter.ControllerAlwaysOnListener);
diff --git a/nfc/java/android/nfc/NfcAdapter.java b/nfc/java/android/nfc/NfcAdapter.java
index 11eb97b..4d56c11 100644
--- a/nfc/java/android/nfc/NfcAdapter.java
+++ b/nfc/java/android/nfc/NfcAdapter.java
@@ -1764,7 +1764,9 @@
private static final int ENABLE_POLLING_FLAGS = 0x0000;
/**
- * Privileged API to enable disable reader polling.
+ * Privileged API to enable or disable reader polling.
+ * Unlike {@link #enableReaderMode(Activity, ReaderCallback, int, Bundle)}, this API does not
+ * need a foreground activity to control reader mode parameters
* Note: Use with caution! The app is responsible for ensuring that the polling state is
* returned to normal.
*
@@ -1778,14 +1780,14 @@
@RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
@FlaggedApi(Flags.FLAG_ENABLE_NFC_MAINLINE)
@SuppressLint("VisiblySynchronized")
- public void setReaderMode(boolean enablePolling) {
+ public void setReaderModePollingEnabled(boolean enable) {
synchronized (sLock) {
if (!sHasNfcFeature) {
throw new UnsupportedOperationException();
}
}
Binder token = new Binder();
- int flags = enablePolling ? ENABLE_POLLING_FLAGS : DISABLE_POLLING_FLAGS;
+ int flags = enable ? ENABLE_POLLING_FLAGS : DISABLE_POLLING_FLAGS;
try {
NfcAdapter.sService.setReaderMode(token, null, flags, null);
} catch (RemoteException e) {
diff --git a/packages/CtsShim/OWNERS b/packages/CtsShim/OWNERS
index 9419771..f5741a0 100644
--- a/packages/CtsShim/OWNERS
+++ b/packages/CtsShim/OWNERS
@@ -1,3 +1,2 @@
-ioffe@google.com
-toddke@google.com
-patb@google.com
\ No newline at end of file
+include /PACKAGE_MANAGER_OWNERS
+ioffe@google.com
\ No newline at end of file
diff --git a/packages/PackageInstaller/OWNERS b/packages/PackageInstaller/OWNERS
index 2736870..acbdff8 100644
--- a/packages/PackageInstaller/OWNERS
+++ b/packages/PackageInstaller/OWNERS
@@ -1,5 +1,4 @@
-svetoslavganov@google.com
+# Bug component: 1002434
include /PACKAGE_MANAGER_OWNERS
-# For automotive related changes
-rogerxue@google.com
+sumedhsen@google.com
\ No newline at end of file
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/CardModel.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/CardModel.kt
index b2a8b87..960ebcc 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/CardModel.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/CardModel.kt
@@ -21,6 +21,7 @@
data class CardButton(
val text: String,
+ val contentDescription: String? = null,
val onClick: () -> Unit,
)
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/SettingsCard.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/SettingsCard.kt
index c7845fa..700fa48 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/SettingsCard.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/card/SettingsCard.kt
@@ -45,6 +45,8 @@
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.android.settingslib.spa.debug.UiModePreviews
import com.android.settingslib.spa.framework.theme.SettingsDimension
@@ -182,7 +184,11 @@
@Composable
private fun Button(button: CardButton, color: Color) {
- TextButton(onClick = button.onClick) {
+ TextButton(
+ onClick = button.onClick,
+ modifier =
+ Modifier.semantics { button.contentDescription?.let { this.contentDescription = it } }
+ ) {
Text(text = button.text, color = color)
}
}
diff --git a/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/card/SettingsCardTest.kt b/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/card/SettingsCardTest.kt
index beb9433..b5b2525 100644
--- a/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/card/SettingsCardTest.kt
+++ b/packages/SettingsLib/Spa/tests/src/com/android/settingslib/spa/widget/card/SettingsCardTest.kt
@@ -36,8 +36,7 @@
@RunWith(AndroidJUnit4::class)
class SettingsCardTest {
- @get:Rule
- val composeTestRule = createComposeRule()
+ @get:Rule val composeTestRule = createComposeRule()
private val context: Context = ApplicationProvider.getApplicationContext()
@@ -76,9 +75,7 @@
CardModel(
title = "",
text = "",
- buttons = listOf(
- CardButton(text = TEXT) {}
- ),
+ buttons = listOf(CardButton(text = TEXT) {}),
)
)
}
@@ -94,9 +91,7 @@
CardModel(
title = "",
text = "",
- buttons = listOf(
- CardButton(text = TEXT) { buttonClicked = true }
- ),
+ buttons = listOf(CardButton(text = TEXT) { buttonClicked = true }),
)
)
}
@@ -107,6 +102,25 @@
}
@Test
+ fun settingsCard_buttonHaveContentDescription() {
+ composeTestRule.setContent {
+ SettingsCard(
+ CardModel(
+ title = "",
+ text = "",
+ buttons = listOf(CardButton(
+ text = TEXT,
+ contentDescription = CONTENT_DESCRIPTION,
+ ) {}
+ ),
+ )
+ )
+ }
+
+ composeTestRule.onNodeWithContentDescription(CONTENT_DESCRIPTION).assertIsDisplayed()
+ }
+
+ @Test
fun settingsCard_dismiss() {
composeTestRule.setContent {
var isVisible by remember { mutableStateOf(true) }
@@ -130,5 +144,6 @@
private companion object {
const val TITLE = "Title"
const val TEXT = "Text"
+ const val CONTENT_DESCRIPTION = "content-description"
}
}
diff --git a/packages/SystemUI/aconfig/cross_device_control.aconfig b/packages/SystemUI/aconfig/cross_device_control.aconfig
new file mode 100644
index 0000000..d3f14c1
--- /dev/null
+++ b/packages/SystemUI/aconfig/cross_device_control.aconfig
@@ -0,0 +1,15 @@
+package: "com.android.systemui"
+
+flag {
+ name: "legacy_le_audio_sharing"
+ namespace: "pixel_cross_device_control"
+ description: "Gates the legacy le audio sharing UI."
+ bug: "322295262"
+}
+
+flag {
+ name: "enable_personal_le_audio_sharing"
+ namespace: "pixel_cross_device_control"
+ description: "Gates the personal le audio sharing UI in UMO."
+ bug: "322295480"
+}
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 0ea2b1f..3db99f28 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -370,3 +370,17 @@
description: "Enables the compose version of keyguard."
bug: "301968149"
}
+
+flag {
+ name: "enable_contextual_tip_for_power_off"
+ namespace: "systemui"
+ description: "Enables on-screen contextual tip about how to power off or restart phone"
+ bug: "322891421"
+}
+
+flag {
+ name: "enable_contextual_tip_for_take_screenshot"
+ namespace: "systemui"
+ description: "Enables on-screen contextual tip about how to take screenshot."
+ bug: "322891421"
+}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateToScene.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateToScene.kt
index 7057545..b9b472f 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateToScene.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateToScene.kt
@@ -30,6 +30,7 @@
internal fun CoroutineScope.animateToScene(
layoutState: BaseSceneTransitionLayoutState,
target: SceneKey,
+ transitionKey: TransitionKey?,
): TransitionState.Transition? {
val transitionState = layoutState.transitionState
if (transitionState.currentScene == target) {
@@ -45,7 +46,7 @@
}
return when (transitionState) {
- is TransitionState.Idle -> animate(layoutState, target)
+ is TransitionState.Idle -> animate(layoutState, target, transitionKey)
is TransitionState.Transition -> {
// A transition is currently running: first check whether `transition.toScene` or
// `transition.fromScene` is the same as our target scene, in which case the transition
@@ -67,7 +68,7 @@
// The transition is in progress: start the canned animation at the same
// progress as it was in.
// TODO(b/290184746): Also take the current velocity into account.
- animate(layoutState, target, startProgress = progress)
+ animate(layoutState, target, transitionKey, startProgress = progress)
}
} else if (transitionState.fromScene == target) {
// There is a transition from [target] to another scene: simply animate the same
@@ -82,12 +83,18 @@
null
} else {
// TODO(b/290184746): Also take the current velocity into account.
- animate(layoutState, target, startProgress = progress, reversed = true)
+ animate(
+ layoutState,
+ target,
+ transitionKey,
+ startProgress = progress,
+ reversed = true,
+ )
}
} else {
// Generic interruption; the current transition is neither from or to [target].
// TODO(b/290930950): Better handle interruptions here.
- animate(layoutState, target)
+ animate(layoutState, target, transitionKey)
}
}
}
@@ -96,6 +103,7 @@
private fun CoroutineScope.animate(
layoutState: BaseSceneTransitionLayoutState,
target: SceneKey,
+ transitionKey: TransitionKey?,
startProgress: Float = 0f,
reversed: Boolean = false,
): TransitionState.Transition {
@@ -127,7 +135,7 @@
// Change the current layout state to start this new transition. This will compute the
// TransformationSpec associated to this transition, which we need to initialize the Animatable
// that will actually animate it.
- layoutState.startTransition(transition)
+ layoutState.startTransition(transition, transitionKey)
// The transformation now contains the spec that we should use to instantiate the Animatable.
val animationSpec = layoutState.transformationSpec.progressSpec
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
index c6851954..2596d4a 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
@@ -55,6 +55,7 @@
// Implementation of [UserActionResult].
override val toScene: SceneKey = this
+ override val transitionKey: TransitionKey? = null
override val distance: UserActionDistance? = null
override fun toString(): String {
@@ -104,3 +105,13 @@
return "ValueKey(debugName=$debugName)"
}
}
+
+/**
+ * Key for a transition. This can be used to specify which transition spec should be used when
+ * starting the transition between two scenes.
+ */
+class TransitionKey(debugName: String, identity: Any = Object()) : Key(debugName, identity) {
+ override fun toString(): String {
+ return "TransitionKey(debugName=$debugName)"
+ }
+}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
index 35754d6..23af5ac 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
@@ -54,7 +54,7 @@
private fun updateTransition(newTransition: SwipeTransition, force: Boolean = false) {
if (isDrivingTransition || force) {
- layoutState.startTransition(newTransition)
+ layoutState.startTransition(newTransition, newTransition.key)
// Initialize SwipeTransition.swipeSpec. Note that this must be called right after
// layoutState.startTransition() is called, because it computes the
@@ -237,7 +237,11 @@
}
swipeTransition.dragOffset += acceleratedOffset
- if (isNewFromScene || result.toScene != swipeTransition.toScene) {
+ if (
+ isNewFromScene ||
+ result.toScene != swipeTransition.toScene ||
+ result.transitionKey != swipeTransition.key
+ ) {
updateTransition(
SwipeTransition(fromScene, result).apply {
this.dragOffset = swipeTransition.dragOffset
@@ -484,6 +488,7 @@
private fun SwipeTransition(fromScene: Scene, result: UserActionResult): SwipeTransition {
return SwipeTransition(
+ result.transitionKey,
fromScene,
layoutImpl.scene(result.toScene),
computeAbsoluteDistance(fromScene, result),
@@ -491,6 +496,7 @@
}
internal class SwipeTransition(
+ val key: TransitionKey?,
val _fromScene: Scene,
val _toScene: Scene,
/**
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
index 7e0aa9c3..5258078 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
@@ -388,8 +388,9 @@
/**
* The result of performing a [UserAction].
*
- * Note: [UserActionResult] is implemented by [SceneKey], and you can also use [withDistance] to
- * easily create a [UserActionResult] with a fixed distance:
+ * Note: [UserActionResult] is implemented by [SceneKey], so you can also use scene keys directly
+ * when defining your [UserActionResult]s.
+ *
* ```
* SceneTransitionLayout(...) {
* scene(
@@ -397,7 +398,7 @@
* userActions =
* mapOf(
* Swipe.Right to Scene.Bar,
- * Swipe.Down to Scene.Doe withDistance 100.dp,
+ * Swipe.Down to Scene.Doe,
* )
* )
* ) { ... }
@@ -408,6 +409,9 @@
/** The scene we should be transitioning to during the [UserAction]. */
val toScene: SceneKey
+ /** The key of the transition that should be used. */
+ val transitionKey: TransitionKey?
+
/**
* The distance the action takes to animate from 0% to 100%.
*
@@ -416,6 +420,32 @@
val distance: UserActionDistance?
}
+/** Create a [UserActionResult] to [toScene] with the given [distance] and [transitionKey]. */
+fun UserActionResult(
+ toScene: SceneKey,
+ distance: UserActionDistance? = null,
+ transitionKey: TransitionKey? = null,
+): UserActionResult {
+ return object : UserActionResult {
+ override val toScene: SceneKey = toScene
+ override val transitionKey: TransitionKey? = transitionKey
+ override val distance: UserActionDistance? = distance
+ }
+}
+
+/** Create a [UserActionResult] to [toScene] with the given fixed [distance] and [transitionKey]. */
+fun UserActionResult(
+ toScene: SceneKey,
+ distance: Dp,
+ transitionKey: TransitionKey? = null,
+): UserActionResult {
+ return UserActionResult(
+ toScene = toScene,
+ distance = FixedDistance(distance),
+ transitionKey = transitionKey,
+ )
+}
+
interface UserActionDistance {
/**
* Return the **absolute** distance of the user action given the size of the scene we are
@@ -424,22 +454,6 @@
fun Density.absoluteDistance(fromSceneSize: IntSize, orientation: Orientation): Float
}
-/**
- * A utility function to make it possible to define user actions with a distance using the syntax
- * `Swipe.Up to Scene.foo withDistance 100.dp`
- */
-infix fun Pair<UserAction, SceneKey>.withDistance(
- distance: Dp
-): Pair<UserAction, UserActionResult> {
- val scene = second
- val distance = FixedDistance(distance)
- return first to
- object : UserActionResult {
- override val toScene: SceneKey = scene
- override val distance: UserActionDistance = distance
- }
-}
-
/** The user action has a fixed [absoluteDistance]. */
private class FixedDistance(private val distance: Dp) : UserActionDistance {
override fun Density.absoluteDistance(fromSceneSize: IntSize, orientation: Orientation): Float {
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
index 956e326..aee6f9e 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
@@ -92,6 +92,7 @@
fun setTargetScene(
targetScene: SceneKey,
coroutineScope: CoroutineScope,
+ transitionKey: TransitionKey? = null,
): TransitionState.Transition?
}
@@ -213,11 +214,14 @@
}
/** Start a new [transition], instantly interrupting any ongoing transition if there was one. */
- internal fun startTransition(transition: TransitionState.Transition) {
+ internal fun startTransition(
+ transition: TransitionState.Transition,
+ transitionKey: TransitionKey?,
+ ) {
// Compute the [TransformationSpec] when the transition starts.
transformationSpec =
transitions
- .transitionSpec(transition.fromScene, transition.toScene)
+ .transitionSpec(transition.fromScene, transition.toScene, key = transitionKey)
.transformationSpec()
transitionState = transition
@@ -265,7 +269,11 @@
// Inspired by AnimateAsState.kt: let's poll the last value to avoid being one frame
// late.
val newKey = targetSceneChannel.tryReceive().getOrNull() ?: newKey
- animateToScene(layoutState = this@HoistedSceneTransitionLayoutScene, newKey)
+ animateToScene(
+ layoutState = this@HoistedSceneTransitionLayoutScene,
+ target = newKey,
+ transitionKey = null,
+ )
}
}
}
@@ -278,14 +286,14 @@
) : MutableSceneTransitionLayoutState, BaseSceneTransitionLayoutState(initialScene) {
override fun setTargetScene(
targetScene: SceneKey,
- coroutineScope: CoroutineScope
+ coroutineScope: CoroutineScope,
+ transitionKey: TransitionKey?,
): TransitionState.Transition? {
- return with(this) {
- coroutineScope.animateToScene(
- layoutState = this@MutableSceneTransitionLayoutStateImpl,
- target = targetScene,
- )
- }
+ return coroutineScope.animateToScene(
+ layoutState = this@MutableSceneTransitionLayoutStateImpl,
+ target = targetScene,
+ transitionKey = transitionKey,
+ )
}
override fun CoroutineScope.onChangeScene(scene: SceneKey) {
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
index ac423b7..b8f9359 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
@@ -42,32 +42,42 @@
internal val defaultSwipeSpec: SpringSpec<Float>,
internal val transitionSpecs: List<TransitionSpecImpl>,
) {
- private val cache = mutableMapOf<SceneKey, MutableMap<SceneKey, TransitionSpecImpl>>()
+ private val cache =
+ mutableMapOf<
+ SceneKey, MutableMap<SceneKey, MutableMap<TransitionKey?, TransitionSpecImpl>>
+ >()
- internal fun transitionSpec(from: SceneKey, to: SceneKey): TransitionSpecImpl {
- return cache.getOrPut(from) { mutableMapOf() }.getOrPut(to) { findSpec(from, to) }
+ internal fun transitionSpec(
+ from: SceneKey,
+ to: SceneKey,
+ key: TransitionKey?,
+ ): TransitionSpecImpl {
+ return cache
+ .getOrPut(from) { mutableMapOf() }
+ .getOrPut(to) { mutableMapOf() }
+ .getOrPut(key) { findSpec(from, to, key) }
}
- private fun findSpec(from: SceneKey, to: SceneKey): TransitionSpecImpl {
- val spec = transition(from, to) { it.from == from && it.to == to }
+ private fun findSpec(from: SceneKey, to: SceneKey, key: TransitionKey?): TransitionSpecImpl {
+ val spec = transition(from, to, key) { it.from == from && it.to == to }
if (spec != null) {
return spec
}
- val reversed = transition(from, to) { it.from == to && it.to == from }
+ val reversed = transition(from, to, key) { it.from == to && it.to == from }
if (reversed != null) {
return reversed.reversed()
}
val relaxedSpec =
- transition(from, to) {
+ transition(from, to, key) {
(it.from == from && it.to == null) || (it.to == to && it.from == null)
}
if (relaxedSpec != null) {
return relaxedSpec
}
- return transition(from, to) {
+ return transition(from, to, key) {
(it.from == to && it.to == null) || (it.to == from && it.from == null)
}
?.reversed()
@@ -77,11 +87,12 @@
private fun transition(
from: SceneKey,
to: SceneKey,
+ key: TransitionKey?,
filter: (TransitionSpecImpl) -> Boolean,
): TransitionSpecImpl? {
var match: TransitionSpecImpl? = null
transitionSpecs.fastForEach { spec ->
- if (filter(spec)) {
+ if (spec.key == key && filter(spec)) {
if (match != null) {
error("Found multiple transition specs for transition $from => $to")
}
@@ -92,7 +103,7 @@
}
private fun defaultTransition(from: SceneKey, to: SceneKey) =
- TransitionSpecImpl(from, to, TransformationSpec.EmptyProvider)
+ TransitionSpecImpl(key = null, from, to, TransformationSpec.EmptyProvider)
companion object {
internal val DefaultSwipeSpec =
@@ -107,6 +118,9 @@
/** The definition of a transition between [from] and [to]. */
interface TransitionSpec {
+ /** The key of this [TransitionSpec]. */
+ val key: TransitionKey?
+
/**
* The scene we are transitioning from. If `null`, this spec can be used to animate from any
* scene.
@@ -164,12 +178,14 @@
}
internal class TransitionSpecImpl(
+ override val key: TransitionKey?,
override val from: SceneKey?,
override val to: SceneKey?,
private val transformationSpec: () -> TransformationSpecImpl,
) : TransitionSpec {
override fun reversed(): TransitionSpecImpl {
return TransitionSpecImpl(
+ key = key,
from = to,
to = from,
transformationSpec = {
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
index 04e0937..d93911d 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
@@ -42,10 +42,14 @@
* any scene. For the animation specification to apply only when transitioning between two
* specific scenes, use [from] instead.
*
+ * If [key] is not `null`, then this transition will only be used if the same key is specified
+ * when triggering the transition.
+ *
* @see from
*/
fun to(
to: SceneKey,
+ key: TransitionKey? = null,
builder: TransitionBuilder.() -> Unit = {},
): TransitionSpec
@@ -55,7 +59,8 @@
* the destination scene via the [to] argument.
*
* When looking up which transition should be used when animating from scene A to scene B, we
- * pick the single transition matching one of these predicates (in order of importance):
+ * pick the single transition with the given [key] and matching one of these predicates (in
+ * order of importance):
* 1. from == A && to == B
* 2. to == A && from == B, which is then treated in reverse.
* 3. (from == A && to == null) || (from == null && to == B)
@@ -64,6 +69,7 @@
fun from(
from: SceneKey,
to: SceneKey? = null,
+ key: TransitionKey? = null,
builder: TransitionBuilder.() -> Unit = {},
): TransitionSpec
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt
index df186a1..9b16d46 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt
@@ -49,21 +49,27 @@
val transitionSpecs = mutableListOf<TransitionSpecImpl>()
- override fun to(to: SceneKey, builder: TransitionBuilder.() -> Unit): TransitionSpec {
- return transition(from = null, to = to, builder)
+ override fun to(
+ to: SceneKey,
+ key: TransitionKey?,
+ builder: TransitionBuilder.() -> Unit
+ ): TransitionSpec {
+ return transition(from = null, to = to, key = key, builder)
}
override fun from(
from: SceneKey,
to: SceneKey?,
+ key: TransitionKey?,
builder: TransitionBuilder.() -> Unit
): TransitionSpec {
- return transition(from = from, to = to, builder)
+ return transition(from = from, to = to, key = key, builder)
}
private fun transition(
from: SceneKey?,
to: SceneKey?,
+ key: TransitionKey?,
builder: TransitionBuilder.() -> Unit,
): TransitionSpec {
fun transformationSpec(): TransformationSpecImpl {
@@ -75,7 +81,7 @@
)
}
- val spec = TransitionSpecImpl(from, to, ::transformationSpec)
+ val spec = TransitionSpecImpl(key, from, to, ::transformationSpec)
transitionSpecs.add(spec)
return spec
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt
index 9a25d43..c61917d 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt
@@ -45,7 +45,10 @@
@Test
fun isTransitioningTo_transition() {
val state = MutableSceneTransitionLayoutStateImpl(TestScenes.SceneA, SceneTransitions.Empty)
- state.startTransition(transition(from = TestScenes.SceneA, to = TestScenes.SceneB))
+ state.startTransition(
+ transition(from = TestScenes.SceneA, to = TestScenes.SceneB),
+ transitionKey = null
+ )
assertThat(state.isTransitioning()).isTrue()
assertThat(state.isTransitioning(from = TestScenes.SceneA)).isTrue()
@@ -116,4 +119,43 @@
testScheduler.advanceUntilIdle()
assertThat(state.transitionState).isEqualTo(TransitionState.Idle(TestScenes.SceneB))
}
+
+ @Test
+ fun setTargetScene_withTransitionKey() = runMonotonicClockTest {
+ val transitionkey = TransitionKey(debugName = "foo")
+ val state =
+ MutableSceneTransitionLayoutState(
+ TestScenes.SceneA,
+ transitions =
+ transitions {
+ from(TestScenes.SceneA, to = TestScenes.SceneB) { fade(TestElements.Foo) }
+ from(TestScenes.SceneA, to = TestScenes.SceneB, key = transitionkey) {
+ fade(TestElements.Foo)
+ fade(TestElements.Bar)
+ }
+ },
+ )
+ as MutableSceneTransitionLayoutStateImpl
+
+ // Default transition from A to B.
+ assertThat(state.setTargetScene(TestScenes.SceneB, coroutineScope = this)).isNotNull()
+ assertThat(state.transformationSpec.transformations).hasSize(1)
+
+ // Go back to A.
+ state.setTargetScene(TestScenes.SceneA, coroutineScope = this)
+ testScheduler.advanceUntilIdle()
+ assertThat(state.currentTransition).isNull()
+ assertThat(state.transitionState.currentScene).isEqualTo(TestScenes.SceneA)
+
+ // Specific transition from A to B.
+ assertThat(
+ state.setTargetScene(
+ TestScenes.SceneB,
+ coroutineScope = this,
+ transitionKey = transitionkey,
+ )
+ )
+ .isNotNull()
+ assertThat(state.transformationSpec.transformations).hasSize(2)
+ }
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
index af1a5b8..543ed04 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
@@ -384,7 +384,13 @@
scene(
TestScenes.SceneA,
userActions =
- mapOf(Swipe.Down to TestScenes.SceneB withDistance verticalSwipeDistance),
+ mapOf(
+ Swipe.Down to
+ UserActionResult(
+ toScene = TestScenes.SceneB,
+ distance = verticalSwipeDistance,
+ )
+ ),
) {
Spacer(Modifier.fillMaxSize())
}
@@ -492,4 +498,54 @@
}
assertThat(layoutState.currentTransition).isNotNull()
}
+
+ @Test
+ fun transitionKey() {
+ val transitionkey = TransitionKey(debugName = "foo")
+ val state =
+ MutableSceneTransitionLayoutState(
+ TestScenes.SceneA,
+ transitions {
+ from(TestScenes.SceneA, to = TestScenes.SceneB) { fade(TestElements.Foo) }
+ from(TestScenes.SceneA, to = TestScenes.SceneB, key = transitionkey) {
+ fade(TestElements.Foo)
+ fade(TestElements.Bar)
+ }
+ }
+ )
+ as MutableSceneTransitionLayoutStateImpl
+
+ var touchSlop = 0f
+ rule.setContent {
+ touchSlop = LocalViewConfiguration.current.touchSlop
+ SceneTransitionLayout(state, Modifier.size(LayoutWidth, LayoutHeight)) {
+ scene(
+ TestScenes.SceneA,
+ userActions =
+ mapOf(
+ Swipe.Down to TestScenes.SceneB,
+ Swipe.Up to
+ UserActionResult(TestScenes.SceneB, transitionKey = transitionkey)
+ )
+ ) {
+ Box(Modifier.fillMaxSize())
+ }
+ scene(TestScenes.SceneB) { Box(Modifier.fillMaxSize()) }
+ }
+ }
+
+ // Swipe down for the default transition from A to B.
+ rule.onRoot().performTouchInput {
+ down(middle)
+ moveBy(Offset(0f, touchSlop), delayMillis = 1_000)
+ }
+
+ assertThat(state.isTransitioning(from = TestScenes.SceneA, to = TestScenes.SceneB)).isTrue()
+ assertThat(state.transformationSpec.transformations).hasSize(1)
+
+ // Move the pointer up to swipe to scene B using the new transition.
+ rule.onRoot().performTouchInput { moveBy(Offset(0f, -1.dp.toPx()), delayMillis = 1_000) }
+ assertThat(state.isTransitioning(from = TestScenes.SceneA, to = TestScenes.SceneB)).isTrue()
+ assertThat(state.transformationSpec.transformations).hasSize(2)
+ }
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt
index 140baca..1beafcc 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt
@@ -177,7 +177,7 @@
// to B we defined.
val transformations =
transitions
- .transitionSpec(from = TestScenes.SceneB, to = TestScenes.SceneA)
+ .transitionSpec(from = TestScenes.SceneB, to = TestScenes.SceneA, key = null)
.transformationSpec()
.transformations
@@ -207,7 +207,7 @@
// A => B does not have a custom spec.
assertThat(
transitions
- .transitionSpec(from = TestScenes.SceneA, to = TestScenes.SceneB)
+ .transitionSpec(from = TestScenes.SceneA, to = TestScenes.SceneB, key = null)
.transformationSpec()
.swipeSpec
)
@@ -216,7 +216,7 @@
// A => C has a custom swipe spec.
assertThat(
transitions
- .transitionSpec(from = TestScenes.SceneA, to = TestScenes.SceneC)
+ .transitionSpec(from = TestScenes.SceneA, to = TestScenes.SceneC, key = null)
.transformationSpec()
.swipeSpec
)
diff --git a/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt b/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt
index 6d6d575..2d71a6e 100644
--- a/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt
+++ b/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt
@@ -89,7 +89,7 @@
SceneTransitionLayout(
currentScene,
onChangeScene,
- transitions { from(fromScene, to = toScene, transition) },
+ transitions { from(fromScene, to = toScene, builder = transition) },
layoutModifier,
) {
scene(fromScene, content = fromSceneContent)
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java
index 5d85fba..c9e2989 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java
@@ -264,15 +264,18 @@
}
}
- @ProvidesInterface(version = BooleanState.VERSION)
- public static class BooleanState extends State {
+ /**
+ * Distinguished from [BooleanState] for use-case purposes such as allowing null secondary label
+ */
+ @ProvidesInterface(version = AdapterState.VERSION)
+ class AdapterState extends State {
public static final int VERSION = 1;
public boolean value;
public boolean forceExpandIcon;
@Override
public boolean copyTo(State other) {
- final BooleanState o = (BooleanState) other;
+ final AdapterState o = (AdapterState) other;
final boolean changed = super.copyTo(other)
|| o.value != value
|| o.forceExpandIcon != forceExpandIcon;
@@ -291,6 +294,18 @@
@Override
public State copy() {
+ AdapterState state = new AdapterState();
+ copyTo(state);
+ return state;
+ }
+ }
+
+ @ProvidesInterface(version = BooleanState.VERSION)
+ class BooleanState extends AdapterState {
+ public static final int VERSION = 1;
+
+ @Override
+ public State copy() {
BooleanState state = new BooleanState();
copyTo(state);
return state;
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index fa89fcd..33bdca3 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -903,6 +903,10 @@
Keep it the same as in Launcher-->
<dimen name="communal_enforced_rounded_corner_max_radius">16dp</dimen>
+ <!-- Width and height used to filter widgets displayed in the communal widget picker -->
+ <dimen name="communal_widget_picker_desired_width">464dp</dimen>
+ <dimen name="communal_widget_picker_desired_height">307dp</dimen>
+
<!-- The width/height of the unlock icon view on keyguard. -->
<dimen name="keyguard_lock_height">42dp</dimen>
<dimen name="keyguard_lock_padding">20dp</dimen>
diff --git a/packages/SystemUI/shared/Android.bp b/packages/SystemUI/shared/Android.bp
index 326c7ef..4e04af6 100644
--- a/packages/SystemUI/shared/Android.bp
+++ b/packages/SystemUI/shared/Android.bp
@@ -53,6 +53,7 @@
"SystemUIPluginLib",
"SystemUIUnfoldLib",
"SystemUISharedLib-Keyguard",
+ "WindowManager-Shell-shared",
"tracinglib",
"androidx.dynamicanimation_dynamicanimation",
"androidx.concurrent_concurrent-futures",
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java
index 88b9c02..a78080f 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java
@@ -38,7 +38,7 @@
import android.window.IRemoteTransitionFinishedCallback;
import android.window.TransitionInfo;
-import com.android.wm.shell.util.CounterRotator;
+import com.android.wm.shell.shared.CounterRotator;
public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner.Stub {
private static final String TAG = "RemoteAnimRunnerCompat";
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java
index d4ac195..e4d9243 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java
@@ -22,7 +22,7 @@
import android.window.TransitionInfo;
import android.window.TransitionInfo.Change;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
import java.util.ArrayList;
import java.util.function.Predicate;
diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
index 82410fd..91e6b62 100644
--- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
+++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
@@ -39,7 +39,7 @@
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.DisplaySpecific
import com.android.systemui.dagger.qualifiers.Main
-import com.android.systemui.flags.FeatureFlags
+import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags.REGION_SAMPLING
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -47,7 +47,6 @@
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.log.core.Logger
-import com.android.systemui.log.core.LogLevel.DEBUG
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceController
import com.android.systemui.plugins.clocks.ClockMessageBuffers
@@ -92,7 +91,7 @@
@Main private val mainExecutor: DelayableExecutor,
@Background private val bgExecutor: Executor,
private val clockBuffers: ClockMessageBuffers,
- private val featureFlags: FeatureFlags,
+ private val featureFlags: FeatureFlagsClassic,
private val zenModeController: ZenModeController,
) {
var loggers = listOf(
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
index ad30317..28013c6 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
@@ -196,6 +196,9 @@
mSmallClockFrame = findViewById(R.id.lockscreen_clock_view);
mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large);
mStatusArea = findViewById(R.id.keyguard_status_area);
+ } else {
+ removeView(findViewById(R.id.lockscreen_clock_view));
+ removeView(findViewById(R.id.lockscreen_clock_view_large));
}
onConfigChanged();
}
@@ -263,6 +266,9 @@
}
void updateClockTargetRegions() {
+ if (migrateClocksToBlueprint()) {
+ return;
+ }
if (mClock != null) {
if (mSmallClockFrame.isLaidOut()) {
Rect targetRegion = getSmallClockRegion(mSmallClockFrame);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index de7c12d..2db3795 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -246,8 +246,11 @@
protected void onInit() {
mKeyguardSliceViewController.init();
- mSmallClockFrame = mView.findViewById(R.id.lockscreen_clock_view);
- mLargeClockFrame = mView.findViewById(R.id.lockscreen_clock_view_large);
+ if (!migrateClocksToBlueprint()) {
+ mSmallClockFrame = mView.findViewById(R.id.lockscreen_clock_view);
+ mLargeClockFrame = mView.findViewById(R.id.lockscreen_clock_view_large);
+ }
+
if (!mOnlyClock) {
mDumpManager.unregisterDumpable(getClass().getSimpleName()); // unregister previous
@@ -526,13 +529,15 @@
*/
void updatePosition(int x, float scale, AnimationProperties props, boolean animate) {
x = getCurrentLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -x : x;
+ if (!migrateClocksToBlueprint()) {
+ PropertyAnimator.setProperty(mSmallClockFrame, AnimatableProperty.TRANSLATION_X,
+ x, props, animate);
+ PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_X,
+ scale, props, animate);
+ PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
+ scale, props, animate);
- PropertyAnimator.setProperty(mSmallClockFrame, AnimatableProperty.TRANSLATION_X,
- x, props, animate);
- PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_X,
- scale, props, animate);
- PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
- scale, props, animate);
+ }
if (mStatusArea != null) {
PropertyAnimator.setProperty(mStatusArea, KeyguardStatusAreaView.TRANSLATE_X_AOD,
@@ -550,6 +555,10 @@
return 0;
}
+ if (migrateClocksToBlueprint()) {
+ return 0;
+ }
+
if (mLargeClockFrame.getVisibility() == View.VISIBLE) {
// This gets the expected clock bottom if mLargeClockFrame had a top margin, but it's
// top margin only contributed to height and didn't move the top of the view (as this
@@ -581,6 +590,9 @@
}
boolean isClockTopAligned() {
+ if (migrateClocksToBlueprint()) {
+ return mKeyguardClockInteractor.getClockSize().getValue() == LARGE;
+ }
return mLargeClockFrame.getVisibility() != View.VISIBLE;
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractor.kt
index 70be0f2..a742c0e 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractor.kt
@@ -19,22 +19,15 @@
import android.hardware.biometrics.AuthenticateOptions
import android.hardware.biometrics.IBiometricContextListener
import android.util.Log
-import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
-import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.keyguard.WakefulnessLifecycle
+import com.android.systemui.display.data.repository.DeviceStateRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
-import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_CLOSED
-import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_FULL_OPEN
-import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_HALF_OPEN
-import com.android.systemui.unfold.updates.FoldStateProvider
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
-import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.catch
@@ -80,15 +73,11 @@
@Inject
constructor(
@Application private val applicationScope: CoroutineScope,
- private val foldProvider: FoldStateProvider,
+ deviceStateRepository: DeviceStateRepository,
keyguardTransitionInteractor: KeyguardTransitionInteractor,
udfpsOverlayInteractor: UdfpsOverlayInteractor,
) : LogContextInteractor {
- init {
- applicationScope.launch { foldProvider.start() }
- }
-
override val displayState =
keyguardTransitionInteractor.startedKeyguardTransitionStep.map {
when (it.to) {
@@ -123,32 +112,21 @@
.distinctUntilChanged()
override val foldState: Flow<Int> =
- conflatedCallbackFlow {
- val callback =
- object : FoldStateProvider.FoldUpdatesListener {
- override fun onHingeAngleUpdate(angle: Float) {}
-
- override fun onFoldUpdate(@FoldStateProvider.FoldUpdate update: Int) {
- val loggedState =
- when (update) {
- FOLD_UPDATE_FINISH_HALF_OPEN ->
- IBiometricContextListener.FoldState.HALF_OPENED
- FOLD_UPDATE_FINISH_FULL_OPEN ->
- IBiometricContextListener.FoldState.FULLY_OPENED
- FOLD_UPDATE_FINISH_CLOSED ->
- IBiometricContextListener.FoldState.FULLY_CLOSED
- else -> null
- }
- if (loggedState != null) {
- trySendWithFailureLogging(loggedState, TAG)
- }
- }
- }
-
- foldProvider.addCallback(callback)
- trySendWithFailureLogging(IBiometricContextListener.FoldState.UNKNOWN, TAG)
- awaitClose { foldProvider.removeCallback(callback) }
+ deviceStateRepository.state
+ .map {
+ when (it) {
+ DeviceStateRepository.DeviceState.UNFOLDED,
+ DeviceStateRepository.DeviceState.REAR_DISPLAY,
+ DeviceStateRepository.DeviceState.CONCURRENT_DISPLAY ->
+ IBiometricContextListener.FoldState.FULLY_OPENED
+ DeviceStateRepository.DeviceState.FOLDED ->
+ IBiometricContextListener.FoldState.FULLY_CLOSED
+ DeviceStateRepository.DeviceState.HALF_FOLDED ->
+ IBiometricContextListener.FoldState.HALF_OPENED
+ else -> IBiometricContextListener.FoldState.UNKNOWN
+ }
}
+ .distinctUntilChanged()
.shareIn(applicationScope, started = SharingStarted.Eagerly, replay = 1)
override fun addBiometricContextListener(listener: IBiometricContextListener): Job {
@@ -178,6 +156,3 @@
private const val TAG = "ContextRepositoryImpl"
}
}
-
-private val WakefulnessLifecycle.isAwake: Boolean
- get() = wakefulness == WakefulnessLifecycle.WAKEFULNESS_AWAKE
diff --git a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt
index 54c709d..eb6dc43 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/widgets/EditWidgetsActivity.kt
@@ -32,6 +32,7 @@
import com.android.systemui.communal.shared.model.CommunalSceneKey
import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel
import com.android.systemui.compose.ComposeFacade.setCommunalEditWidgetActivityContent
+import com.android.systemui.res.R
import javax.inject.Inject
/** An Activity for editing the widgets that appear in hub mode. */
@@ -45,8 +46,10 @@
) : ComponentActivity() {
companion object {
private const val EXTRA_IS_PENDING_WIDGET_DRAG = "is_pending_widget_drag"
- private const val EXTRA_FILTER_STRATEGY = "filter_strategy"
- private const val FILTER_STRATEGY_GLANCEABLE_HUB = 1
+ private const val EXTRA_DESIRED_WIDGET_WIDTH = "desired_widget_width"
+
+ private const val EXTRA_DESIRED_WIDGET_HEIGHT = "desired_widget_height"
+
private const val TAG = "EditWidgetsActivity"
const val EXTRA_PRESELECTED_KEY = "preselected_key"
}
@@ -111,11 +114,19 @@
?.let { packageName ->
try {
addWidgetActivityLauncher.launch(
- Intent(Intent.ACTION_PICK).also {
- it.setPackage(packageName)
- it.putExtra(
- EXTRA_FILTER_STRATEGY,
- FILTER_STRATEGY_GLANCEABLE_HUB
+ Intent(Intent.ACTION_PICK).apply {
+ setPackage(packageName)
+ putExtra(
+ EXTRA_DESIRED_WIDGET_WIDTH,
+ resources.getDimensionPixelSize(
+ R.dimen.communal_widget_picker_desired_width
+ )
+ )
+ putExtra(
+ EXTRA_DESIRED_WIDGET_HEIGHT,
+ resources.getDimensionPixelSize(
+ R.dimen.communal_widget_picker_desired_height
+ )
)
}
)
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt b/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt
index 26e83a3..f16a3bd 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/PhysicalKeyboardCoreStartable.kt
@@ -17,7 +17,7 @@
package com.android.systemui.keyboard
-import com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag
+import android.hardware.input.InputSettings
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
@@ -40,7 +40,7 @@
if (featureFlags.isEnabled(Flags.KEYBOARD_BACKLIGHT_INDICATOR)) {
keyboardBacklightDialogCoordinator.get().startListening()
}
- if (keyboardA11yStickyKeysFlag()) {
+ if (InputSettings.isAccessibilityStickyKeysFeatureEnabled()) {
stickyKeysIndicatorCoordinator.get().startListening()
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinator.kt b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinator.kt
index b68551b..c3a618d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/stickykeys/ui/StickyKeysIndicatorCoordinator.kt
@@ -58,7 +58,6 @@
dialog = null
} else if (dialog == null) {
dialog = ComposeFacade.createStickyKeysDialog(dialogFactory, viewModel).apply {
- setCanceledOnTouchOutside(false)
window?.setAttributes()
show()
}
@@ -70,6 +69,7 @@
private fun Window.setAttributes() {
setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL)
addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
+ addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
setGravity(Gravity.TOP or Gravity.END)
attributes = WindowManager.LayoutParams().apply {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index f10b87e..b5f9c69 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -85,10 +85,10 @@
import com.android.systemui.power.domain.interactor.PowerInteractor;
import com.android.systemui.power.shared.model.ScreenPowerState;
import com.android.systemui.settings.DisplayTracker;
+import com.android.wm.shell.shared.CounterRotator;
+import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.transition.ShellTransitions;
import com.android.wm.shell.transition.Transitions;
-import com.android.wm.shell.util.CounterRotator;
-import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList;
import java.util.Map;
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
index afef875..7f43fac 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
@@ -41,6 +41,7 @@
import com.android.systemui.keyguard.ui.view.layout.KeyguardBlueprintCommandListener
import com.android.systemui.keyguard.ui.viewmodel.AodAlphaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardIndicationAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.OccludingAppDeviceEntryMessageViewModel
@@ -86,6 +87,7 @@
private val vibratorHelper: VibratorHelper,
private val falsingManager: FalsingManager,
private val aodAlphaViewModel: AodAlphaViewModel,
+ private val keyguardClockViewModel: KeyguardClockViewModel,
) : CoreStartable {
private var rootViewHandle: DisposableHandle? = null
@@ -113,7 +115,11 @@
initializeViews()
if (!SceneContainerFlag.isEnabled) {
- KeyguardBlueprintViewBinder.bind(keyguardRootView, keyguardBlueprintViewModel)
+ KeyguardBlueprintViewBinder.bind(
+ keyguardRootView,
+ keyguardBlueprintViewModel,
+ keyguardClockViewModel
+ )
}
keyguardBlueprintCommandListener.start()
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepository.kt
index 48b6634..9381830 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepository.kt
@@ -23,6 +23,8 @@
import com.android.systemui.keyguard.shared.model.KeyguardBlueprint
import com.android.systemui.keyguard.ui.view.layout.blueprints.DefaultKeyguardBlueprint.Companion.DEFAULT
import com.android.systemui.keyguard.ui.view.layout.blueprints.KeyguardBlueprintModule
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType.DefaultTransition
import java.io.PrintWriter
import java.util.TreeMap
import javax.inject.Inject
@@ -54,6 +56,8 @@
TreeMap<String, KeyguardBlueprint>().apply { putAll(blueprints.associateBy { it.id }) }
val blueprint: MutableStateFlow<KeyguardBlueprint> = MutableStateFlow(blueprintIdMap[DEFAULT]!!)
val refreshBluePrint: MutableSharedFlow<Unit> = MutableSharedFlow(extraBufferCapacity = 1)
+ val refreshBlueprintTransition: MutableSharedFlow<IntraBlueprintTransitionType> =
+ MutableSharedFlow(extraBufferCapacity = 1)
val configurationChange: Flow<Unit> = configurationRepository.onAnyConfigurationChange
/**
@@ -103,7 +107,12 @@
/** Re-emits the last emitted blueprint value if possible. */
fun refreshBlueprint() {
+ refreshBlueprintWithTransition(DefaultTransition)
+ }
+
+ fun refreshBlueprintWithTransition(type: IntraBlueprintTransitionType = DefaultTransition) {
refreshBluePrint.tryEmit(Unit)
+ refreshBlueprintTransition.tryEmit(type)
}
/** Prints all available blueprints to the PrintWriter. */
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt
index ba44e68..566e006 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt
@@ -24,12 +24,13 @@
import com.android.systemui.keyguard.shared.model.KeyguardBlueprint
import com.android.systemui.keyguard.ui.view.layout.blueprints.DefaultKeyguardBlueprint
import com.android.systemui.keyguard.ui.view.layout.blueprints.SplitShadeKeyguardBlueprint
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType.DefaultTransition
import com.android.systemui.statusbar.policy.SplitShadeStateController
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.merge
+import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
@@ -48,13 +49,15 @@
*
* This flow can also emit the same blueprint value if refreshBlueprint is emitted.
*/
- val blueprint: Flow<KeyguardBlueprint> =
- merge(
- keyguardBlueprintRepository.blueprint,
- keyguardBlueprintRepository.refreshBluePrint.map {
- keyguardBlueprintRepository.blueprint.value
- }
- )
+ val blueprint: Flow<KeyguardBlueprint> = keyguardBlueprintRepository.blueprint
+
+ val blueprintWithTransition =
+ combine(
+ keyguardBlueprintRepository.refreshBluePrint,
+ keyguardBlueprintRepository.refreshBlueprintTransition
+ ) { _, source ->
+ source
+ }
init {
applicationScope.launch {
@@ -107,6 +110,10 @@
keyguardBlueprintRepository.refreshBlueprint()
}
+ fun refreshBlueprintWithTransition(type: IntraBlueprintTransitionType = DefaultTransition) {
+ keyguardBlueprintRepository.refreshBlueprintWithTransition(type)
+ }
+
fun getCurrentBlueprint(): KeyguardBlueprint {
return keyguardBlueprintRepository.blueprint.value
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt
index 8d6493f..404046b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt
@@ -26,7 +26,10 @@
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.Flags.keyguardBottomAreaRefactor
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.BaseBlueprintTransition
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransition
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import kotlinx.coroutines.launch
@@ -34,7 +37,11 @@
companion object {
private const val TAG = "KeyguardBlueprintViewBinder"
- fun bind(constraintLayout: ConstraintLayout, viewModel: KeyguardBlueprintViewModel) {
+ fun bind(
+ constraintLayout: ConstraintLayout,
+ viewModel: KeyguardBlueprintViewModel,
+ clockViewModel: KeyguardClockViewModel
+ ) {
constraintLayout.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.CREATED) {
launch {
@@ -42,6 +49,7 @@
val prevBluePrint = viewModel.currentBluePrint
Trace.beginSection("KeyguardBlueprint#applyBlueprint")
Log.d(TAG, "applying blueprint: $blueprint")
+ TransitionManager.endTransitions(constraintLayout)
val cs =
ConstraintSet().apply {
@@ -54,11 +62,28 @@
}
// Apply transition.
- if (!keyguardBottomAreaRefactor() && prevBluePrint != null &&
- prevBluePrint != blueprint) {
+ if (
+ !keyguardBottomAreaRefactor() &&
+ prevBluePrint != null &&
+ prevBluePrint != blueprint
+ ) {
TransitionManager.beginDelayedTransition(
constraintLayout,
- BaseBlueprintTransition()
+ BaseBlueprintTransition(clockViewModel)
+ .addTransition(
+ IntraBlueprintTransition(
+ IntraBlueprintTransitionType.NoTransition,
+ clockViewModel
+ )
+ )
+ )
+ } else {
+ TransitionManager.beginDelayedTransition(
+ constraintLayout,
+ IntraBlueprintTransition(
+ IntraBlueprintTransitionType.NoTransition,
+ clockViewModel
+ )
)
}
@@ -71,6 +96,25 @@
Trace.endSection()
}
}
+
+ launch {
+ viewModel.blueprintWithTransition.collect { source ->
+ TransitionManager.endTransitions(constraintLayout)
+
+ val cs =
+ ConstraintSet().apply {
+ clone(constraintLayout)
+ viewModel.currentBluePrint?.applyConstraints(this)
+ }
+
+ TransitionManager.beginDelayedTransition(
+ constraintLayout,
+ IntraBlueprintTransition(source, clockViewModel)
+ )
+ cs.applyTo(constraintLayout)
+ Trace.endSection()
+ }
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
index 3c3ebdf..f0e89f9 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
@@ -16,34 +16,30 @@
package com.android.systemui.keyguard.ui.binder
-import android.animation.Animator
-import android.animation.ValueAnimator
-import android.transition.Transition
import android.transition.TransitionManager
import android.transition.TransitionSet
-import android.transition.TransitionValues
-import android.view.ViewGroup
+import android.util.Log
+import android.view.View.INVISIBLE
import androidx.annotation.VisibleForTesting
import androidx.constraintlayout.helper.widget.Layer
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
-import com.android.app.animation.Interpolators
import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.keyguard.KeyguardClockSwitch.SMALL
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType
import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.res.R
+import com.android.systemui.shared.clocks.DEFAULT_CLOCK_ID
import kotlinx.coroutines.launch
-private const val KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION_MS = 1000L
-
object KeyguardClockViewBinder {
@JvmStatic
fun bind(
@@ -67,32 +63,56 @@
viewModel.clock = currentClock
addClockViews(currentClock, keyguardRootView)
updateBurnInLayer(keyguardRootView, viewModel)
- blueprintInteractor.refreshBlueprint()
+ applyConstraints(clockSection, keyguardRootView, true)
}
}
launch {
if (!migrateClocksToBlueprint()) return@launch
viewModel.clockSize.collect {
updateBurnInLayer(keyguardRootView, viewModel)
- blueprintInteractor.refreshBlueprint()
+ blueprintInteractor.refreshBlueprintWithTransition(
+ IntraBlueprintTransitionType.ClockSize
+ )
}
}
launch {
if (!migrateClocksToBlueprint()) return@launch
- viewModel.clockShouldBeCentered.collect {
+ viewModel.clockShouldBeCentered.collect { clockShouldBeCentered ->
+ Log.d(
+ "ClockViewBinder",
+ "Sherry clockShouldBeCentered $clockShouldBeCentered"
+ )
viewModel.clock?.let {
- if (it.largeClock.config.hasCustomPositionUpdatedAnimation) {
- playClockCenteringAnimation(clockSection, keyguardRootView, it)
+ // Weather clock also has hasCustomPositionUpdatedAnimation as true
+ // TODO(b/323020908): remove ID check
+ if (
+ it.largeClock.config.hasCustomPositionUpdatedAnimation &&
+ it.config.id == DEFAULT_CLOCK_ID
+ ) {
+ blueprintInteractor.refreshBlueprintWithTransition(
+ IntraBlueprintTransitionType.DefaultClockStepping
+ )
} else {
- blueprintInteractor.refreshBlueprint()
+ blueprintInteractor.refreshBlueprintWithTransition(
+ IntraBlueprintTransitionType.DefaultTransition
+ )
}
}
}
}
launch {
if (!migrateClocksToBlueprint()) return@launch
- viewModel.isAodIconsVisible.collect {
- applyConstraints(clockSection, keyguardRootView, true)
+ viewModel.isAodIconsVisible.collect { isAodIconsVisible ->
+ viewModel.clock?.let {
+ // Weather clock also has hasCustomPositionUpdatedAnimation as true
+ if (
+ viewModel.useLargeClock && it.config.id == "DIGITAL_CLOCK_WEATHER"
+ ) {
+ blueprintInteractor.refreshBlueprintWithTransition(
+ IntraBlueprintTransitionType.DefaultTransition
+ )
+ }
+ }
}
}
}
@@ -155,7 +175,9 @@
}
// small clock should either be a single view or container with id
// `lockscreen_clock_view`
- clock.smallClock.layout.views.forEach { rootView.addView(it) }
+ clock.smallClock.layout.views.forEach {
+ rootView.addView(it).apply { it.visibility = INVISIBLE }
+ }
clock.largeClock.layout.views.forEach { rootView.addView(it) }
}
}
@@ -173,74 +195,4 @@
}
constraintSet.applyTo(rootView)
}
-
- private fun playClockCenteringAnimation(
- clockSection: ClockSection,
- keyguardRootView: ConstraintLayout,
- clock: ClockController,
- ) {
- // Find the clock, so we can exclude it from this transition.
- val clockView = clock.largeClock.view
- val set = TransitionSet()
- val adapter = SplitShadeTransitionAdapter(clock)
- adapter.setInterpolator(Interpolators.LINEAR)
- adapter.setDuration(KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION_MS)
- adapter.addTarget(clockView)
- set.addTransition(adapter)
- applyConstraints(clockSection, keyguardRootView, true, set)
- }
-
- internal class SplitShadeTransitionAdapter
- @VisibleForTesting
- constructor(private val clock: ClockController) : Transition() {
- private fun captureValues(transitionValues: TransitionValues) {
- transitionValues.values[PROP_BOUNDS_LEFT] = transitionValues.view.left
- val locationInWindowTmp = IntArray(2)
- transitionValues.view.getLocationInWindow(locationInWindowTmp)
- transitionValues.values[PROP_X_IN_WINDOW] = locationInWindowTmp[0]
- }
-
- override fun captureEndValues(transitionValues: TransitionValues) {
- captureValues(transitionValues)
- }
-
- override fun captureStartValues(transitionValues: TransitionValues) {
- captureValues(transitionValues)
- }
-
- override fun createAnimator(
- sceneRoot: ViewGroup,
- startValues: TransitionValues?,
- endValues: TransitionValues?
- ): Animator? {
- if (startValues == null || endValues == null) {
- return null
- }
- val anim = ValueAnimator.ofFloat(0f, 1f)
- val fromLeft = startValues.values[PROP_BOUNDS_LEFT] as Int
- val fromWindowX = startValues.values[PROP_X_IN_WINDOW] as Int
- val toWindowX = endValues.values[PROP_X_IN_WINDOW] as Int
- // Using windowX, to determine direction, instead of left, as in RTL the difference of
- // toLeft - fromLeft is always positive, even when moving left.
- val direction = if (toWindowX - fromWindowX > 0) 1 else -1
- anim.addUpdateListener { animation: ValueAnimator ->
- clock.largeClock.animations.onPositionUpdated(
- fromLeft,
- direction,
- animation.animatedFraction
- )
- }
- return anim
- }
-
- override fun getTransitionProperties(): Array<String> {
- return TRANSITION_PROPERTIES
- }
-
- companion object {
- private const val PROP_BOUNDS_LEFT = "splitShadeTransitionAdapter:boundsLeft"
- private const val PROP_X_IN_WINDOW = "splitShadeTransitionAdapter:xInWindow"
- private val TRANSITION_PROPERTIES = arrayOf(PROP_BOUNDS_LEFT, PROP_X_IN_WINDOW)
- }
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
index 10392e3..08a2b9c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
@@ -49,14 +49,15 @@
clockViewModel,
smartspaceViewModel
)
- blueprintInteractor.refreshBlueprint()
+ blueprintInteractor.refreshBlueprintWithTransition()
}
}
launch {
+ if (!migrateClocksToBlueprint()) return@launch
smartspaceViewModel.bcSmartspaceVisibility.collect {
updateBCSmartspaceInBurnInLayer(keyguardRootView, clockViewModel)
- blueprintInteractor.refreshBlueprint()
+ blueprintInteractor.refreshBlueprintWithTransition()
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt
index fd530b7..9c9df80 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/BaseBlueprintTransition.kt
@@ -19,30 +19,32 @@
import android.animation.Animator
import android.animation.ObjectAnimator
import android.transition.ChangeBounds
+import android.transition.Transition
import android.transition.TransitionSet
import android.transition.TransitionValues
import android.transition.Visibility
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.helper.widget.Layer
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
-import com.android.systemui.res.R
-class BaseBlueprintTransition : TransitionSet() {
+class BaseBlueprintTransition(val clockViewModel: KeyguardClockViewModel) : TransitionSet() {
init {
ordering = ORDERING_SEQUENTIAL
addTransition(AlphaOutVisibility())
.addTransition(ChangeBounds())
.addTransition(AlphaInVisibility())
excludeTarget(Layer::class.java, /* exclude= */ true)
- excludeClockAndSmartspaceViews()
+ excludeClockAndSmartspaceViews(this)
}
- private fun excludeClockAndSmartspaceViews() {
- excludeTarget(R.id.lockscreen_clock_view, true)
- excludeTarget(R.id.lockscreen_clock_view_large, true)
- excludeTarget(SmartspaceView::class.java, true)
- // TODO(b/319468190): need to exclude views from large weather clock
+ private fun excludeClockAndSmartspaceViews(transition: Transition) {
+ transition.excludeTarget(SmartspaceView::class.java, true)
+ clockViewModel.clock?.let { clock ->
+ clock.largeClock.layout.views.forEach { view -> transition.excludeTarget(view, true) }
+ clock.smallClock.layout.views.forEach { view -> transition.excludeTarget(view, true) }
+ }
}
class AlphaOutVisibility : Visibility() {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/IntraBlueprintTransition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/IntraBlueprintTransition.kt
new file mode 100644
index 0000000..524aa1a
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/transitions/IntraBlueprintTransition.kt
@@ -0,0 +1,45 @@
+/*
+ * 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.keyguard.ui.view.layout.blueprints.transitions
+
+import android.transition.TransitionSet
+import com.android.systemui.keyguard.ui.view.layout.sections.transitions.ClockSizeTransition
+import com.android.systemui.keyguard.ui.view.layout.sections.transitions.DefaultClockSteppingTransition
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
+
+enum class IntraBlueprintTransitionType {
+ ClockSize,
+ ClockCenter,
+ DefaultClockStepping,
+ DefaultTransition,
+ AodNotifIconsTransition,
+ // When transition between blueprint, we don't need any duration or interpolator but we need
+ // all elements go to correct state
+ NoTransition,
+}
+
+class IntraBlueprintTransition(
+ type: IntraBlueprintTransitionType,
+ clockViewModel: KeyguardClockViewModel
+) : TransitionSet() {
+ init {
+ ordering = ORDERING_TOGETHER
+ if (type == IntraBlueprintTransitionType.DefaultClockStepping)
+ addTransition(clockViewModel.clock?.let { DefaultClockSteppingTransition(it) })
+ addTransition(ClockSizeTransition(type, clockViewModel))
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
index fe4f07d..b1178f5 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
@@ -166,10 +166,7 @@
context.resources.getDimensionPixelSize(R.dimen.keyguard_smartspace_top_offset)
largeClockTopMargin += getDimen(DATE_WEATHER_VIEW_HEIGHT)
largeClockTopMargin += getDimen(ENHANCED_SMARTSPACE_HEIGHT)
- if (!keyguardClockViewModel.useLargeClock) {
- largeClockTopMargin -=
- context.resources.getDimensionPixelSize(customizationR.dimen.small_clock_height)
- }
+
connect(R.id.lockscreen_clock_view_large, TOP, PARENT_ID, TOP, largeClockTopMargin)
constrainHeight(R.id.lockscreen_clock_view_large, WRAP_CONTENT)
constrainWidth(R.id.lockscreen_clock_view_large, WRAP_CONTENT)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt
new file mode 100644
index 0000000..99565b1
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt
@@ -0,0 +1,196 @@
+/*
+ * 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.keyguard.ui.view.layout.sections.transitions
+
+import android.animation.Animator
+import android.animation.ObjectAnimator
+import android.transition.ChangeBounds
+import android.transition.TransitionSet
+import android.transition.TransitionValues
+import android.transition.Visibility
+import android.view.View
+import android.view.ViewGroup
+import com.android.app.animation.Interpolators
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
+import com.android.systemui.res.R
+import com.android.systemui.shared.R as sharedR
+
+const val CLOCK_OUT_MILLIS = 133L
+const val CLOCK_IN_MILLIS = 167L
+val CLOCK_IN_INTERPOLATOR = Interpolators.LINEAR_OUT_SLOW_IN
+const val CLOCK_IN_START_DELAY_MILLIS = 133L
+val CLOCK_OUT_INTERPOLATOR = Interpolators.LINEAR
+
+class ClockSizeTransition(
+ val type: IntraBlueprintTransitionType,
+ clockViewModel: KeyguardClockViewModel
+) : TransitionSet() {
+ init {
+ ordering = ORDERING_TOGETHER
+ addTransition(ClockOutTransition(clockViewModel, type))
+ addTransition(ClockInTransition(clockViewModel, type))
+ addTransition(SmartspaceChangeBounds(clockViewModel, type))
+ addTransition(ClockInChangeBounds(clockViewModel, type))
+ addTransition(ClockOutChangeBounds(clockViewModel, type))
+ }
+
+ class ClockInTransition(viewModel: KeyguardClockViewModel, type: IntraBlueprintTransitionType) :
+ Visibility() {
+ init {
+ mode = MODE_IN
+ if (type != IntraBlueprintTransitionType.NoTransition) {
+ duration = CLOCK_IN_MILLIS
+ startDelay = CLOCK_IN_START_DELAY_MILLIS
+ interpolator = Interpolators.LINEAR_OUT_SLOW_IN
+ } else {
+ duration = 0
+ startDelay = 0
+ }
+
+ addTarget(sharedR.id.bc_smartspace_view)
+ addTarget(sharedR.id.date_smartspace_view)
+ addTarget(sharedR.id.weather_smartspace_view)
+ if (viewModel.useLargeClock) {
+ viewModel.clock?.let { it.largeClock.layout.views.forEach { addTarget(it) } }
+ } else {
+ addTarget(R.id.lockscreen_clock_view)
+ }
+ }
+
+ override fun onAppear(
+ sceneRoot: ViewGroup?,
+ view: View,
+ startValues: TransitionValues?,
+ endValues: TransitionValues?
+ ): Animator {
+ return ObjectAnimator.ofFloat(view, "alpha", 1f).also {
+ it.duration = duration
+ it.startDelay = startDelay
+ it.interpolator = interpolator
+ it.addUpdateListener { view.alpha = it.animatedValue as Float }
+ it.start()
+ }
+ }
+ }
+
+ class ClockOutTransition(
+ viewModel: KeyguardClockViewModel,
+ type: IntraBlueprintTransitionType
+ ) : Visibility() {
+ init {
+ mode = MODE_OUT
+ if (type != IntraBlueprintTransitionType.NoTransition) {
+ duration = CLOCK_OUT_MILLIS
+ interpolator = CLOCK_OUT_INTERPOLATOR
+ } else {
+ duration = 0
+ }
+
+ addTarget(sharedR.id.bc_smartspace_view)
+ addTarget(sharedR.id.date_smartspace_view)
+ addTarget(sharedR.id.weather_smartspace_view)
+ if (viewModel.useLargeClock) {
+ addTarget(R.id.lockscreen_clock_view)
+ } else {
+ viewModel.clock?.let { it.largeClock.layout.views.forEach { addTarget(it) } }
+ }
+ }
+
+ override fun onDisappear(
+ sceneRoot: ViewGroup?,
+ view: View,
+ startValues: TransitionValues?,
+ endValues: TransitionValues?
+ ): Animator {
+ return ObjectAnimator.ofFloat(view, "alpha", 0f).also {
+ it.duration = duration
+ it.interpolator = interpolator
+ it.addUpdateListener { view.alpha = it.animatedValue as Float }
+ it.start()
+ }
+ }
+ }
+
+ class ClockInChangeBounds(
+ viewModel: KeyguardClockViewModel,
+ type: IntraBlueprintTransitionType
+ ) : ChangeBounds() {
+ init {
+ if (type != IntraBlueprintTransitionType.NoTransition) {
+ duration = CLOCK_IN_MILLIS
+ startDelay = CLOCK_IN_START_DELAY_MILLIS
+ interpolator = CLOCK_IN_INTERPOLATOR
+ } else {
+ duration = 0
+ startDelay = 0
+ }
+
+ if (viewModel.useLargeClock) {
+ viewModel.clock?.let { it.largeClock.layout.views.forEach { addTarget(it) } }
+ } else {
+ addTarget(R.id.lockscreen_clock_view)
+ }
+ }
+ }
+
+ class ClockOutChangeBounds(
+ viewModel: KeyguardClockViewModel,
+ type: IntraBlueprintTransitionType
+ ) : ChangeBounds() {
+ init {
+ if (type != IntraBlueprintTransitionType.NoTransition) {
+ duration = CLOCK_OUT_MILLIS
+ interpolator = CLOCK_OUT_INTERPOLATOR
+ } else {
+ duration = 0
+ }
+ if (viewModel.useLargeClock) {
+ addTarget(R.id.lockscreen_clock_view)
+ } else {
+ viewModel.clock?.let { it.largeClock.layout.views.forEach { addTarget(it) } }
+ }
+ }
+ }
+
+ class SmartspaceChangeBounds(
+ viewModel: KeyguardClockViewModel,
+ val type: IntraBlueprintTransitionType = IntraBlueprintTransitionType.DefaultTransition
+ ) : ChangeBounds() {
+ init {
+ if (type != IntraBlueprintTransitionType.NoTransition) {
+ duration =
+ if (viewModel.useLargeClock) {
+ STATUS_AREA_MOVE_UP_MILLIS
+ } else {
+ STATUS_AREA_MOVE_DOWN_MILLIS
+ }
+ interpolator = Interpolators.EMPHASIZED
+ } else {
+ duration = 0
+ }
+ addTarget(sharedR.id.date_smartspace_view)
+ addTarget(sharedR.id.weather_smartspace_view)
+ addTarget(sharedR.id.bc_smartspace_view)
+ }
+
+ companion object {
+ const val STATUS_AREA_MOVE_UP_MILLIS = 967L
+ const val STATUS_AREA_MOVE_DOWN_MILLIS = 467L
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt
new file mode 100644
index 0000000..c35dad7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt
@@ -0,0 +1,83 @@
+/*
+ * 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.keyguard.ui.view.layout.sections.transitions
+
+import android.animation.Animator
+import android.animation.ValueAnimator
+import android.transition.Transition
+import android.transition.TransitionValues
+import android.view.ViewGroup
+import com.android.app.animation.Interpolators
+import com.android.systemui.plugins.clocks.ClockController
+
+class DefaultClockSteppingTransition(private val clock: ClockController) : Transition() {
+ init {
+ interpolator = Interpolators.LINEAR
+ duration = KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION_MS
+ addTarget(clock.largeClock.view)
+ }
+ private fun captureValues(transitionValues: TransitionValues) {
+ transitionValues.values[PROP_BOUNDS_LEFT] = transitionValues.view.left
+ val locationInWindowTmp = IntArray(2)
+ transitionValues.view.getLocationInWindow(locationInWindowTmp)
+ transitionValues.values[PROP_X_IN_WINDOW] = locationInWindowTmp[0]
+ }
+
+ override fun captureEndValues(transitionValues: TransitionValues) {
+ captureValues(transitionValues)
+ }
+
+ override fun captureStartValues(transitionValues: TransitionValues) {
+ captureValues(transitionValues)
+ }
+
+ override fun createAnimator(
+ sceneRoot: ViewGroup,
+ startValues: TransitionValues?,
+ endValues: TransitionValues?
+ ): Animator? {
+ if (startValues == null || endValues == null) {
+ return null
+ }
+ val anim = ValueAnimator.ofFloat(0f, 1f)
+ val fromLeft = startValues.values[PROP_BOUNDS_LEFT] as Int
+ val fromWindowX = startValues.values[PROP_X_IN_WINDOW] as Int
+ val toWindowX = endValues.values[PROP_X_IN_WINDOW] as Int
+ // Using windowX, to determine direction, instead of left, as in RTL the difference of
+ // toLeft - fromLeft is always positive, even when moving left.
+ val direction = if (toWindowX - fromWindowX > 0) 1 else -1
+ anim.addUpdateListener { animation: ValueAnimator ->
+ clock.largeClock.animations.onPositionUpdated(
+ fromLeft,
+ direction,
+ animation.animatedFraction
+ )
+ }
+ return anim
+ }
+
+ override fun getTransitionProperties(): Array<String> {
+ return TRANSITION_PROPERTIES
+ }
+
+ companion object {
+ private const val PROP_BOUNDS_LEFT = "splitShadeTransitionAdapter:boundsLeft"
+ private const val PROP_X_IN_WINDOW = "splitShadeTransitionAdapter:xInWindow"
+ private val TRANSITION_PROPERTIES = arrayOf(PROP_BOUNDS_LEFT, PROP_X_IN_WINDOW)
+ private const val KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION_MS = 1000L
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBlueprintViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBlueprintViewModel.kt
index e2bfc36..d22856b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBlueprintViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBlueprintViewModel.kt
@@ -26,4 +26,5 @@
constructor(keyguardBlueprintInteractor: KeyguardBlueprintInteractor) {
var currentBluePrint: KeyguardBlueprint? = null
val blueprint = keyguardBlueprintInteractor.blueprint
+ val blueprintWithTransition = keyguardBlueprintInteractor.blueprintWithTransition
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
index 523414c..c33ab12 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
@@ -586,7 +586,7 @@
coroutineScope.launch {
communalInteractor.isCommunalShowing.collect { value ->
isCommunalShowing = value
- updateDesiredLocation(forceNoAnimation = true)
+ updateDesiredLocation()
}
}
}
@@ -1149,13 +1149,17 @@
when {
mediaFlags.isSceneContainerEnabled() -> desiredLocation
dreamOverlayActive && dreamMediaComplicationActive -> LOCATION_DREAM_OVERLAY
+
+ // UMO should show in communal unless the shade is expanding or visible.
+ isCommunalShowing && qsExpansion == 0.0f -> LOCATION_COMMUNAL_HUB
(qsExpansion > 0.0f || inSplitShade) && !onLockscreen -> LOCATION_QS
qsExpansion > 0.4f && onLockscreen -> LOCATION_QS
onLockscreen && isSplitShadeExpanding() -> LOCATION_QS
onLockscreen && isTransformingToFullShadeAndInQQS() -> LOCATION_QQS
- // TODO(b/311234666): revisit logic once interactions between the hub and
- // shade/keyguard state are finalized
- isCommunalShowing && communalInteractor.isCommunalEnabled -> LOCATION_COMMUNAL_HUB
+
+ // Communal does not have its own StatusBarState so it should always have higher
+ // priority for the UMO over the lockscreen.
+ isCommunalShowing -> LOCATION_COMMUNAL_HUB
onLockscreen && allowMediaPlayerOnLockScreen -> LOCATION_LOCKSCREEN
else -> LOCATION_QQS
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java
index ac0bd29..1c37510f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java
@@ -77,6 +77,7 @@
private Consumer<Boolean> mMediaVisibilityChangedListener;
@Orientation
private int mLastOrientation;
+ private int mLastScreenLayout;
private String mCachedSpecs = "";
@Nullable
private QSTileRevealController mQsTileRevealController;
@@ -93,15 +94,19 @@
public void onConfigurationChange(Configuration newConfig) {
final boolean previousSplitShadeState = mShouldUseSplitNotificationShade;
final int previousOrientation = mLastOrientation;
+ final int previousScreenLayout = mLastScreenLayout;
mShouldUseSplitNotificationShade = mSplitShadeStateController
.shouldUseSplitNotificationShade(getResources());
mLastOrientation = newConfig.orientation;
+ mLastScreenLayout = newConfig.screenLayout;
mQSLogger.logOnConfigurationChanged(
/* oldOrientation= */ previousOrientation,
/* newOrientation= */ mLastOrientation,
/* oldShouldUseSplitShade= */ previousSplitShadeState,
/* newShouldUseSplitShade= */ mShouldUseSplitNotificationShade,
+ /* oldScreenLayout= */ previousScreenLayout,
+ /* newScreenLayout= */ mLastScreenLayout,
/* containerName= */ mView.getDumpableTag());
switchTileLayoutIfNeeded();
@@ -198,6 +203,7 @@
mView.addOnConfigurationChangedListener(mOnConfigurationChangedListener);
setTiles();
mLastOrientation = getResources().getConfiguration().orientation;
+ mLastScreenLayout = getResources().getConfiguration().screenLayout;
mQSLogger.logOnViewAttached(mLastOrientation, mView.getDumpableTag());
switchTileLayout(true);
@@ -443,11 +449,13 @@
}
boolean shouldUseHorizontalLayout() {
- if (mShouldUseSplitNotificationShade) {
+ if (mShouldUseSplitNotificationShade) {
return false;
}
return mUsingMediaPlayer && mMediaHost.getVisible()
- && mLastOrientation == Configuration.ORIENTATION_LANDSCAPE;
+ && mLastOrientation == Configuration.ORIENTATION_LANDSCAPE
+ && (mLastScreenLayout & Configuration.SCREENLAYOUT_LONG_MASK)
+ == Configuration.SCREENLAYOUT_LONG_YES;
}
private void logTiles() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt b/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt
index 38e7972..b515ce0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt
@@ -19,6 +19,8 @@
import android.content.res.Configuration.ORIENTATION_LANDSCAPE
import android.content.res.Configuration.ORIENTATION_PORTRAIT
import android.content.res.Configuration.Orientation
+import android.content.res.Configuration.SCREENLAYOUT_LONG_NO
+import android.content.res.Configuration.SCREENLAYOUT_LONG_YES
import android.service.quicksettings.Tile
import android.view.View
import com.android.systemui.log.ConstantStringsLogger
@@ -266,8 +268,10 @@
fun logOnConfigurationChanged(
@Orientation oldOrientation: Int,
@Orientation newOrientation: Int,
- newShouldUseSplitShade: Boolean,
oldShouldUseSplitShade: Boolean,
+ newShouldUseSplitShade: Boolean,
+ oldScreenLayout: Int,
+ newScreenLayout: Int,
containerName: String
) {
configChangedBuffer.log(
@@ -277,6 +281,8 @@
str1 = containerName
int1 = oldOrientation
int2 = newOrientation
+ long1 = oldScreenLayout.toLong()
+ long2 = newScreenLayout.toLong()
bool1 = oldShouldUseSplitShade
bool2 = newShouldUseSplitShade
},
@@ -284,6 +290,8 @@
"config change: " +
"$str1 orientation=${toOrientationString(int2)} " +
"(was ${toOrientationString(int1)}), " +
+ "screen layout=${toScreenLayoutString(long1.toInt())} " +
+ "(was ${toScreenLayoutString(long2.toInt())}), " +
"splitShade=$bool2 (was $bool1)"
}
)
@@ -370,3 +378,11 @@
else -> "undefined"
}
}
+
+private inline fun toScreenLayoutString(screenLayout: Int): String {
+ return when (screenLayout) {
+ SCREENLAYOUT_LONG_YES -> "long"
+ SCREENLAYOUT_LONG_NO -> "notlong"
+ else -> "undefined"
+ }
+}
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 c5eeb2f..9fefcbd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -52,7 +52,7 @@
import com.android.systemui.animation.LaunchableViewDelegate
import com.android.systemui.plugins.qs.QSIconView
import com.android.systemui.plugins.qs.QSTile
-import com.android.systemui.plugins.qs.QSTile.BooleanState
+import com.android.systemui.plugins.qs.QSTile.AdapterState
import com.android.systemui.plugins.qs.QSTileView
import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH
@@ -506,13 +506,12 @@
state.expandedAccessibilityClassName
}
- if (state is BooleanState) {
+ if (state is AdapterState) {
val newState = state.value
if (tileState != newState) {
tileState = newState
}
}
- //
// Labels
if (!Objects.equals(label.text, state.label)) {
@@ -625,7 +624,7 @@
customDrawableView.setImageDrawable(state.sideViewCustomDrawable)
customDrawableView.visibility = VISIBLE
chevronView.visibility = GONE
- } else if (state !is BooleanState || state.forceExpandIcon) {
+ } else if (state !is AdapterState || state.forceExpandIcon) {
customDrawableView.setImageDrawable(null)
customDrawableView.visibility = GONE
chevronView.visibility = VISIBLE
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 4780a2e..5a389f3 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
@@ -227,7 +227,7 @@
): QSTile.State =
// we have to use QSTile.BooleanState to support different side icons
// which are bound to instanceof QSTile.BooleanState in QSTileView.
- QSTile.BooleanState().apply {
+ QSTile.AdapterState().apply {
spec = config.tileSpec.spec
label = viewModelState.label
// This value is synthetic and doesn't have any meaning. It's only needed to satisfy
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
index 7aa0dad..b5a1313 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
@@ -25,7 +25,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
-import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import android.media.MediaRecorder;
import android.net.Uri;
@@ -379,10 +378,9 @@
.addExtras(extras);
// Add thumbnail if available
- Bitmap thumbnailBitmap = recording.getThumbnail();
- if (thumbnailBitmap != null) {
+ if (recording.getThumbnail() != null) {
Notification.BigPictureStyle pictureStyle = new Notification.BigPictureStyle()
- .bigPicture(thumbnailBitmap)
+ .bigPicture(recording.getThumbnail())
.showBigPictureWhenCollapsed(true);
builder.setStyle(pictureStyle);
}
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java
index a170d0da..5469a4e 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java
@@ -23,10 +23,12 @@
import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.MIC_AND_INTERNAL;
import android.annotation.Nullable;
+import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.drawable.Icon;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.media.MediaCodec;
@@ -51,6 +53,7 @@
import android.view.Surface;
import android.view.WindowManager;
+import com.android.internal.R;
import com.android.systemui.mediaprojection.MediaProjectionCaptureTarget;
import java.io.Closeable;
@@ -361,14 +364,27 @@
Files.copy(mTempVideoFile.toPath(), os);
os.close();
if (mTempAudioFile != null) mTempAudioFile.delete();
- DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
- Size size = new Size(metrics.widthPixels, metrics.heightPixels);
- SavedRecording recording = new SavedRecording(itemUri, mTempVideoFile, size);
+ SavedRecording recording = new SavedRecording(
+ itemUri, mTempVideoFile, getRequiredThumbnailSize());
mTempVideoFile.delete();
return recording;
}
/**
+ * Returns the required {@code Size} of the thumbnail.
+ */
+ private Size getRequiredThumbnailSize() {
+ boolean isLowRam = ActivityManager.isLowRamDeviceStatic();
+ int thumbnailIconHeight = mContext.getResources().getDimensionPixelSize(isLowRam
+ ? R.dimen.notification_big_picture_max_height_low_ram
+ : R.dimen.notification_big_picture_max_height);
+ int thumbnailIconWidth = mContext.getResources().getDimensionPixelSize(isLowRam
+ ? R.dimen.notification_big_picture_max_width_low_ram
+ : R.dimen.notification_big_picture_max_width);
+ return new Size(thumbnailIconWidth, thumbnailIconHeight);
+ }
+
+ /**
* Release the resources without saving the data
*/
protected void release() {
@@ -386,13 +402,14 @@
public class SavedRecording {
private Uri mUri;
- private Bitmap mThumbnailBitmap;
+ private Icon mThumbnailIcon;
protected SavedRecording(Uri uri, File file, Size thumbnailSize) {
mUri = uri;
try {
- mThumbnailBitmap = ThumbnailUtils.createVideoThumbnail(
+ Bitmap thumbnailBitmap = ThumbnailUtils.createVideoThumbnail(
file, thumbnailSize, null);
+ mThumbnailIcon = Icon.createWithBitmap(thumbnailBitmap);
} catch (IOException e) {
Log.e(TAG, "Error creating thumbnail", e);
}
@@ -402,8 +419,8 @@
return mUri;
}
- public @Nullable Bitmap getThumbnail() {
- return mThumbnailBitmap;
+ public @Nullable Icon getThumbnail() {
+ return mThumbnailIcon;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt
index d3459b1..e40bcd5 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt
@@ -46,7 +46,7 @@
/**
* Adds a listener that will be notified when the panel expansion fraction has changed and
- * returns the current state in a ShadeExpansionChangeEvent for legacy purposes (b/23035507).
+ * returns the current state in a ShadeExpansionChangeEvent for legacy purposes (b/281038056).
*
* @see #addExpansionListener
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index ada7d3e..ffb11dd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -56,6 +56,7 @@
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsController.Appearance;
import android.view.WindowInsetsController.Behavior;
+import android.view.accessibility.Flags;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -305,6 +306,13 @@
default void setTopAppHidesStatusBar(boolean topAppHidesStatusBar) { }
default void addQsTile(ComponentName tile) { }
+
+ /**
+ * Add a tile to the Quick Settings Panel
+ * @param tile the ComponentName of the {@link android.service.quicksettings.TileService}
+ * @param end if true, the tile will be added at the end. If false, at the beginning.
+ */
+ default void addQsTileToFrontOrEnd(ComponentName tile, boolean end) { }
default void remQsTile(ComponentName tile) { }
default void setQsTiles(String[] tiles) {}
@@ -904,8 +912,29 @@
@Override
public void addQsTile(ComponentName tile) {
- synchronized (mLock) {
- mHandler.obtainMessage(MSG_ADD_QS_TILE, tile).sendToTarget();
+ if (Flags.a11yQsShortcut()) {
+ addQsTileToFrontOrEnd(tile, false);
+ } else {
+ synchronized (mLock) {
+ mHandler.obtainMessage(MSG_ADD_QS_TILE, tile).sendToTarget();
+ }
+ }
+ }
+
+ /**
+ * Add a tile to the Quick Settings Panel
+ * @param tile the ComponentName of the {@link android.service.quicksettings.TileService}
+ * @param end if true, the tile will be added at the end. If false, at the beginning.
+ */
+ @Override
+ public void addQsTileToFrontOrEnd(ComponentName tile, boolean end) {
+ if (Flags.a11yQsShortcut()) {
+ synchronized (mLock) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = tile;
+ args.arg2 = end;
+ mHandler.obtainMessage(MSG_ADD_QS_TILE, args).sendToTarget();
+ }
}
}
@@ -1546,11 +1575,21 @@
mCallbacks.get(i).showPictureInPictureMenu();
}
break;
- case MSG_ADD_QS_TILE:
- for (int i = 0; i < mCallbacks.size(); i++) {
- mCallbacks.get(i).addQsTile((ComponentName) msg.obj);
+ case MSG_ADD_QS_TILE: {
+ if (Flags.a11yQsShortcut()) {
+ SomeArgs someArgs = (SomeArgs) msg.obj;
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).addQsTileToFrontOrEnd(
+ (ComponentName) someArgs.arg1, (boolean) someArgs.arg2);
+ }
+ someArgs.recycle();
+ } else {
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).addQsTile((ComponentName) msg.obj);
+ }
}
break;
+ }
case MSG_REMOVE_QS_TILE:
for (int i = 0; i < mCallbacks.size(); i++) {
mCallbacks.get(i).remQsTile((ComponentName) msg.obj);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java
index 60a4606..39ca7b2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java
@@ -179,6 +179,11 @@
}
@Override
+ public void addQsTileToFrontOrEnd(ComponentName tile, boolean end) {
+ mQSHost.addTile(tile, end);
+ }
+
+ @Override
public void remQsTile(ComponentName tile) {
mQSHost.removeTileByUser(tile);
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/kotlin/SysUICoroutinesModule.kt b/packages/SystemUI/src/com/android/systemui/util/kotlin/SysUICoroutinesModule.kt
index a13d85b..cabe831 100644
--- a/packages/SystemUI/src/com/android/systemui/util/kotlin/SysUICoroutinesModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/kotlin/SysUICoroutinesModule.kt
@@ -25,9 +25,13 @@
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.newFixedThreadPoolContext
import kotlinx.coroutines.plus
+private const val LIMIT_BACKGROUND_DISPATCHER_THREADS = true
+
/** Providers for various SystemIU specific coroutines-related constructs. */
@Module
class SysUICoroutinesModule {
@@ -40,14 +44,13 @@
): CoroutineScope = applicationScope.plus(coroutineContext)
/**
- * Provide a [CoroutineDispatcher] backed by a thread pool containing at most X threads, where X
- * is the number of CPU cores available.
+ * Default Coroutine dispatcher for background operations.
*
- * Because there are multiple threads at play, there is no serialization order guarantee. You
- * should use a [kotlinx.coroutines.channels.Channel] for serialization if necessary.
- *
- * @see Dispatchers.Default
+ * Note that this is explicitly limiting the number of threads. In the past, we used
+ * [Dispatchers.IO]. This caused >40 threads to be spawned, and a lot of thread list lock
+ * contention between then, eventually causing jank.
*/
+ @OptIn(DelicateCoroutinesApi::class)
@Provides
@SysUISingleton
@Background
@@ -55,12 +58,29 @@
"Use @Background CoroutineContext instead",
ReplaceWith("bgCoroutineContext()", "kotlin.coroutines.CoroutineContext")
)
- fun bgDispatcher(): CoroutineDispatcher = Dispatchers.IO
+ fun bgDispatcher(): CoroutineDispatcher {
+ return if (LIMIT_BACKGROUND_DISPATCHER_THREADS) {
+ // Why a new ThreadPool instead of just using Dispatchers.IO with
+ // CoroutineDispatcher.limitedParallelism? Because, if we were to use Dispatchers.IO, we
+ // would share those threads with other dependencies using Dispatchers.IO.
+ // Using a dedicated thread pool we have guarantees only SystemUI is able to schedule
+ // code on those.
+ newFixedThreadPoolContext(
+ nThreads = Runtime.getRuntime().availableProcessors(),
+ name = "SystemUIBg"
+ )
+ } else {
+ Dispatchers.IO
+ }
+ }
@Provides
@Background
@SysUISingleton
- fun bgCoroutineContext(@Tracing tracingCoroutineContext: CoroutineContext): CoroutineContext {
- return Dispatchers.IO + tracingCoroutineContext
+ fun bgCoroutineContext(
+ @Tracing tracingCoroutineContext: CoroutineContext,
+ @Background bgCoroutineDispatcher: CoroutineDispatcher,
+ ): CoroutineContext {
+ return bgCoroutineDispatcher + tracingCoroutineContext
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt
index b1e471a..fc34255 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt
@@ -1,3 +1,19 @@
+/*
+ * 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.biometrics.domain.interactor
import android.hardware.biometrics.AuthenticateOptions
@@ -5,24 +21,19 @@
import android.hardware.biometrics.IBiometricContextListener.FoldState
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.biometrics.AuthController
import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.display.data.repository.DeviceStateRepository
+import com.android.systemui.display.data.repository.fakeDeviceStateRepository
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
+import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
-import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_CLOSED
-import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_FULL_OPEN
-import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_HALF_OPEN
-import com.android.systemui.unfold.updates.FOLD_UPDATE_START_CLOSING
-import com.android.systemui.unfold.updates.FOLD_UPDATE_START_OPENING
-import com.android.systemui.unfold.updates.FoldStateProvider
-import com.android.systemui.user.domain.interactor.SelectedUserInteractor
-import com.android.systemui.util.mockito.withArgCaptor
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -30,8 +41,6 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
-import org.mockito.Mock
-import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
@OptIn(ExperimentalCoroutinesApi::class)
@@ -41,31 +50,20 @@
@JvmField @Rule var mockitoRule = MockitoJUnit.rule()
- private val testScope = TestScope()
-
- @Mock private lateinit var foldProvider: FoldStateProvider
- @Mock private lateinit var authController: AuthController
- @Mock private lateinit var selectedUserInteractor: SelectedUserInteractor
-
- private lateinit var udfpsOverlayInteractor: UdfpsOverlayInteractor
- private lateinit var keyguardTransitionRepository: FakeKeyguardTransitionRepository
+ private val kosmos = testKosmos()
+ private val testScope = kosmos.testScope
+ private val deviceStateRepository = kosmos.fakeDeviceStateRepository
+ private val udfpsOverlayInteractor = kosmos.udfpsOverlayInteractor
+ private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
private lateinit var interactor: LogContextInteractorImpl
@Before
fun setup() {
- keyguardTransitionRepository = FakeKeyguardTransitionRepository()
- udfpsOverlayInteractor =
- UdfpsOverlayInteractor(
- context,
- authController,
- selectedUserInteractor,
- testScope.backgroundScope,
- )
interactor =
LogContextInteractorImpl(
testScope.backgroundScope,
- foldProvider,
+ deviceStateRepository,
KeyguardTransitionInteractorFactory.create(
repository = keyguardTransitionRepository,
scope = testScope.backgroundScope,
@@ -189,33 +187,31 @@
@Test
fun foldStateChanges() =
testScope.runTest {
- val foldState = collectLastValue(interactor.foldState)
- runCurrent()
- val listener = foldProvider.captureListener()
+ val foldState by collectLastValue(interactor.foldState)
- listener.onFoldUpdate(FOLD_UPDATE_START_OPENING)
- assertThat(foldState()).isEqualTo(FoldState.UNKNOWN)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.HALF_FOLDED)
+ assertThat(foldState).isEqualTo(FoldState.HALF_OPENED)
- listener.onFoldUpdate(FOLD_UPDATE_FINISH_HALF_OPEN)
- assertThat(foldState()).isEqualTo(FoldState.HALF_OPENED)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.CONCURRENT_DISPLAY)
+ assertThat(foldState).isEqualTo(FoldState.FULLY_OPENED)
- listener.onFoldUpdate(FOLD_UPDATE_FINISH_FULL_OPEN)
- assertThat(foldState()).isEqualTo(FoldState.FULLY_OPENED)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.UNFOLDED)
+ assertThat(foldState).isEqualTo(FoldState.FULLY_OPENED)
- listener.onFoldUpdate(FOLD_UPDATE_START_CLOSING)
- assertThat(foldState()).isEqualTo(FoldState.FULLY_OPENED)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.FOLDED)
+ assertThat(foldState).isEqualTo(FoldState.FULLY_CLOSED)
- listener.onFoldUpdate(FOLD_UPDATE_FINISH_CLOSED)
- assertThat(foldState()).isEqualTo(FoldState.FULLY_CLOSED)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.REAR_DISPLAY)
+ assertThat(foldState).isEqualTo(FoldState.FULLY_OPENED)
+
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.UNKNOWN)
+ assertThat(foldState).isEqualTo(FoldState.UNKNOWN)
}
@Test
fun contextSubscriberChanges() =
testScope.runTest {
- runCurrent()
- val foldListener = foldProvider.captureListener()
- foldListener.onFoldUpdate(FOLD_UPDATE_START_CLOSING)
- foldListener.onFoldUpdate(FOLD_UPDATE_FINISH_CLOSED)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.FOLDED)
keyguardTransitionRepository.startTransitionTo(KeyguardState.AOD)
var folded: Int? = null
@@ -243,8 +239,7 @@
assertThat(displayState).isEqualTo(AuthenticateOptions.DISPLAY_STATE_AOD)
assertThat(ignoreTouches).isFalse()
- foldListener.onFoldUpdate(FOLD_UPDATE_START_OPENING)
- foldListener.onFoldUpdate(FOLD_UPDATE_FINISH_HALF_OPEN)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.HALF_FOLDED)
keyguardTransitionRepository.startTransitionTo(KeyguardState.LOCKSCREEN)
runCurrent()
@@ -259,7 +254,7 @@
job.cancel()
// stale updates should be ignored
- foldListener.onFoldUpdate(FOLD_UPDATE_FINISH_FULL_OPEN)
+ deviceStateRepository.emit(DeviceStateRepository.DeviceState.UNFOLDED)
keyguardTransitionRepository.startTransitionTo(KeyguardState.AOD)
runCurrent()
@@ -270,8 +265,3 @@
private suspend fun FakeKeyguardTransitionRepository.startTransitionTo(newState: KeyguardState) =
sendTransitionStep(TransitionStep(to = newState, transitionState = TransitionState.STARTED))
-
-private fun FoldStateProvider.captureListener() =
- withArgCaptor<FoldStateProvider.FoldUpdatesListener> {
- verify(this@captureListener).addCallback(capture())
- }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractorTest.kt
index 9fe40d7..8b16da2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractorTest.kt
@@ -23,6 +23,7 @@
import com.android.systemui.keyguard.data.repository.KeyguardBlueprintRepository
import com.android.systemui.keyguard.ui.view.layout.blueprints.DefaultKeyguardBlueprint
import com.android.systemui.keyguard.ui.view.layout.blueprints.SplitShadeKeyguardBlueprint
+import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType
import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.whenever
@@ -46,6 +47,10 @@
private lateinit var underTest: KeyguardBlueprintInteractor
private lateinit var testScope: TestScope
+ val refreshBluePrint: MutableSharedFlow<Unit> = MutableSharedFlow(extraBufferCapacity = 1)
+ val refreshBlueprintTransition: MutableSharedFlow<IntraBlueprintTransitionType> =
+ MutableSharedFlow(extraBufferCapacity = 1)
+
@Mock private lateinit var splitShadeStateController: SplitShadeStateController
@Mock private lateinit var keyguardBlueprintRepository: KeyguardBlueprintRepository
@@ -54,6 +59,9 @@
MockitoAnnotations.initMocks(this)
testScope = TestScope(StandardTestDispatcher())
whenever(keyguardBlueprintRepository.configurationChange).thenReturn(configurationFlow)
+ whenever(keyguardBlueprintRepository.refreshBluePrint).thenReturn(refreshBluePrint)
+ whenever(keyguardBlueprintRepository.refreshBlueprintTransition)
+ .thenReturn(refreshBlueprintTransition)
underTest =
KeyguardBlueprintInteractor(
@@ -105,4 +113,11 @@
underTest.transitionToBlueprint("abc")
verify(keyguardBlueprintRepository).applyBlueprint("abc")
}
+
+ @Test
+ fun testRefreshBlueprintWithTransition() {
+ underTest.refreshBlueprintWithTransition(IntraBlueprintTransitionType.DefaultTransition)
+ verify(keyguardBlueprintRepository)
+ .refreshBlueprintWithTransition(IntraBlueprintTransitionType.DefaultTransition)
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
index acb6ff0..2da74b0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
@@ -165,7 +165,7 @@
val cs = ConstraintSet()
underTest.applyDefaultConstraints(cs)
- val expectedLargeClockTopMargin = LARGE_CLOCK_TOP - CLOCK_FADE_TRANSLATION_Y
+ val expectedLargeClockTopMargin = LARGE_CLOCK_TOP
assetLargeClockTop(cs, expectedLargeClockTopMargin)
val expectedSmallClockTopMargin = SMALL_CLOCK_TOP_SPLIT_SHADE
@@ -178,7 +178,7 @@
setSplitShade(false)
val cs = ConstraintSet()
underTest.applyDefaultConstraints(cs)
- val expectedLargeClockTopMargin = LARGE_CLOCK_TOP - CLOCK_FADE_TRANSLATION_Y
+ val expectedLargeClockTopMargin = LARGE_CLOCK_TOP
assetLargeClockTop(cs, expectedLargeClockTopMargin)
val expectedSmallClockTopMargin = SMALL_CLOCK_TOP_NON_SPLIT_SHADE
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
index ba7927d..239bf65 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
@@ -532,6 +532,58 @@
}
@Test
+ fun testCommunalLocation_showsOverLockscreen() =
+ testScope.runTest {
+ // Device is on lock screen.
+ whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)
+
+ // UMO goes to communal even over the lock screen.
+ communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
+ runCurrent()
+ verify(mediaCarouselController)
+ .onDesiredLocationChanged(
+ eq(MediaHierarchyManager.LOCATION_COMMUNAL_HUB),
+ nullable(),
+ eq(false),
+ anyLong(),
+ anyLong()
+ )
+ }
+
+ @Test
+ fun testCommunalLocation_showsUntilQsExpands() =
+ testScope.runTest {
+ // Device is on lock screen.
+ whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD)
+
+ communalInteractor.onSceneChanged(CommunalSceneKey.Communal)
+ runCurrent()
+ verify(mediaCarouselController)
+ .onDesiredLocationChanged(
+ eq(MediaHierarchyManager.LOCATION_COMMUNAL_HUB),
+ nullable(),
+ eq(false),
+ anyLong(),
+ anyLong()
+ )
+ clearInvocations(mediaCarouselController)
+
+ // Start opening the shade.
+ mediaHierarchyManager.qsExpansion = 0.1f
+ runCurrent()
+
+ // UMO goes to the shade instead.
+ verify(mediaCarouselController)
+ .onDesiredLocationChanged(
+ eq(MediaHierarchyManager.LOCATION_QS),
+ any(MediaHostState::class.java),
+ eq(false),
+ anyLong(),
+ anyLong()
+ )
+ }
+
+ @Test
fun testQsExpandedChanged_noQqsMedia() {
// When we are looking at QQS with active media
whenever(statusBarStateController.state).thenReturn(StatusBarState.SHADE)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java
index a92111e..da8d29c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java
@@ -246,8 +246,9 @@
@Test
- public void testShouldUzeHorizontalLayout_falseForSplitShade() {
+ public void testShouldUseHorizontalLayout_falseForSplitShade() {
mConfiguration.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ mConfiguration.screenLayout = Configuration.SCREENLAYOUT_LONG_YES;
when(mMediaHost.getVisible()).thenReturn(true);
when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(false);
@@ -270,12 +271,13 @@
}
@Test
- public void testChangeConfiguration_shouldUseHorizontalLayout() {
+ public void testChangeConfiguration_shouldUseHorizontalLayoutInLandscape_true() {
when(mMediaHost.getVisible()).thenReturn(true);
mController.setUsingHorizontalLayoutChangeListener(mHorizontalLayoutListener);
- // When device is rotated to landscape
+ // When device is rotated to landscape and is long
mConfiguration.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ mConfiguration.screenLayout = Configuration.SCREENLAYOUT_LONG_YES;
mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration);
// Then the layout changes
@@ -292,6 +294,29 @@
}
@Test
+ public void testChangeConfiguration_shouldUseHorizontalLayoutInLongDevices_true() {
+ when(mMediaHost.getVisible()).thenReturn(true);
+ mController.setUsingHorizontalLayoutChangeListener(mHorizontalLayoutListener);
+
+ // When device is rotated to landscape and is long
+ mConfiguration.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ mConfiguration.screenLayout = Configuration.SCREENLAYOUT_LONG_YES;
+ mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration);
+
+ // Then the layout changes
+ assertThat(mController.shouldUseHorizontalLayout()).isTrue();
+ verify(mHorizontalLayoutListener).run();
+
+ // When device changes to not-long
+ mConfiguration.screenLayout = Configuration.SCREENLAYOUT_LONG_NO;
+ mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration);
+
+ // Then the layout changes back
+ assertThat(mController.shouldUseHorizontalLayout()).isFalse();
+ verify(mHorizontalLayoutListener, times(2)).run();
+ }
+
+ @Test
public void testRefreshAllTilesDoesntRefreshListeningTiles() {
when(mQSHost.getTiles()).thenReturn(List.of(mQSTile, mOtherTile));
mController.setTiles();
@@ -310,6 +335,7 @@
when(mMediaHost.getVisible()).thenReturn(true);
when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(false);
mConfiguration.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ mConfiguration.screenLayout = Configuration.SCREENLAYOUT_LONG_YES;
mController.setUsingHorizontalLayoutChangeListener(mHorizontalLayoutListener);
mController.mOnConfigurationChangedListener.onConfigurationChange(mConfiguration);
assertThat(mController.shouldUseHorizontalLayout()).isTrue();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java b/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java
index 190ee81..460892a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java
@@ -49,7 +49,7 @@
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
-import com.android.wm.shell.util.TransitionUtil;
+import com.android.wm.shell.shared.TransitionUtil;
import org.junit.Before;
import org.junit.Test;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java
index 260bef8..5da3a56 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java
@@ -25,6 +25,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.verifyZeroInteractions;
import android.content.ComponentName;
import android.graphics.Rect;
@@ -32,11 +33,14 @@
import android.hardware.biometrics.PromptInfo;
import android.hardware.fingerprint.IUdfpsRefreshRateRequestCallback;
import android.os.Bundle;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
import android.view.KeyEvent;
import android.view.WindowInsets;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsController.Appearance;
import android.view.WindowInsetsController.Behavior;
+import android.view.accessibility.Flags;
import androidx.test.filters.SmallTest;
@@ -365,14 +369,50 @@
}
@Test
- public void testAddQsTile() {
+ @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
+ public void addQsTile_withA11yQsShortcutFlagOff() {
ComponentName c = new ComponentName("testpkg", "testcls");
+
mCommandQueue.addQsTile(c);
waitForIdleSync();
+
verify(mCallbacks).addQsTile(eq(c));
}
@Test
+ @DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
+ public void addQsTileToFrontOrEnd_withA11yQsShortcutFlagOff_doNothing() {
+ ComponentName c = new ComponentName("testpkg", "testcls");
+
+ mCommandQueue.addQsTileToFrontOrEnd(c, true);
+ waitForIdleSync();
+
+ verifyZeroInteractions(mCallbacks);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
+ public void addQsTile_withA11yQsShortcutFlagOn() {
+ ComponentName c = new ComponentName("testpkg", "testcls");
+
+ mCommandQueue.addQsTile(c);
+ waitForIdleSync();
+
+ verify(mCallbacks).addQsTileToFrontOrEnd(eq(c), eq(false));
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
+ public void addQsTileAtTheEnd_withA11yQsShortcutFlagOn() {
+ ComponentName c = new ComponentName("testpkg", "testcls");
+
+ mCommandQueue.addQsTileToFrontOrEnd(c, true);
+ waitForIdleSync();
+
+ verify(mCallbacks).addQsTileToFrontOrEnd(eq(c), eq(true));
+ }
+
+ @Test
public void testRemoveQsTile() {
ComponentName c = new ComponentName("testpkg", "testcls");
mCommandQueue.remQsTile(c);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java
index 912c27d..ea4ae17 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java
@@ -26,6 +26,7 @@
import android.app.ActivityManager;
import android.app.StatusBarManager;
+import android.content.ComponentName;
import android.os.PowerManager;
import android.os.UserHandle;
import android.os.Vibrator;
@@ -190,4 +191,31 @@
HapticFeedbackConstants.GESTURE_START
);
}
+
+ @Test
+ public void addQsTile_delegateCallToQsHost() {
+ ComponentName c = new ComponentName("testpkg", "testcls");
+
+ mSbcqCallbacks.addQsTile(c);
+
+ verify(mQSHost).addTile(c);
+ }
+
+ @Test
+ public void addQsTileToFrontOrEnd_toTheEnd_delegateCallToQsHost() {
+ ComponentName c = new ComponentName("testpkg", "testcls");
+
+ mSbcqCallbacks.addQsTileToFrontOrEnd(c, true);
+
+ verify(mQSHost).addTile(c, true);
+ }
+
+ @Test
+ public void addQsTileToFrontOrEnd_toTheFront_delegateCallToQsHost() {
+ ComponentName c = new ComponentName("testpkg", "testcls");
+
+ mSbcqCallbacks.addQsTileToFrontOrEnd(c, false);
+
+ verify(mQSHost).addTile(c, false);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
index 0a3c2d9..925ac2a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
@@ -2098,6 +2098,26 @@
}
@Test
+ public void testShowOrHideAppBubble_addsFromOverflow() {
+ String appBubbleKey = Bubble.getAppBubbleKeyForApp(mAppBubbleIntent.getPackage(), mUser0);
+ mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon);
+
+ // Collapse the stack so we don't need to wait for the dismiss animation in the test
+ mBubbleController.collapseStack();
+
+ // Dismiss the app bubble so it's in the overflow
+ mBubbleController.dismissBubble(appBubbleKey, Bubbles.DISMISS_USER_GESTURE);
+ assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNotNull();
+
+ // Calling this while collapsed will re-add and expand the app bubble
+ mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon);
+ assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleKey);
+ assertThat(mBubbleController.isStackExpanded()).isTrue();
+ assertThat(mBubbleData.getBubbles().size()).isEqualTo(1);
+ assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNull();
+ }
+
+ @Test
public void testCreateBubbleFromOngoingNotification() {
NotificationEntry notif = new NotificationEntryBuilder()
.setFlag(mContext, Notification.FLAG_ONGOING_EVENT, true)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/display/data/repository/DeviceStateRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/display/data/repository/DeviceStateRepositoryKosmos.kt
new file mode 100644
index 0000000..5855060
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/display/data/repository/DeviceStateRepositoryKosmos.kt
@@ -0,0 +1,24 @@
+/*
+ * 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.display.data.repository
+
+import com.android.systemui.kosmos.Kosmos
+
+var Kosmos.deviceStateRepository: DeviceStateRepository by
+ Kosmos.Fixture { fakeDeviceStateRepository }
+val Kosmos.fakeDeviceStateRepository: FakeDeviceStateRepository by
+ Kosmos.Fixture { FakeDeviceStateRepository() }
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
index 5588f4f..3670459 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
@@ -24,6 +24,8 @@
import androidx.test.platform.app.InstrumentationRegistry;
+import com.android.internal.os.RuntimeInit;
+
import org.junit.runner.Description;
import java.io.PrintStream;
@@ -53,6 +55,8 @@
}
public static void init(RavenwoodRule rule) {
+ RuntimeInit.redirectLogStreams();
+
android.os.Process.init$ravenwood(rule.mUid, rule.mPid);
android.os.Binder.init$ravenwood();
android.os.SystemProperties.init$ravenwood(
diff --git a/ravenwood/ravenwood-annotation-allowed-classes.txt b/ravenwood/ravenwood-annotation-allowed-classes.txt
index b775f9a..e49b64e 100644
--- a/ravenwood/ravenwood-annotation-allowed-classes.txt
+++ b/ravenwood/ravenwood-annotation-allowed-classes.txt
@@ -5,6 +5,7 @@
com.android.internal.logging.MetricsLogger
com.android.internal.logging.testing.FakeMetricsLogger
com.android.internal.logging.testing.UiEventLoggerFake
+com.android.internal.os.AndroidPrintStream
com.android.internal.os.BatteryStatsHistory
com.android.internal.os.BatteryStatsHistory$TraceDelegate
com.android.internal.os.BatteryStatsHistory$VarintParceler
@@ -16,6 +17,7 @@
com.android.internal.os.PowerProfile
com.android.internal.os.PowerStats
com.android.internal.os.PowerStats$Descriptor
+com.android.internal.os.RuntimeInit
com.android.internal.power.ModemPowerProfile
android.util.AtomicFile
diff --git a/services/core/java/com/android/server/IntentResolver.java b/services/core/java/com/android/server/IntentResolver.java
index a1e6b58f..81c9ee7 100644
--- a/services/core/java/com/android/server/IntentResolver.java
+++ b/services/core/java/com/android/server/IntentResolver.java
@@ -81,7 +81,7 @@
* Returns whether an intent matches the IntentFilter with a pre-resolved type.
*/
public static boolean intentMatchesFilter(
- IntentFilter filter, Intent intent, String resolvedType, boolean defaultOnly) {
+ IntentFilter filter, Intent intent, String resolvedType) {
final boolean debug = localLOGV
|| ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
@@ -97,10 +97,6 @@
int match = filter.match(intent.getAction(), resolvedType, intent.getScheme(),
intent.getData(), intent.getCategories(), TAG);
- if (match >= 0 && defaultOnly && !filter.hasCategory(Intent.CATEGORY_DEFAULT)) {
- match = IntentFilter.NO_MATCH_CATEGORY;
- }
-
if (match >= 0) {
if (debug) {
Slog.v(TAG, "Filter matched! match=0x" + Integer.toHexString(match));
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 374a17a..a5531ae 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -2101,7 +2101,8 @@
// Start watching app ops after we and the package manager are up and running.
mAppOpsService.startWatchingMode(AppOpsManager.OP_RUN_IN_BACKGROUND, null,
new IAppOpsCallback.Stub() {
- @Override public void opChanged(int op, int uid, String packageName) {
+ @Override public void opChanged(int op, int uid, String packageName,
+ String persistentDeviceId) {
if (op == AppOpsManager.OP_RUN_IN_BACKGROUND && packageName != null) {
if (getAppOpsManager().checkOpNoThrow(op, uid, packageName)
!= AppOpsManager.MODE_ALLOWED) {
@@ -2115,7 +2116,7 @@
mAppOpsService.startWatchingActive(cameraOp, new IAppOpsActiveCallback.Stub() {
@Override
public void opActiveChanged(int op, int uid, String packageName, String attributionTag,
- boolean active, @AttributionFlags int attributionFlags,
+ int virtualDeviceId, boolean active, @AttributionFlags int attributionFlags,
int attributionChainId) {
cameraActiveChanged(uid, active);
}
diff --git a/services/core/java/com/android/server/am/AppPermissionTracker.java b/services/core/java/com/android/server/am/AppPermissionTracker.java
index 18a9153..c641b35 100644
--- a/services/core/java/com/android/server/am/AppPermissionTracker.java
+++ b/services/core/java/com/android/server/am/AppPermissionTracker.java
@@ -393,7 +393,7 @@
private class MyAppOpsCallback extends IAppOpsCallback.Stub {
@Override
- public void opChanged(int op, int uid, String packageName) {
+ public void opChanged(int op, int uid, String packageName, String persistentDeviceId) {
mHandler.obtainMessage(MyHandler.MSG_APPOPS_CHANGED, op, uid, packageName)
.sendToTarget();
}
diff --git a/services/core/java/com/android/server/appop/AppOpsCheckingServiceImpl.java b/services/core/java/com/android/server/appop/AppOpsCheckingServiceImpl.java
index 0916967..9535db8 100644
--- a/services/core/java/com/android/server/appop/AppOpsCheckingServiceImpl.java
+++ b/services/core/java/com/android/server/appop/AppOpsCheckingServiceImpl.java
@@ -220,7 +220,7 @@
}
for (int i = 0; i < listenersCopy.size(); i++) {
- listenersCopy.get(i).onUidModeChanged(uid, op, mode);
+ listenersCopy.get(i).onUidModeChanged(uid, op, mode, persistentDeviceId);
}
return true;
diff --git a/services/core/java/com/android/server/appop/AppOpsCheckingServiceInterface.java b/services/core/java/com/android/server/appop/AppOpsCheckingServiceInterface.java
index f056f6b..8b4ea67 100644
--- a/services/core/java/com/android/server/appop/AppOpsCheckingServiceInterface.java
+++ b/services/core/java/com/android/server/appop/AppOpsCheckingServiceInterface.java
@@ -176,8 +176,9 @@
* @param uid The UID whose appop mode was changed.
* @param code The op code that was changed.
* @param mode The new mode.
+ * @param persistentDeviceId the device whose mode was changed
*/
- void onUidModeChanged(int uid, int code, int mode);
+ void onUidModeChanged(int uid, int code, int mode, String persistentDeviceId);
/**
* Invoked when a package's appop mode is changed.
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 2ed217a..5c95d43 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -166,6 +166,7 @@
import com.android.server.LockGuard;
import com.android.server.SystemServerInitThreadPool;
import com.android.server.SystemServiceManager;
+import com.android.server.companion.virtual.VirtualDeviceManagerInternal;
import com.android.server.pm.PackageList;
import com.android.server.pm.PackageManagerLocal;
import com.android.server.pm.UserManagerInternal;
@@ -275,6 +276,10 @@
= new AppOpsManagerInternalImpl();
@Nullable private final DevicePolicyManagerInternal dpmi =
LocalServices.getService(DevicePolicyManagerInternal.class);
+ @Nullable private VirtualDeviceManagerInternal mVirtualDeviceManagerInternal;
+
+ /** Map of virtual device id -> persistent device id. */
+ private final SparseArray<String> mKnownDeviceIds = new SparseArray<>();
private final IPlatformCompat mPlatformCompat = IPlatformCompat.Stub.asInterface(
ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE));
@@ -595,45 +600,71 @@
final UidState uidState;
final @NonNull String packageName;
- /** attributionTag -> AttributedOp */
- final ArrayMap<String, AttributedOp> mAttributions = new ArrayMap<>(1);
+ /**
+ * Map to retrieve {@link AttributedOp} for a particular device and attribution tag.
+ *
+ * ArrayMap<Persistent Device Id, ArrayMap<Attribution Tag, AttributedOp>>
+ */
+ final ArrayMap<String, ArrayMap<String, AttributedOp>> mDeviceAttributedOps =
+ new ArrayMap<String, ArrayMap<String, AttributedOp>>(1);
Op(UidState uidState, String packageName, int op, int uid) {
this.op = op;
this.uid = uid;
this.uidState = uidState;
this.packageName = packageName;
+ // We keep an invariant that the persistent device will always have an entry in
+ // mDeviceAttributedOps.
+ mDeviceAttributedOps.put(PERSISTENT_DEVICE_ID_DEFAULT,
+ new ArrayMap<String, AttributedOp>());
}
void removeAttributionsWithNoTime() {
- for (int i = mAttributions.size() - 1; i >= 0; i--) {
- if (!mAttributions.valueAt(i).hasAnyTime()) {
- mAttributions.removeAt(i);
+ for (int deviceIndex = mDeviceAttributedOps.size() - 1; deviceIndex >= 0;
+ deviceIndex--) {
+ ArrayMap<String, AttributedOp> attributedOps = mDeviceAttributedOps.valueAt(
+ deviceIndex);
+ for (int tagIndex = attributedOps.size() - 1; tagIndex >= 0; tagIndex--) {
+ if (!attributedOps.valueAt(tagIndex).hasAnyTime()) {
+ attributedOps.removeAt(tagIndex);
+ }
+ }
+ if (!Objects.equals(PERSISTENT_DEVICE_ID_DEFAULT,
+ mDeviceAttributedOps.keyAt(deviceIndex)) && attributedOps.isEmpty()) {
+ mDeviceAttributedOps.removeAt(deviceIndex);
}
}
}
private @NonNull AttributedOp getOrCreateAttribution(@NonNull Op parent,
- @Nullable String attributionTag) {
- AttributedOp attributedOp;
+ @Nullable String attributionTag, String persistentDeviceId) {
+ ArrayMap<String, AttributedOp> attributedOps = mDeviceAttributedOps.get(
+ persistentDeviceId);
+ if (attributedOps == null) {
+ attributedOps = new ArrayMap<>();
+ mDeviceAttributedOps.put(persistentDeviceId, attributedOps);
+ }
+ AttributedOp attributedOp = attributedOps.get(attributionTag);
- attributedOp = mAttributions.get(attributionTag);
if (attributedOp == null) {
- attributedOp = new AttributedOp(AppOpsService.this, attributionTag, parent);
- mAttributions.put(attributionTag, attributedOp);
+ attributedOp = new AttributedOp(AppOpsService.this, attributionTag,
+ persistentDeviceId, parent);
+ attributedOps.put(attributionTag, attributedOp);
}
return attributedOp;
}
@NonNull OpEntry createEntryLocked() {
- final int numAttributions = mAttributions.size();
-
+ // TODO(b/308201969): Update this method when we introduce disk persistence of events
+ // for accesses on external devices.
+ final ArrayMap<String, AttributedOp> attributedOps = mDeviceAttributedOps.get(
+ PERSISTENT_DEVICE_ID_DEFAULT);
final ArrayMap<String, AppOpsManager.AttributedOpEntry> attributionEntries =
- new ArrayMap<>(numAttributions);
- for (int i = 0; i < numAttributions; i++) {
- attributionEntries.put(mAttributions.keyAt(i),
- mAttributions.valueAt(i).createAttributedOpEntryLocked());
+ new ArrayMap<>(attributedOps.size());
+ for (int i = 0; i < attributedOps.size(); i++) {
+ attributionEntries.put(attributedOps.keyAt(i),
+ attributedOps.valueAt(i).createAttributedOpEntryLocked());
}
return new OpEntry(
@@ -644,17 +675,15 @@
}
@NonNull OpEntry createSingleAttributionEntryLocked(@Nullable String attributionTag) {
- final int numAttributions = mAttributions.size();
-
+ // TODO(b/308201969): Update this method when we introduce disk persistence of events
+ // for accesses on external devices.
+ final ArrayMap<String, AttributedOp> attributedOps = mDeviceAttributedOps.get(
+ PERSISTENT_DEVICE_ID_DEFAULT);
final ArrayMap<String, AttributedOpEntry> attributionEntries = new ArrayMap<>(1);
- for (int i = 0; i < numAttributions; i++) {
- if (Objects.equals(mAttributions.keyAt(i), attributionTag)) {
- attributionEntries.put(mAttributions.keyAt(i),
- mAttributions.valueAt(i).createAttributedOpEntryLocked());
- break;
- }
+ if (attributedOps.get(attributionTag) != null) {
+ attributionEntries.put(attributionTag,
+ attributedOps.get(attributionTag).createAttributedOpEntryLocked());
}
-
return new OpEntry(
op,
mAppOpsCheckingService.getPackageMode(
@@ -663,13 +692,15 @@
}
boolean isRunning() {
- final int numAttributions = mAttributions.size();
- for (int i = 0; i < numAttributions; i++) {
- if (mAttributions.valueAt(i).isRunning()) {
- return true;
+ for (int deviceIndex = 0; deviceIndex < mDeviceAttributedOps.size(); deviceIndex++) {
+ ArrayMap<String, AttributedOp> attributedOps = mDeviceAttributedOps.valueAt(
+ deviceIndex);
+ for (int tagIndex = 0; tagIndex < attributedOps.size(); tagIndex++) {
+ if (attributedOps.valueAt(tagIndex).isRunning()) {
+ return true;
+ }
}
}
-
return false;
}
}
@@ -738,7 +769,15 @@
@Override
public void onOpModeChanged(int op, int uid, String packageName) throws RemoteException {
- mCallback.opChanged(op, uid, packageName);
+ throw new IllegalStateException(
+ "unimplemented onOpModeChanged method called for op: " + op + " uid: " + uid
+ + " packageName: " + packageName);
+ }
+
+ @Override
+ public void onOpModeChanged(int op, int uid, String packageName, String persistentDeviceId)
+ throws RemoteException {
+ mCallback.opChanged(op, uid, packageName, persistentDeviceId);
}
}
@@ -910,6 +949,7 @@
public AppOpsService(File recentAccessesFile, File storageFile, Handler handler,
Context context) {
mContext = context;
+ mKnownDeviceIds.put(Context.DEVICE_ID_DEFAULT, PERSISTENT_DEVICE_ID_DEFAULT);
for (int switchedCode = 0; switchedCode < _NUM_OP; switchedCode++) {
int switchCode = AppOpsManager.opToSwitch(switchedCode);
@@ -927,10 +967,11 @@
mAppOpsCheckingService.addAppOpsModeChangedListener(
new AppOpsCheckingServiceInterface.AppOpsModeChangedListener() {
@Override
- public void onUidModeChanged(int uid, int code, int mode) {
+ public void onUidModeChanged(int uid, int code, int mode,
+ String persistentDeviceId) {
mHandler.sendMessage(PooledLambda.obtainMessage(
AppOpsService::notifyOpChangedForAllPkgsInUid, AppOpsService.this,
- code, uid, false));
+ code, uid, false, persistentDeviceId));
}
@Override
@@ -941,8 +982,9 @@
packageName, code, mode, userId));
}
});
+ // Only notify default device as other devices are unaffected by restriction changes.
mAppOpsRestrictions = new AppOpsRestrictionsImpl(context, handler,
- code -> notifyWatchersOfChange(code, UID_ANY));
+ code -> notifyWatchersOnDefaultDevice(code, UID_ANY));
LockGuard.installLock(this, LockGuard.INDEX_APP_OPS);
mStorageFile = new AtomicFile(storageFile, "appops_legacy");
@@ -1043,25 +1085,28 @@
int numOps = ops.size();
for (int opNum = 0; opNum < numOps; opNum++) {
Op op = ops.valueAt(opNum);
+ for (int deviceIndex = op.mDeviceAttributedOps.size() - 1; deviceIndex >= 0;
+ deviceIndex--) {
+ ArrayMap<String, AttributedOp> attributedOps =
+ op.mDeviceAttributedOps.valueAt(deviceIndex);
+ for (int tagIndex = attributedOps.size() - 1; tagIndex >= 0;
+ tagIndex--) {
+ String tag = attributedOps.keyAt(tagIndex);
+ if (attributionTags.contains(tag)) {
+ // attribution still exist after upgrade
+ continue;
+ }
- int numAttributions = op.mAttributions.size();
- for (int attributionNum = numAttributions - 1; attributionNum >= 0;
- attributionNum--) {
- String attributionTag = op.mAttributions.keyAt(attributionNum);
+ String newAttributionTag = dstAttributionTags.get(tag);
- if (attributionTags.contains(attributionTag)) {
- // attribution still exist after upgrade
- continue;
+ AttributedOp newAttributedOp = op.getOrCreateAttribution(op,
+ newAttributionTag,
+ op.mDeviceAttributedOps.keyAt(deviceIndex));
+ newAttributedOp.add(attributedOps.get(tag));
+ attributedOps.remove(tag);
+
+ scheduleFastWriteLocked();
}
-
- String newAttributionTag = dstAttributionTags.get(attributionTag);
-
- AttributedOp newAttributedOp = op.getOrCreateAttribution(op,
- newAttributionTag);
- newAttributedOp.add(op.mAttributions.valueAt(attributionNum));
- op.mAttributions.removeAt(attributionNum);
-
- scheduleFastWriteLocked();
}
}
}
@@ -1070,6 +1115,8 @@
};
public void systemReady() {
+ mVirtualDeviceManagerInternal = LocalServices.getService(
+ VirtualDeviceManagerInternal.class);
mAppOpsCheckingService.systemReady();
initializeUidStates();
@@ -1144,7 +1191,17 @@
final String changedPkg = changedPkgs[i];
// We trust packagemanager to insert matching uid and packageNames in the
// extras
- notifyOpChanged(onModeChangedListeners, code, changedUid, changedPkg);
+ Set<String> devices;
+ if (mVirtualDeviceManagerInternal != null) {
+ devices = mVirtualDeviceManagerInternal.getAllPersistentDeviceIds();
+ } else {
+ devices = new ArraySet<>();
+ devices.add(PERSISTENT_DEVICE_ID_DEFAULT);
+ }
+ for (String device: devices) {
+ notifyOpChanged(onModeChangedListeners, code, changedUid, changedPkg,
+ device);
+ }
}
}
}
@@ -1295,17 +1352,19 @@
final int numOps = removedOps.size();
for (int opNum = 0; opNum < numOps; opNum++) {
final Op op = removedOps.valueAt(opNum);
+ for (int deviceIndex = 0; deviceIndex < op.mDeviceAttributedOps.size();
+ deviceIndex++) {
+ ArrayMap<String, AttributedOp> attributedOps =
+ op.mDeviceAttributedOps.valueAt(deviceIndex);
+ for (int tagIndex = 0; tagIndex < attributedOps.size(); tagIndex++) {
+ AttributedOp attributedOp = attributedOps.valueAt(tagIndex);
- final int numAttributions = op.mAttributions.size();
- for (int attributionNum = 0; attributionNum < numAttributions;
- attributionNum++) {
- AttributedOp attributedOp = op.mAttributions.valueAt(attributionNum);
-
- while (attributedOp.isRunning()) {
- attributedOp.finished(attributedOp.mInProgressEvents.keyAt(0));
- }
- while (attributedOp.isPaused()) {
- attributedOp.finished(attributedOp.mPausedInProgressEvents.keyAt(0));
+ while (attributedOp.isRunning()) {
+ attributedOp.finished(attributedOp.mInProgressEvents.keyAt(0));
+ }
+ while (attributedOp.isPaused()) {
+ attributedOp.finished(attributedOp.mPausedInProgressEvents.keyAt(0));
+ }
}
}
}
@@ -1380,7 +1439,7 @@
== AppOpsManager.MODE_FOREGROUND) {
mHandler.sendMessage(PooledLambda.obtainMessage(
AppOpsService::notifyOpChangedForAllPkgsInUid,
- this, code, uidState.uid, true));
+ this, code, uidState.uid, true, PERSISTENT_DEVICE_ID_DEFAULT));
} else if (!uidState.pkgOps.isEmpty()) {
final ArraySet<OnOpModeChangedListener> listenerSet =
mOpModeWatchers.get(code);
@@ -1405,7 +1464,8 @@
mHandler.sendMessage(PooledLambda.obtainMessage(
AppOpsService::notifyOpChanged,
this, listenerSet.valueAt(cbi), code, uidState.uid,
- uidState.pkgOps.keyAt(pkgi)));
+ uidState.pkgOps.keyAt(pkgi),
+ PERSISTENT_DEVICE_ID_DEFAULT));
}
}
}
@@ -1422,14 +1482,15 @@
int numOps = ops.size();
for (int opNum = 0; opNum < numOps; opNum++) {
Op op = ops.valueAt(opNum);
-
- int numAttributions = op.mAttributions.size();
- for (int attributionNum = 0; attributionNum < numAttributions;
- attributionNum++) {
- AttributedOp attributedOp = op.mAttributions.valueAt(
- attributionNum);
-
- attributedOp.onUidStateChanged(state);
+ for (int deviceIndex = 0; deviceIndex < op.mDeviceAttributedOps.size();
+ deviceIndex++) {
+ ArrayMap<String, AttributedOp> attributedOps =
+ op.mDeviceAttributedOps.valueAt(deviceIndex);
+ for (int tagIndex = 0; tagIndex < attributedOps.size();
+ tagIndex++) {
+ AttributedOp attributedOp = attributedOps.valueAt(tagIndex);
+ attributedOp.onUidStateChanged(state);
+ }
}
}
}
@@ -1774,7 +1835,7 @@
private void pruneOpLocked(Op op, int uid, String packageName) {
op.removeAttributionsWithNoTime();
- if (op.mAttributions.isEmpty()) {
+ if (op.mDeviceAttributedOps.isEmpty()) {
Ops ops = getOpsLocked(uid, packageName, null, false, null, /* edit */ false);
if (ops != null) {
ops.remove(op.op);
@@ -1870,8 +1931,10 @@
uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT, code, mode)) {
return;
}
+ // TODO(b/266164193): Ensure this behavior is device-aware after uid op mode for runtime
+ // permissions is deprecated.
if (mode != MODE_ERRORED && mode != previousMode) {
- updateStartedOpModeForUidLocked(code, mode == MODE_IGNORED, uid);
+ updateStartedOpModeForUidForDefaultDeviceLocked(code, mode == MODE_IGNORED, uid);
}
}
@@ -1884,8 +1947,10 @@
* @param code The op that changed
* @param uid The uid the op was changed for
* @param onlyForeground Only notify watchers that watch for foreground changes
+ * @param persistentDeviceId device the op was changed for
*/
- private void notifyOpChangedForAllPkgsInUid(int code, int uid, boolean onlyForeground) {
+ private void notifyOpChangedForAllPkgsInUid(int code, int uid, boolean onlyForeground,
+ String persistentDeviceId) {
String[] uidPackageNames = getPackagesForUid(uid);
ArrayMap<OnOpModeChangedListener, ArraySet<String>> callbackSpecs = null;
synchronized (this) {
@@ -1951,17 +2016,17 @@
final OnOpModeChangedListener callback = callbackSpecs.keyAt(i);
final ArraySet<String> reportedPackageNames = callbackSpecs.valueAt(i);
if (reportedPackageNames == null) {
- mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyOpChanged,
- this, callback, code, uid, (String) null));
+ mHandler.sendMessage(
+ PooledLambda.obtainMessage(AppOpsService::notifyOpChanged, this,
+ callback, code, uid, (String) null, persistentDeviceId));
} else {
final int reportedPackageCount = reportedPackageNames.size();
for (int j = 0; j < reportedPackageCount; j++) {
final String reportedPackageName = reportedPackageNames.valueAt(j);
- mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyOpChanged,
- this, callback, code, uid, reportedPackageName));
+ mHandler.sendMessage(
+ PooledLambda.obtainMessage(AppOpsService::notifyOpChanged, this,
+ callback, code, uid, reportedPackageName, persistentDeviceId));
}
}
}
@@ -1999,13 +2064,17 @@
}
scheduleFastWriteLocked();
if (mode != MODE_ERRORED) {
- updateStartedOpModeForUidLocked(code, mode == MODE_IGNORED, uid);
+ // Notify on PERSISTENT_DEVICE_ID_DEFAULT only as only uid modes are device-aware,
+ // not package modes.
+ updateStartedOpModeForUidForDefaultDeviceLocked(code, mode == MODE_IGNORED, uid);
}
}
if (repCbs != null && uid != -1) {
+ // Notify on PERSISTENT_DEVICE_ID_DEFAULT only as only uid modes are device-aware, not
+ // package modes.
mHandler.sendMessage(PooledLambda.obtainMessage(AppOpsService::notifyOpChanged, this,
- repCbs, code, uid, packageName));
+ repCbs, code, uid, packageName, PERSISTENT_DEVICE_ID_DEFAULT));
}
}
@@ -2161,15 +2230,15 @@
}
private void notifyOpChanged(ArraySet<OnOpModeChangedListener> callbacks, int code,
- int uid, String packageName) {
+ int uid, String packageName, String persistentDeviceId) {
for (int i = 0; i < callbacks.size(); i++) {
final OnOpModeChangedListener callback = callbacks.valueAt(i);
- notifyOpChanged(callback, code, uid, packageName);
+ notifyOpChanged(callback, code, uid, packageName, persistentDeviceId);
}
}
private void notifyOpChanged(OnOpModeChangedListener onModeChangedListener, int code,
- int uid, String packageName) {
+ int uid, String packageName, String persistentDeviceId) {
Objects.requireNonNull(onModeChangedListener);
if (uid != UID_ANY && onModeChangedListener.getWatchingUid() >= 0
@@ -2197,7 +2266,8 @@
onModeChangedListener.getCallingUid())) {
continue;
}
- onModeChangedListener.onOpModeChanged(switchedCode, uid, packageName);
+ onModeChangedListener.onOpModeChanged(switchedCode, uid, packageName,
+ persistentDeviceId);
} catch (RemoteException e) {
/* ignore */
} finally {
@@ -2289,7 +2359,8 @@
boolean changed = false;
for (int i = mUidStates.size() - 1; i >= 0; i--) {
UidState uidState = mUidStates.valueAt(i);
- // TODO(b/299330771): Check non default modes for all devices.
+ // TODO(b/266164193): Ensure this behavior is device-aware after uid op mode for
+ // runtime permissions is deprecated.
SparseIntArray opModes =
mAppOpsCheckingService.getNonDefaultUidModes(
uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT);
@@ -2301,7 +2372,6 @@
int previousMode = opModes.valueAt(j);
int newMode = isUidOpGrantedByRole(uidState.uid, code) ? MODE_ALLOWED :
AppOpsManager.opToDefaultMode(code);
- // TODO(b/299330771): Set mode for all necessary devices.
mAppOpsCheckingService.setUidMode(
uidState.uid,
PERSISTENT_DEVICE_ID_DEFAULT,
@@ -2375,7 +2445,7 @@
allChanges = addChange(allChanges, curOp.op, uid, packageName,
previousMode);
curOp.removeAttributionsWithNoTime();
- if (curOp.mAttributions.isEmpty()) {
+ if (curOp.mDeviceAttributedOps.isEmpty()) {
pkgOps.removeAt(j);
}
}
@@ -2399,9 +2469,18 @@
ArrayList<ChangeRec> reports = ent.getValue();
for (int i=0; i<reports.size(); i++) {
ChangeRec rep = reports.get(i);
- mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyOpChanged,
- this, cb, rep.op, rep.uid, rep.pkg));
+ Set<String> devices;
+ if (mVirtualDeviceManagerInternal != null) {
+ devices = mVirtualDeviceManagerInternal.getAllPersistentDeviceIds();
+ } else {
+ devices = new ArraySet<>();
+ devices.add(PERSISTENT_DEVICE_ID_DEFAULT);
+ }
+ for (String device: devices) {
+ mHandler.sendMessage(PooledLambda.obtainMessage(
+ AppOpsService::notifyOpChanged,
+ this, cb, rep.op, rep.uid, rep.pkg, device));
+ }
}
}
}
@@ -2595,6 +2674,12 @@
private int checkOperationImpl(int code, int uid, String packageName,
@Nullable String attributionTag, int virtualDeviceId, boolean raw) {
verifyIncomingOp(code);
+ if (!isValidVirtualDeviceId(virtualDeviceId)) {
+ Slog.w(TAG,
+ "checkOperationImpl returned MODE_IGNORED as virtualDeviceId " + virtualDeviceId
+ + " is invalid");
+ return AppOpsManager.MODE_IGNORED;
+ }
if (!isIncomingPackageValid(packageName, UserHandle.getUserId(uid))) {
return AppOpsManager.opToDefaultMode(code);
}
@@ -2603,7 +2688,8 @@
if (resolvedPackageName == null) {
return AppOpsManager.MODE_IGNORED;
}
- return checkOperationUnchecked(code, uid, resolvedPackageName, attributionTag, raw);
+ return checkOperationUnchecked(code, uid, resolvedPackageName, attributionTag,
+ virtualDeviceId, raw);
}
/**
@@ -2617,7 +2703,7 @@
* @return The mode of the op
*/
private @Mode int checkOperationUnchecked(int code, int uid, @NonNull String packageName,
- @Nullable String attributionTag, boolean raw) {
+ @Nullable String attributionTag, int virtualDeviceId, boolean raw) {
PackageVerificationResult pvr;
try {
pvr = verifyAndGetBypass(uid, packageName, null);
@@ -2630,19 +2716,19 @@
return AppOpsManager.MODE_IGNORED;
}
synchronized (this) {
- if (isOpRestrictedLocked(uid, code, packageName, attributionTag, pvr.bypass, true)) {
+ if (isOpRestrictedLocked(uid, code, packageName, attributionTag, virtualDeviceId,
+ pvr.bypass, true)) {
return AppOpsManager.MODE_IGNORED;
}
code = AppOpsManager.opToSwitch(code);
UidState uidState = getUidStateLocked(uid, false);
- // TODO(b/299330771): Check mode for the relevant device.
if (uidState != null
&& mAppOpsCheckingService.getUidMode(
- uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT, code)
+ uidState.uid, getPersistentId(virtualDeviceId), code)
!= AppOpsManager.opToDefaultMode(code)) {
final int rawMode =
mAppOpsCheckingService.getUidMode(
- uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT, code);
+ uidState.uid, getPersistentId(virtualDeviceId), code);
return raw ? rawMode : uidState.evalMode(code, rawMode);
}
Op op = getOpLocked(code, uid, packageName, null, false, pvr.bypass, /* edit */ false);
@@ -2683,8 +2769,9 @@
mAudioRestrictionManager.setZenModeAudioRestriction(
code, usage, uid, mode, exceptionPackages);
+ // Only notify default device as other devices are unaffected by restriction changes.
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyWatchersOfChange, this, code, UID_ANY));
+ AppOpsService::notifyWatchersOnDefaultDevice, this, code, UID_ANY));
}
@@ -2694,11 +2781,12 @@
mAudioRestrictionManager.setCameraAudioRestriction(mode);
+ // Only notify default device as other devices are unaffected by restriction changes.
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyWatchersOfChange, this,
+ AppOpsService::notifyWatchersOnDefaultDevice, this,
AppOpsManager.OP_PLAY_AUDIO, UID_ANY));
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyWatchersOfChange, this,
+ AppOpsService::notifyWatchersOnDefaultDevice, this,
AppOpsManager.OP_VIBRATE, UID_ANY));
}
@@ -2761,11 +2849,18 @@
final String proxyPackageName = attributionSource.getPackageName();
final String proxyAttributionTag = attributionSource.getAttributionTag();
final int proxiedUid = attributionSource.getNextUid();
+ final int proxyVirtualDeviceId = attributionSource.getDeviceId();
final String proxiedPackageName = attributionSource.getNextPackageName();
final String proxiedAttributionTag = attributionSource.getNextAttributionTag();
verifyIncomingProxyUid(attributionSource);
verifyIncomingOp(code);
+ if (!isValidVirtualDeviceId(proxyVirtualDeviceId)) {
+ Slog.w(TAG, "noteProxyOperationImpl returned MODE_IGNORED as virtualDeviceId "
+ + proxyVirtualDeviceId + " is invalid");
+ return new SyncNotedAppOp(AppOpsManager.MODE_IGNORED, code, proxiedAttributionTag,
+ proxiedPackageName);
+ }
if (!isIncomingPackageValid(proxiedPackageName, UserHandle.getUserId(proxiedUid))
|| !isIncomingPackageValid(proxyPackageName, UserHandle.getUserId(proxyUid))) {
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, proxiedAttributionTag,
@@ -2792,8 +2887,9 @@
: AppOpsManager.OP_FLAG_UNTRUSTED_PROXY;
final SyncNotedAppOp proxyReturn = noteOperationUnchecked(code, proxyUid,
- resolveProxyPackageName, proxyAttributionTag, Process.INVALID_UID, null, null,
- proxyFlags, !isProxyTrusted, "proxy " + message, shouldCollectMessage);
+ resolveProxyPackageName, proxyAttributionTag, proxyVirtualDeviceId,
+ Process.INVALID_UID, null, null, proxyFlags, !isProxyTrusted,
+ "proxy " + message, shouldCollectMessage);
if (proxyReturn.getOpMode() != AppOpsManager.MODE_ALLOWED) {
return new SyncNotedAppOp(proxyReturn.getOpMode(), code, proxiedAttributionTag,
proxiedPackageName);
@@ -2810,8 +2906,9 @@
final int proxiedFlags = isProxyTrusted ? AppOpsManager.OP_FLAG_TRUSTED_PROXIED
: AppOpsManager.OP_FLAG_UNTRUSTED_PROXIED;
return noteOperationUnchecked(code, proxiedUid, resolveProxiedPackageName,
- proxiedAttributionTag, proxyUid, resolveProxyPackageName, proxyAttributionTag,
- proxiedFlags, shouldCollectAsyncNotedOp, message, shouldCollectMessage);
+ proxiedAttributionTag, proxyVirtualDeviceId, proxyUid, resolveProxyPackageName,
+ proxyAttributionTag, proxiedFlags, shouldCollectAsyncNotedOp, message,
+ shouldCollectMessage);
}
@Override
@@ -2838,6 +2935,13 @@
boolean shouldCollectMessage) {
verifyIncomingUid(uid);
verifyIncomingOp(code);
+ if (!isValidVirtualDeviceId(virtualDeviceId)) {
+ Slog.w(TAG,
+ "checkOperationImpl returned MODE_IGNORED as virtualDeviceId " + virtualDeviceId
+ + " is invalid");
+ return new SyncNotedAppOp(AppOpsManager.MODE_IGNORED, code, attributionTag,
+ packageName);
+ }
if (!isIncomingPackageValid(packageName, UserHandle.getUserId(uid))) {
// TODO(b/302609140): Remove extra logging after this issue is diagnosed.
if (code == OP_BLUETOOTH_CONNECT) {
@@ -2854,15 +2958,16 @@
packageName);
}
return noteOperationUnchecked(code, uid, resolvedPackageName, attributionTag,
- Process.INVALID_UID, null, null, AppOpsManager.OP_FLAG_SELF,
- shouldCollectAsyncNotedOp, message, shouldCollectMessage);
+ virtualDeviceId, Process.INVALID_UID, null, null,
+ AppOpsManager.OP_FLAG_SELF, shouldCollectAsyncNotedOp, message,
+ shouldCollectMessage);
}
private SyncNotedAppOp noteOperationUnchecked(int code, int uid, @NonNull String packageName,
- @Nullable String attributionTag, int proxyUid, String proxyPackageName,
- @Nullable String proxyAttributionTag, @OpFlags int flags,
- boolean shouldCollectAsyncNotedOp, @Nullable String message,
- boolean shouldCollectMessage) {
+ @Nullable String attributionTag, int virtualDeviceId, int proxyUid,
+ String proxyPackageName, @Nullable String proxyAttributionTag, @OpFlags int flags,
+ boolean shouldCollectAsyncNotedOp, @Nullable String message,
+ boolean shouldCollectMessage) {
PackageVerificationResult pvr;
try {
pvr = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
@@ -2891,8 +2996,8 @@
final Ops ops = getOpsLocked(uid, packageName, attributionTag,
pvr.isAttributionTagValid, pvr.bypass, /* edit */ true);
if (ops == null) {
- scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
- AppOpsManager.MODE_IGNORED);
+ scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, AppOpsManager.MODE_IGNORED);
if (DEBUG) Slog.d(TAG, "noteOperation: no op for code " + code + " uid " + uid
+ " package " + packageName + "flags: " +
AppOpsManager.flagsToString(flags));
@@ -2911,7 +3016,8 @@
packageName);
}
final Op op = getOpLocked(ops, code, uid, true);
- final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag);
+ final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag,
+ getPersistentId(virtualDeviceId));
if (attributedOp.isRunning()) {
Slog.w(TAG, "Noting op not finished: uid " + uid + " pkg " + packageName + " code "
+ code + " startTime of in progress event="
@@ -2920,33 +3026,33 @@
final int switchCode = AppOpsManager.opToSwitch(code);
final UidState uidState = ops.uidState;
- if (isOpRestrictedLocked(uid, code, packageName, attributionTag, pvr.bypass, false)) {
+ if (isOpRestrictedLocked(uid, code, packageName, attributionTag, virtualDeviceId,
+ pvr.bypass, false)) {
attributedOp.rejected(uidState.getState(), flags);
- scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
- AppOpsManager.MODE_IGNORED);
+ scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, AppOpsManager.MODE_IGNORED);
return new SyncNotedAppOp(AppOpsManager.MODE_IGNORED, code, attributionTag,
packageName);
}
- // TODO(b/299330771): Check mode for the relevant device.
// If there is a non-default per UID policy (we set UID op mode only if
// non-default) it takes over, otherwise use the per package policy.
if (mAppOpsCheckingService.getUidMode(
- uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT, switchCode)
+ uidState.uid, getPersistentId(virtualDeviceId), switchCode)
!= AppOpsManager.opToDefaultMode(switchCode)) {
final int uidMode =
uidState.evalMode(
code,
mAppOpsCheckingService.getUidMode(
uidState.uid,
- PERSISTENT_DEVICE_ID_DEFAULT,
+ getPersistentId(virtualDeviceId),
switchCode));
if (uidMode != AppOpsManager.MODE_ALLOWED) {
if (DEBUG) Slog.d(TAG, "noteOperation: uid reject #" + uidMode + " for code "
+ switchCode + " (" + code + ") uid " + uid + " package "
+ packageName + " flags: " + AppOpsManager.flagsToString(flags));
attributedOp.rejected(uidState.getState(), flags);
- scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
- uidMode);
+ scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, uidMode);
// TODO(b/302609140): Remove extra logging after this issue is diagnosed.
if (code == OP_BLUETOOTH_CONNECT && uidMode == MODE_ERRORED) {
Slog.e(TAG, "noting OP_BLUETOOTH_CONNECT returned MODE_ERRORED as"
@@ -2969,8 +3075,8 @@
+ switchCode + " (" + code + ") uid " + uid + " package "
+ packageName + " flags: " + AppOpsManager.flagsToString(flags));
attributedOp.rejected(uidState.getState(), flags);
- scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
- mode);
+ scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, mode);
// TODO(b/302609140): Remove extra logging after this issue is diagnosed.
if (code == OP_BLUETOOTH_CONNECT && mode == MODE_ERRORED) {
Slog.e(TAG, "noting OP_BLUETOOTH_CONNECT returned MODE_ERRORED as"
@@ -2986,11 +3092,10 @@
: "." + attributionTag) + " flags: "
+ AppOpsManager.flagsToString(flags));
}
- scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
- AppOpsManager.MODE_ALLOWED);
+ scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, AppOpsManager.MODE_ALLOWED);
attributedOp.accessed(proxyUid, proxyPackageName, proxyAttributionTag,
- uidState.getState(),
- flags);
+ uidState.getState(), flags);
if (shouldCollectAsyncNotedOp) {
collectAsyncNotedOp(uid, packageName, code, attributionTag, flags, message,
@@ -3314,6 +3419,13 @@
int attributionChainId) {
verifyIncomingUid(uid);
verifyIncomingOp(code);
+ if (!isValidVirtualDeviceId(virtualDeviceId)) {
+ Slog.w(TAG,
+ "startOperationImpl returned MODE_IGNORED as virtualDeviceId " + virtualDeviceId
+ + " is invalid");
+ return new SyncNotedAppOp(AppOpsManager.MODE_IGNORED, code, attributionTag,
+ packageName);
+ }
if (!isIncomingPackageValid(packageName, UserHandle.getUserId(uid))) {
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
packageName);
@@ -3349,9 +3461,9 @@
}
return startOperationUnchecked(clientId, code, uid, packageName, attributionTag,
- Process.INVALID_UID, null, null, OP_FLAG_SELF, startIfModeDefault,
- shouldCollectAsyncNotedOp, message, shouldCollectMessage, attributionFlags,
- attributionChainId);
+ virtualDeviceId, Process.INVALID_UID, null, null, OP_FLAG_SELF,
+ startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage,
+ attributionFlags, attributionChainId);
}
/** @deprecated Use {@link #startProxyOperationWithState} instead. */
@@ -3390,11 +3502,18 @@
final String proxyPackageName = attributionSource.getPackageName();
final String proxyAttributionTag = attributionSource.getAttributionTag();
final int proxiedUid = attributionSource.getNextUid();
+ final int proxyVirtualDeviceId = attributionSource.getDeviceId();
final String proxiedPackageName = attributionSource.getNextPackageName();
final String proxiedAttributionTag = attributionSource.getNextAttributionTag();
verifyIncomingProxyUid(attributionSource);
verifyIncomingOp(code);
+ if (!isValidVirtualDeviceId(proxyVirtualDeviceId)) {
+ Slog.w(TAG, "startProxyOperationImpl returned MODE_IGNORED as virtualDeviceId "
+ + proxyVirtualDeviceId + " is invalid");
+ return new SyncNotedAppOp(AppOpsManager.MODE_IGNORED, code, proxiedAttributionTag,
+ proxiedPackageName);
+ }
if (!isIncomingPackageValid(proxyPackageName, UserHandle.getUserId(proxyUid))
|| !isIncomingPackageValid(proxiedPackageName, UserHandle.getUserId(proxiedUid))) {
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, proxiedAttributionTag,
@@ -3435,7 +3554,8 @@
// Test if the proxied operation will succeed before starting the proxy operation
final SyncNotedAppOp testProxiedOp = startOperationDryRun(code,
proxiedUid, resolvedProxiedPackageName, proxiedAttributionTag,
- resolvedProxyPackageName, proxiedFlags, startIfModeDefault);
+ proxyVirtualDeviceId, resolvedProxyPackageName, proxiedFlags,
+ startIfModeDefault);
if (!shouldStartForMode(testProxiedOp.getOpMode(), startIfModeDefault)) {
return testProxiedOp;
@@ -3445,8 +3565,9 @@
: AppOpsManager.OP_FLAG_UNTRUSTED_PROXY;
final SyncNotedAppOp proxyAppOp = startOperationUnchecked(clientId, code, proxyUid,
- resolvedProxyPackageName, proxyAttributionTag, Process.INVALID_UID, null, null,
- proxyFlags, startIfModeDefault, !isProxyTrusted, "proxy " + message,
+ resolvedProxyPackageName, proxyAttributionTag, proxyVirtualDeviceId,
+ Process.INVALID_UID, null, null, proxyFlags,
+ startIfModeDefault, !isProxyTrusted, "proxy " + message,
shouldCollectMessage, proxyAttributionFlags, attributionChainId);
if (!shouldStartForMode(proxyAppOp.getOpMode(), startIfModeDefault)) {
return proxyAppOp;
@@ -3454,9 +3575,9 @@
}
return startOperationUnchecked(clientId, code, proxiedUid, resolvedProxiedPackageName,
- proxiedAttributionTag, proxyUid, resolvedProxyPackageName, proxyAttributionTag,
- proxiedFlags, startIfModeDefault, shouldCollectAsyncNotedOp, message,
- shouldCollectMessage, proxiedAttributionFlags, attributionChainId);
+ proxiedAttributionTag, proxyVirtualDeviceId, proxyUid, resolvedProxyPackageName,
+ proxyAttributionTag, proxiedFlags, startIfModeDefault, shouldCollectAsyncNotedOp,
+ message, shouldCollectMessage, proxiedAttributionFlags, attributionChainId);
}
private boolean shouldStartForMode(int mode, boolean startIfModeDefault) {
@@ -3464,11 +3585,11 @@
}
private SyncNotedAppOp startOperationUnchecked(IBinder clientId, int code, int uid,
- @NonNull String packageName, @Nullable String attributionTag, int proxyUid,
- String proxyPackageName, @Nullable String proxyAttributionTag, @OpFlags int flags,
- boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message,
- boolean shouldCollectMessage, @AttributionFlags int attributionFlags,
- int attributionChainId) {
+ @NonNull String packageName, @Nullable String attributionTag, int virtualDeviceId,
+ int proxyUid, String proxyPackageName, @Nullable String proxyAttributionTag,
+ @OpFlags int flags, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp,
+ @Nullable String message, boolean shouldCollectMessage,
+ @AttributionFlags int attributionFlags, int attributionChainId) {
PackageVerificationResult pvr;
try {
pvr = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
@@ -3492,8 +3613,8 @@
pvr.isAttributionTagValid, pvr.bypass, /* edit */ true);
if (ops == null) {
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
- flags, AppOpsManager.MODE_IGNORED, startType, attributionFlags,
- attributionChainId);
+ virtualDeviceId, flags, AppOpsManager.MODE_IGNORED, startType,
+ attributionFlags, attributionChainId);
if (DEBUG) Slog.d(TAG, "startOperation: no op for code " + code + " uid " + uid
+ " package " + packageName + " flags: "
+ AppOpsManager.flagsToString(flags));
@@ -3501,23 +3622,23 @@
packageName);
}
final Op op = getOpLocked(ops, code, uid, true);
- final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag);
+ final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag,
+ getPersistentId(virtualDeviceId));
final UidState uidState = ops.uidState;
- isRestricted = isOpRestrictedLocked(uid, code, packageName, attributionTag, pvr.bypass,
- false);
+ isRestricted = isOpRestrictedLocked(uid, code, packageName, attributionTag,
+ virtualDeviceId, pvr.bypass, false);
final int switchCode = AppOpsManager.opToSwitch(code);
- // TODO(b/299330771): Check mode for the relevant device.
// If there is a non-default per UID policy (we set UID op mode only if
// non-default) it takes over, otherwise use the per package policy.
if (mAppOpsCheckingService.getUidMode(
- uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT, switchCode)
+ uidState.uid, getPersistentId(virtualDeviceId), switchCode)
!= AppOpsManager.opToDefaultMode(switchCode)) {
final int uidMode =
uidState.evalMode(
code,
mAppOpsCheckingService.getUidMode(
uidState.uid,
- PERSISTENT_DEVICE_ID_DEFAULT,
+ getPersistentId(virtualDeviceId),
switchCode));
if (!shouldStartForMode(uidMode, startIfModeDefault)) {
if (DEBUG) {
@@ -3527,7 +3648,8 @@
}
attributedOp.rejected(uidState.getState(), flags);
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
- flags, uidMode, startType, attributionFlags, attributionChainId);
+ virtualDeviceId, flags, uidMode, startType, attributionFlags,
+ attributionChainId);
return new SyncNotedAppOp(uidMode, code, attributionTag, packageName);
}
} else {
@@ -3547,7 +3669,8 @@
+ packageName + " flags: " + AppOpsManager.flagsToString(flags));
attributedOp.rejected(uidState.getState(), flags);
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
- flags, mode, startType, attributionFlags, attributionChainId);
+ virtualDeviceId, flags, mode, startType, attributionFlags,
+ attributionChainId);
return new SyncNotedAppOp(mode, code, attributionTag, packageName);
}
}
@@ -3557,19 +3680,19 @@
try {
if (isRestricted) {
attributedOp.createPaused(clientId, proxyUid, proxyPackageName,
- proxyAttributionTag, uidState.getState(), flags,
+ proxyAttributionTag, virtualDeviceId, uidState.getState(), flags,
attributionFlags, attributionChainId);
} else {
attributedOp.started(clientId, proxyUid, proxyPackageName,
- proxyAttributionTag, uidState.getState(), flags,
+ proxyAttributionTag, virtualDeviceId, uidState.getState(), flags,
attributionFlags, attributionChainId);
startType = START_TYPE_STARTED;
}
} catch (RemoteException e) {
throw new RuntimeException(e);
}
- scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag, flags,
- isRestricted ? MODE_IGNORED : MODE_ALLOWED, startType, attributionFlags,
+ scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag, virtualDeviceId,
+ flags, isRestricted ? MODE_IGNORED : MODE_ALLOWED, startType, attributionFlags,
attributionChainId);
}
@@ -3590,7 +3713,7 @@
* the proxied app can successfully start the operation.
*/
private SyncNotedAppOp startOperationDryRun(int code, int uid,
- @NonNull String packageName, @Nullable String attributionTag,
+ @NonNull String packageName, @Nullable String attributionTag, int virtualDeviceId,
String proxyPackageName, @OpFlags int flags,
boolean startIfModeDefault) {
PackageVerificationResult pvr;
@@ -3624,21 +3747,20 @@
}
final Op op = getOpLocked(ops, code, uid, true);
final UidState uidState = ops.uidState;
- isRestricted = isOpRestrictedLocked(uid, code, packageName, attributionTag, pvr.bypass,
- false);
+ isRestricted = isOpRestrictedLocked(uid, code, packageName, attributionTag,
+ virtualDeviceId, pvr.bypass, false);
final int switchCode = AppOpsManager.opToSwitch(code);
- // TODO(b/299330771): Check mode for the relevant device.
// If there is a non-default mode per UID policy (we set UID op mode only if
// non-default) it takes over, otherwise use the per package policy.
if (mAppOpsCheckingService.getUidMode(
- uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT, switchCode)
+ uidState.uid, getPersistentId(virtualDeviceId), switchCode)
!= AppOpsManager.opToDefaultMode(switchCode)) {
final int uidMode =
uidState.evalMode(
code,
mAppOpsCheckingService.getUidMode(
uidState.uid,
- PERSISTENT_DEVICE_ID_DEFAULT,
+ getPersistentId(virtualDeviceId),
switchCode));
if (!shouldStartForMode(uidMode, startIfModeDefault)) {
if (DEBUG) {
@@ -3697,6 +3819,11 @@
String attributionTag, int virtualDeviceId) {
verifyIncomingUid(uid);
verifyIncomingOp(code);
+ if (!isValidVirtualDeviceId(virtualDeviceId)) {
+ Slog.w(TAG, "finishOperationImpl was a no-op as virtualDeviceId " + virtualDeviceId
+ + " is invalid");
+ return;
+ }
if (!isIncomingPackageValid(packageName, UserHandle.getUserId(uid))) {
return;
}
@@ -3706,7 +3833,8 @@
return;
}
- finishOperationUnchecked(clientId, code, uid, resolvedPackageName, attributionTag);
+ finishOperationUnchecked(clientId, code, uid, resolvedPackageName, attributionTag,
+ virtualDeviceId);
}
/** @deprecated Use {@link #finishProxyOperationWithState} instead. */
@@ -3731,6 +3859,7 @@
final String proxyPackageName = attributionSource.getPackageName();
final String proxyAttributionTag = attributionSource.getAttributionTag();
final int proxiedUid = attributionSource.getNextUid();
+ final int proxyVirtualDeviceId = attributionSource.getDeviceId();
final String proxiedPackageName = attributionSource.getNextPackageName();
final String proxiedAttributionTag = attributionSource.getNextAttributionTag();
@@ -3739,6 +3868,11 @@
verifyIncomingProxyUid(attributionSource);
verifyIncomingOp(code);
+ if (!isValidVirtualDeviceId(proxyVirtualDeviceId)) {
+ Slog.w(TAG, "finishProxyOperationImpl was a no-op as virtualDeviceId "
+ + proxyVirtualDeviceId + " is invalid");
+ return null;
+ }
if (!isIncomingPackageValid(proxyPackageName, UserHandle.getUserId(proxyUid))
|| !isIncomingPackageValid(proxiedPackageName, UserHandle.getUserId(proxiedUid))) {
return null;
@@ -3752,7 +3886,7 @@
if (!skipProxyOperation) {
finishOperationUnchecked(clientId, code, proxyUid, resolvedProxyPackageName,
- proxyAttributionTag);
+ proxyAttributionTag, proxyVirtualDeviceId);
}
String resolvedProxiedPackageName = AppOpsManager.resolvePackageName(proxiedUid,
@@ -3762,13 +3896,13 @@
}
finishOperationUnchecked(clientId, code, proxiedUid, resolvedProxiedPackageName,
- proxiedAttributionTag);
+ proxiedAttributionTag, proxyVirtualDeviceId);
return null;
}
private void finishOperationUnchecked(IBinder clientId, int code, int uid, String packageName,
- String attributionTag) {
+ String attributionTag, int virtualDeviceId) {
PackageVerificationResult pvr;
try {
pvr = verifyAndGetBypass(uid, packageName, attributionTag);
@@ -3788,7 +3922,9 @@
+ attributionTag + ") op=" + AppOpsManager.opToName(code));
return;
}
- final AttributedOp attributedOp = op.mAttributions.get(attributionTag);
+ final AttributedOp attributedOp =
+ op.mDeviceAttributedOps.getOrDefault(getPersistentId(virtualDeviceId),
+ new ArrayMap<>()).get(attributionTag);
if (attributedOp == null) {
Slog.e(TAG, "Attribution not found: uid=" + uid + " pkg=" + packageName + "("
+ attributionTag + ") op=" + AppOpsManager.opToName(code));
@@ -3805,8 +3941,8 @@
}
void scheduleOpActiveChangedIfNeededLocked(int code, int uid, @NonNull
- String packageName, @Nullable String attributionTag, boolean active, @AttributionFlags
- int attributionFlags, int attributionChainId) {
+ String packageName, @Nullable String attributionTag, int virtualDeviceId,
+ boolean active, @AttributionFlags int attributionFlags, int attributionChainId) {
ArraySet<ActiveCallback> dispatchedCallbacks = null;
final int callbackListCount = mActiveWatchers.size();
for (int i = 0; i < callbackListCount; i++) {
@@ -3827,13 +3963,14 @@
}
mHandler.sendMessage(PooledLambda.obtainMessage(
AppOpsService::notifyOpActiveChanged,
- this, dispatchedCallbacks, code, uid, packageName, attributionTag, active,
- attributionFlags, attributionChainId));
+ this, dispatchedCallbacks, code, uid, packageName, attributionTag,
+ virtualDeviceId, active, attributionFlags, attributionChainId));
}
private void notifyOpActiveChanged(ArraySet<ActiveCallback> callbacks,
int code, int uid, @NonNull String packageName, @Nullable String attributionTag,
- boolean active, @AttributionFlags int attributionFlags, int attributionChainId) {
+ int virtualDeviceId, boolean active, @AttributionFlags int attributionFlags,
+ int attributionChainId) {
// There are features watching for mode changes such as window manager
// and location manager which are in our process. The callbacks in these
// features may require permissions our remote caller does not have.
@@ -3847,7 +3984,7 @@
continue;
}
callback.mCallback.opActiveChanged(code, uid, packageName, attributionTag,
- active, attributionFlags, attributionChainId);
+ virtualDeviceId, active, attributionFlags, attributionChainId);
} catch (RemoteException e) {
/* do nothing */
}
@@ -3858,7 +3995,7 @@
}
void scheduleOpStartedIfNeededLocked(int code, int uid, String pkgName,
- String attributionTag, @OpFlags int flags, @Mode int result,
+ String attributionTag, int virtualDeviceId, @OpFlags int flags, @Mode int result,
@AppOpsManager.OnOpStartedListener.StartedType int startedType,
@AttributionFlags int attributionFlags, int attributionChainId) {
ArraySet<StartedCallback> dispatchedCallbacks = null;
@@ -3885,13 +4022,14 @@
mHandler.sendMessage(PooledLambda.obtainMessage(
AppOpsService::notifyOpStarted,
- this, dispatchedCallbacks, code, uid, pkgName, attributionTag, flags,
- result, startedType, attributionFlags, attributionChainId));
+ this, dispatchedCallbacks, code, uid, pkgName, attributionTag, virtualDeviceId,
+ flags, result, startedType, attributionFlags, attributionChainId));
}
private void notifyOpStarted(ArraySet<StartedCallback> callbacks,
- int code, int uid, String packageName, String attributionTag, @OpFlags int flags,
- @Mode int result, @AppOpsManager.OnOpStartedListener.StartedType int startedType,
+ int code, int uid, String packageName, String attributionTag, int virtualDeviceId,
+ @OpFlags int flags, @Mode int result,
+ @AppOpsManager.OnOpStartedListener.StartedType int startedType,
@AttributionFlags int attributionFlags, int attributionChainId) {
final long identity = Binder.clearCallingIdentity();
try {
@@ -3902,8 +4040,9 @@
if (shouldIgnoreCallback(code, callback.mCallingPid, callback.mCallingUid)) {
continue;
}
- callback.mCallback.opStarted(code, uid, packageName, attributionTag, flags,
- result, startedType, attributionFlags, attributionChainId);
+ callback.mCallback.opStarted(code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, result, startedType, attributionFlags,
+ attributionChainId);
} catch (RemoteException e) {
/* do nothing */
}
@@ -3914,7 +4053,7 @@
}
private void scheduleOpNotedIfNeededLocked(int code, int uid, String packageName,
- String attributionTag, @OpFlags int flags, @Mode int result) {
+ String attributionTag, int virtualDeviceId, @OpFlags int flags, @Mode int result) {
ArraySet<NotedCallback> dispatchedCallbacks = null;
final int callbackListCount = mNotedWatchers.size();
for (int i = 0; i < callbackListCount; i++) {
@@ -3935,13 +4074,13 @@
}
mHandler.sendMessage(PooledLambda.obtainMessage(
AppOpsService::notifyOpChecked,
- this, dispatchedCallbacks, code, uid, packageName, attributionTag, flags,
- result));
+ this, dispatchedCallbacks, code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, result));
}
private void notifyOpChecked(ArraySet<NotedCallback> callbacks,
- int code, int uid, String packageName, String attributionTag, @OpFlags int flags,
- @Mode int result) {
+ int code, int uid, String packageName, String attributionTag, int virtualDeviceId,
+ @OpFlags int flags, @Mode int result) {
// There are features watching for checks in our process. The callbacks in
// these features may require permissions our remote caller does not have.
final long identity = Binder.clearCallingIdentity();
@@ -3953,8 +4092,8 @@
if (shouldIgnoreCallback(code, callback.mCallingPid, callback.mCallingUid)) {
continue;
}
- callback.mCallback.opNoted(code, uid, packageName, attributionTag, flags,
- result);
+ callback.mCallback.opNoted(code, uid, packageName, attributionTag,
+ virtualDeviceId, flags, result);
} catch (RemoteException e) {
/* do nothing */
}
@@ -4028,6 +4167,22 @@
watcherPid, watcherUid) != PackageManager.PERMISSION_GRANTED;
}
+ private boolean isValidVirtualDeviceId(int virtualDeviceId) {
+ if (virtualDeviceId == Context.DEVICE_ID_DEFAULT) {
+ return true;
+ }
+ if (mVirtualDeviceManagerInternal == null) {
+ return true;
+ }
+ if (mVirtualDeviceManagerInternal.isValidVirtualDeviceId(virtualDeviceId)) {
+ mKnownDeviceIds.put(virtualDeviceId,
+ mVirtualDeviceManagerInternal.getPersistentIdForDevice(virtualDeviceId));
+ return true;
+ }
+
+ return false;
+ }
+
private void verifyIncomingOp(int op) {
if (op >= 0 && op < AppOpsManager._NUM_OP) {
// Enforce manage appops permission if it's a restricted read op.
@@ -4488,7 +4643,12 @@
}
private boolean isOpRestrictedLocked(int uid, int code, String packageName,
- String attributionTag, @Nullable RestrictionBypass appBypass, boolean isCheckOp) {
+ String attributionTag, int virtualDeviceId, @Nullable RestrictionBypass appBypass,
+ boolean isCheckOp) {
+ // Restrictions only apply to the default device.
+ if (virtualDeviceId != Context.DEVICE_ID_DEFAULT) {
+ return false;
+ }
int restrictionSetCount = mOpGlobalRestrictions.size();
for (int i = 0; i < restrictionSetCount; i++) {
@@ -4662,7 +4822,10 @@
private void readAttributionOp(TypedXmlPullParser parser, @NonNull Op parent,
@Nullable String attribution)
throws NumberFormatException, IOException, XmlPullParserException {
- final AttributedOp attributedOp = parent.getOrCreateAttribution(parent, attribution);
+ // TODO(b/308201969): Update this method when we introduce disk persistence of events
+ // for accesses on external devices.
+ final AttributedOp attributedOp =
+ parent.getOrCreateAttribution(parent, attribution, PERSISTENT_DEVICE_ID_DEFAULT);
final long key = parser.getAttributeLong(null, "n");
final int uidState = extractUidStateFromKey(key);
@@ -5369,18 +5532,23 @@
private void dumpStatesLocked(@NonNull PrintWriter pw, @Nullable String filterAttributionTag,
@HistoricalOpsRequestFilter int filter, long nowElapsed, @NonNull Op op, long now,
@NonNull SimpleDateFormat sdf, @NonNull Date date, @NonNull String prefix) {
- final int numAttributions = op.mAttributions.size();
+ // TODO(b/299330771): Dump data for all devices.
+ ArrayMap<String, AttributedOp> defaultDeviceAttributedOps = op.mDeviceAttributedOps.get(
+ PERSISTENT_DEVICE_ID_DEFAULT);
+
+ final int numAttributions = defaultDeviceAttributedOps.size();
for (int i = 0; i < numAttributions; i++) {
if ((filter & FILTER_BY_ATTRIBUTION_TAG) != 0 && !Objects.equals(
- op.mAttributions.keyAt(i), filterAttributionTag)) {
+ defaultDeviceAttributedOps.keyAt(i), filterAttributionTag)) {
continue;
}
- pw.print(prefix + op.mAttributions.keyAt(i) + "=[\n");
- dumpStatesLocked(pw, nowElapsed, op, op.mAttributions.keyAt(i), now, sdf, date,
- prefix + " ");
+ pw.print(prefix + defaultDeviceAttributedOps.keyAt(i) + "=[\n");
+ dumpStatesLocked(pw, nowElapsed, op, defaultDeviceAttributedOps.keyAt(i), now, sdf,
+ date, prefix + " ");
pw.print(prefix + "]\n");
}
+
}
private void dumpStatesLocked(@NonNull PrintWriter pw, long nowElapsed, @NonNull Op op,
@@ -5462,8 +5630,11 @@
pw.println();
}
}
+ // TODO(b/299330771): Dump running starts for all devices.
+ final AttributedOp attributedOp =
+ op.mDeviceAttributedOps.getOrDefault(PERSISTENT_DEVICE_ID_DEFAULT,
+ new ArrayMap<>()).get(attributionTag);
- final AttributedOp attributedOp = op.mAttributions.get(attributionTag);
if (attributedOp.isRunning()) {
long earliestElapsedTime = Long.MAX_VALUE;
long maxNumStarts = 0;
@@ -5828,7 +5999,7 @@
}
for (int i=0; i<mUidStates.size(); i++) {
UidState uidState = mUidStates.valueAt(i);
- // TODO(b/299330771): Get modes for all devices.
+ // TODO(b/299330771): Dump modes for all devices.
final SparseIntArray opModes =
mAppOpsCheckingService.getNonDefaultUidModes(
uidState.uid, PERSISTENT_DEVICE_ID_DEFAULT);
@@ -6043,11 +6214,13 @@
if (restrictionState.setRestriction(code, restricted, excludedPackageTags,
userHandle)) {
+ // Notify on PERSISTENT_DEVICE_ID_DEFAULT only as only the default device is
+ // affected by restrictions.
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyWatchersOfChange, this, code, UID_ANY));
+ AppOpsService::notifyWatchersOnDefaultDevice, this, code, UID_ANY));
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::updateStartedOpModeForUser, this, code, restricted,
- userHandle));
+ AppOpsService::updateStartedOpModeForUserForDefaultDevice, this, code,
+ restricted, userHandle));
}
if (restrictionState.isDefault()) {
@@ -6057,7 +6230,8 @@
}
}
- private void updateStartedOpModeForUser(int code, boolean restricted, int userId) {
+ private void updateStartedOpModeForUserForDefaultDevice(int code, boolean restricted,
+ int userId) {
synchronized (AppOpsService.this) {
int numUids = mUidStates.size();
for (int uidNum = 0; uidNum < numUids; uidNum++) {
@@ -6065,12 +6239,13 @@
if (userId != UserHandle.USER_ALL && UserHandle.getUserId(uid) != userId) {
continue;
}
- updateStartedOpModeForUidLocked(code, restricted, uid);
+ updateStartedOpModeForUidForDefaultDeviceLocked(code, restricted, uid);
}
}
}
- private void updateStartedOpModeForUidLocked(int code, boolean restricted, int uid) {
+ private void updateStartedOpModeForUidForDefaultDeviceLocked(int code, boolean restricted,
+ int uid) {
UidState uidState = mUidStates.get(uid);
if (uidState == null) {
return;
@@ -6089,9 +6264,11 @@
if (mode != MODE_ALLOWED && mode != MODE_FOREGROUND) {
continue;
}
- int numAttrTags = op.mAttributions.size();
- for (int attrNum = 0; attrNum < numAttrTags; attrNum++) {
- AttributedOp attrOp = op.mAttributions.valueAt(attrNum);
+ ArrayMap<String, AttributedOp> defaultDeviceAttributedOps = op.mDeviceAttributedOps.get(
+ PERSISTENT_DEVICE_ID_DEFAULT);
+ for (int tagIndex = 0; tagIndex < defaultDeviceAttributedOps.size();
+ tagIndex++) {
+ AttributedOp attrOp = defaultDeviceAttributedOps.valueAt(tagIndex);
if (restricted && attrOp.isRunning()) {
attrOp.pause();
} else if (attrOp.isPaused()) {
@@ -6101,7 +6278,7 @@
}
}
- private void notifyWatchersOfChange(int code, int uid) {
+ private void notifyWatchersOnDefaultDevice(int code, int uid) {
final ArraySet<OnOpModeChangedListener> modeChangedListenerSet;
synchronized (this) {
modeChangedListenerSet = mOpModeWatchers.get(code);
@@ -6109,8 +6286,7 @@
return;
}
}
-
- notifyOpChanged(modeChangedListenerSet, code, uid, null);
+ notifyOpChanged(modeChangedListenerSet, code, uid, null, PERSISTENT_DEVICE_ID_DEFAULT);
}
@Override
@@ -6582,6 +6758,25 @@
return packageNames;
}
+ @NonNull private String getPersistentId(int virtualDeviceId) {
+ if (virtualDeviceId == Context.DEVICE_ID_DEFAULT) {
+ return PERSISTENT_DEVICE_ID_DEFAULT;
+ }
+ if (mVirtualDeviceManagerInternal == null) {
+ return PERSISTENT_DEVICE_ID_DEFAULT;
+ }
+ String persistentId =
+ mVirtualDeviceManagerInternal.getPersistentIdForDevice(virtualDeviceId);
+ if (persistentId == null) {
+ persistentId = mKnownDeviceIds.get(virtualDeviceId);
+ }
+ if (persistentId != null) {
+ return persistentId;
+ }
+ throw new IllegalStateException(
+ "Requested persistentId for invalid virtualDeviceId: " + virtualDeviceId);
+ }
+
private final class ClientUserRestrictionState implements DeathRecipient {
private final IBinder token;
@@ -6713,12 +6908,14 @@
}
if (restrictionState.setRestriction(code, restricted)) {
+ // Notify on PERSISTENT_DEVICE_ID_DEFAULT only as only the default device is
+ // affected by restrictions.
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::notifyWatchersOfChange, AppOpsService.this, code,
- UID_ANY));
+ AppOpsService::notifyWatchersOnDefaultDevice, AppOpsService.this,
+ code, UID_ANY));
mHandler.sendMessage(PooledLambda.obtainMessage(
- AppOpsService::updateStartedOpModeForUser, AppOpsService.this,
- code, restricted, UserHandle.USER_ALL));
+ AppOpsService::updateStartedOpModeForUserForDefaultDevice,
+ AppOpsService.this, code, restricted, UserHandle.USER_ALL));
}
if (restrictionState.isDefault()) {
diff --git a/services/core/java/com/android/server/appop/AttributedOp.java b/services/core/java/com/android/server/appop/AttributedOp.java
index 0ded75a..94baf88 100644
--- a/services/core/java/com/android/server/appop/AttributedOp.java
+++ b/services/core/java/com/android/server/appop/AttributedOp.java
@@ -42,6 +42,7 @@
final class AttributedOp {
private final @NonNull AppOpsService mAppOpsService;
public final @Nullable String tag;
+ public final @NonNull String persistentDeviceId;
public final @NonNull AppOpsService.Op parent;
/**
@@ -81,9 +82,10 @@
@Nullable ArrayMap<IBinder, InProgressStartOpEvent> mPausedInProgressEvents;
AttributedOp(@NonNull AppOpsService appOpsService, @Nullable String tag,
- @NonNull AppOpsService.Op parent) {
+ @NonNull String persistentDeviceId, @NonNull AppOpsService.Op parent) {
mAppOpsService = appOpsService;
this.tag = tag;
+ this.persistentDeviceId = persistentDeviceId;
this.parent = parent;
}
@@ -196,23 +198,26 @@
*/
public void started(@NonNull IBinder clientId, int proxyUid,
@Nullable String proxyPackageName, @Nullable String proxyAttributionTag,
- @AppOpsManager.UidState int uidState, @AppOpsManager.OpFlags int flags,
- @AppOpsManager.AttributionFlags
- int attributionFlags, int attributionChainId) throws RemoteException {
+ int proxyVirtualDeviceId, @AppOpsManager.UidState int uidState,
+ @AppOpsManager.OpFlags int flags, @AppOpsManager.AttributionFlags int attributionFlags,
+ int attributionChainId) throws RemoteException {
startedOrPaused(clientId, proxyUid, proxyPackageName,
- proxyAttributionTag, uidState, flags, /* triggeredByUidStateChange */ false,
- /* isStarted */ true, attributionFlags, attributionChainId);
+ proxyAttributionTag, proxyVirtualDeviceId, uidState, flags,
+ /* triggeredByUidStateChange */ false, /* isStarted */ true, attributionFlags,
+ attributionChainId);
}
@SuppressWarnings("GuardedBy") // Lock is held on mAppOpsService
private void startedOrPaused(@NonNull IBinder clientId, int proxyUid,
@Nullable String proxyPackageName, @Nullable String proxyAttributionTag,
- @AppOpsManager.UidState int uidState, @AppOpsManager.OpFlags int flags,
- boolean triggeredByUidStateChange, boolean isStarted, @AppOpsManager.AttributionFlags
- int attributionFlags, int attributionChainId) throws RemoteException {
+ int proxyVirtualDeviceId, @AppOpsManager.UidState int uidState,
+ @AppOpsManager.OpFlags int flags, boolean triggeredByUidStateChange,
+ boolean isStarted, @AppOpsManager.AttributionFlags int attributionFlags,
+ int attributionChainId) throws RemoteException {
if (!triggeredByUidStateChange && !parent.isRunning() && isStarted) {
mAppOpsService.scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
- parent.packageName, tag, true, attributionFlags, attributionChainId);
+ parent.packageName, tag, proxyVirtualDeviceId, true, attributionFlags,
+ attributionChainId);
}
if (isStarted && mInProgressEvents == null) {
@@ -227,7 +232,7 @@
InProgressStartOpEvent event = events.get(clientId);
if (event == null) {
event = mAppOpsService.mInProgressStartOpEventPool.acquire(startTime,
- SystemClock.elapsedRealtime(), clientId, tag,
+ SystemClock.elapsedRealtime(), clientId, tag, proxyVirtualDeviceId,
PooledLambda.obtainRunnable(AppOpsService::onClientDeath, this, clientId),
proxyUid, proxyPackageName, proxyAttributionTag, uidState, flags,
attributionFlags, attributionChainId);
@@ -320,8 +325,8 @@
// TODO ntmyren: Also callback for single attribution tag activity changes
if (!triggeredByUidStateChange && !parent.isRunning()) {
mAppOpsService.scheduleOpActiveChangedIfNeededLocked(parent.op,
- parent.uid, parent.packageName, tag, false,
- event.getAttributionFlags(), event.getAttributionChainId());
+ parent.uid, parent.packageName, tag, event.getVirtualDeviceId(),
+ false, event.getAttributionFlags(), event.getAttributionChainId());
}
}
}
@@ -362,11 +367,13 @@
*/
public void createPaused(@NonNull IBinder clientId, int proxyUid,
@Nullable String proxyPackageName, @Nullable String proxyAttributionTag,
- @AppOpsManager.UidState int uidState, @AppOpsManager.OpFlags int flags,
- @AppOpsManager.AttributionFlags
- int attributionFlags, int attributionChainId) throws RemoteException {
+ int proxyVirtualDeviceId, @AppOpsManager.UidState int uidState,
+ @AppOpsManager.OpFlags int flags,
+ @AppOpsManager.AttributionFlags int attributionFlags,
+ int attributionChainId) throws RemoteException {
startedOrPaused(clientId, proxyUid, proxyPackageName, proxyAttributionTag,
- uidState, flags, false, false, attributionFlags, attributionChainId);
+ proxyVirtualDeviceId, uidState, flags, false, false,
+ attributionFlags, attributionChainId);
}
/**
@@ -387,7 +394,7 @@
finishOrPause(event.getClientId(), false, true);
mAppOpsService.scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
- parent.packageName, tag, false,
+ parent.packageName, tag, event.getVirtualDeviceId(), false,
event.getAttributionFlags(), event.getAttributionChainId());
}
mInProgressEvents = null;
@@ -419,14 +426,15 @@
event.getAttributionFlags(), event.getAttributionChainId());
if (shouldSendActive) {
mAppOpsService.scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
- parent.packageName, tag, true, event.getAttributionFlags(),
- event.getAttributionChainId());
+ parent.packageName, tag, event.getVirtualDeviceId(), true,
+ event.getAttributionFlags(), event.getAttributionChainId());
}
// Note: this always sends MODE_ALLOWED, even if the mode is FOREGROUND
// TODO ntmyren: figure out how to get the real mode.
mAppOpsService.scheduleOpStartedIfNeededLocked(parent.op, parent.uid,
- parent.packageName, tag, event.getFlags(), MODE_ALLOWED, START_TYPE_RESUMED,
- event.getAttributionFlags(), event.getAttributionChainId());
+ parent.packageName, tag, event.getVirtualDeviceId(), event.getFlags(),
+ MODE_ALLOWED, START_TYPE_RESUMED, event.getAttributionFlags(),
+ event.getAttributionChainId());
}
mPausedInProgressEvents = null;
}
@@ -488,13 +496,15 @@
// previously removed unfinished start counts back
if (proxy != null) {
startedOrPaused(event.getClientId(), proxy.getUid(),
- proxy.getPackageName(), proxy.getAttributionTag(), newState,
- event.getFlags(), true, isRunning,
+ proxy.getPackageName(), proxy.getAttributionTag(),
+ event.getVirtualDeviceId(), newState, event.getFlags(),
+ true, isRunning,
event.getAttributionFlags(), event.getAttributionChainId());
} else {
startedOrPaused(event.getClientId(), Process.INVALID_UID, null, null,
- newState, event.getFlags(), true, isRunning,
- event.getAttributionFlags(), event.getAttributionChainId());
+ event.getVirtualDeviceId(), newState, event.getFlags(), true,
+ isRunning, event.getAttributionFlags(),
+ event.getAttributionChainId());
}
events = isRunning ? mInProgressEvents : mPausedInProgressEvents;
@@ -508,7 +518,7 @@
"Cannot switch to new uidState " + newState);
}
mAppOpsService.scheduleOpActiveChangedIfNeededLocked(parent.op,
- parent.uid, parent.packageName, tag, false,
+ parent.uid, parent.packageName, tag, event.getVirtualDeviceId(), false,
eventAttributionFlags, eventAttributionChainId);
}
}
@@ -644,6 +654,9 @@
/** Id of the client that started the event */
private @NonNull IBinder mClientId;
+ /** virtual device id */
+ private int mVirtualDeviceId;
+
/** The attribution tag for this operation */
private @Nullable String mAttributionTag;
@@ -685,7 +698,7 @@
* @throws RemoteException If the client is dying
*/
InProgressStartOpEvent(long startTime, long startElapsedTime,
- @NonNull IBinder clientId, @Nullable String attributionTag,
+ @NonNull IBinder clientId, int virtualDeviceId, @Nullable String attributionTag,
@NonNull Runnable onDeath, @AppOpsManager.UidState int uidState,
@Nullable AppOpsManager.OpEventProxyInfo proxy, @AppOpsManager.OpFlags int flags,
@AppOpsManager.AttributionFlags int attributionFlags, int attributionChainId)
@@ -693,6 +706,7 @@
mStartTime = startTime;
mStartElapsedTime = startElapsedTime;
mClientId = clientId;
+ mVirtualDeviceId = virtualDeviceId;
mAttributionTag = attributionTag;
mOnDeath = onDeath;
mUidState = uidState;
@@ -737,7 +751,7 @@
* @throws RemoteException If the client is dying
*/
public void reinit(long startTime, long startElapsedTime, @NonNull IBinder clientId,
- @Nullable String attributionTag, @NonNull Runnable onDeath,
+ @Nullable String attributionTag, int virtualDeviceId, @NonNull Runnable onDeath,
@AppOpsManager.UidState int uidState, @AppOpsManager.OpFlags int flags,
@Nullable AppOpsManager.OpEventProxyInfo proxy,
@AppOpsManager.AttributionFlags int attributionFlags,
@@ -749,6 +763,7 @@
mClientId = clientId;
mAttributionTag = attributionTag;
mOnDeath = onDeath;
+ mVirtualDeviceId = virtualDeviceId;
mUidState = uidState;
mFlags = flags;
@@ -802,6 +817,11 @@
return mAttributionChainId;
}
+ /** @return virtual device id for the access */
+ public int getVirtualDeviceId() {
+ return mVirtualDeviceId;
+ }
+
public void setStartTime(long startTime) {
mStartTime = startTime;
}
@@ -824,11 +844,11 @@
}
InProgressStartOpEvent acquire(long startTime, long elapsedTime, @NonNull IBinder clientId,
- @Nullable String attributionTag, @NonNull Runnable onDeath, int proxyUid,
- @Nullable String proxyPackageName, @Nullable String proxyAttributionTag,
- @AppOpsManager.UidState int uidState, @AppOpsManager.OpFlags int flags,
- @AppOpsManager.AttributionFlags
- int attributionFlags, int attributionChainId) throws RemoteException {
+ @Nullable String attributionTag, int virtualDeviceId, @NonNull Runnable onDeath,
+ int proxyUid, @Nullable String proxyPackageName,
+ @Nullable String proxyAttributionTag, @AppOpsManager.UidState int uidState,
+ @AppOpsManager.OpFlags int flags, @AppOpsManager.AttributionFlags
+ int attributionFlags, int attributionChainId) throws RemoteException {
InProgressStartOpEvent recycled = acquire();
@@ -839,14 +859,15 @@
}
if (recycled != null) {
- recycled.reinit(startTime, elapsedTime, clientId, attributionTag, onDeath,
- uidState, flags, proxyInfo, attributionFlags, attributionChainId,
+ recycled.reinit(startTime, elapsedTime, clientId, attributionTag, virtualDeviceId,
+ onDeath, uidState, flags, proxyInfo, attributionFlags, attributionChainId,
mOpEventProxyInfoPool);
return recycled;
}
- return new InProgressStartOpEvent(startTime, elapsedTime, clientId, attributionTag,
- onDeath, uidState, proxyInfo, flags, attributionFlags, attributionChainId);
+ return new InProgressStartOpEvent(startTime, elapsedTime, clientId, virtualDeviceId,
+ attributionTag, onDeath, uidState, proxyInfo, flags, attributionFlags,
+ attributionChainId);
}
}
diff --git a/services/core/java/com/android/server/appop/OnOpModeChangedListener.java b/services/core/java/com/android/server/appop/OnOpModeChangedListener.java
index 1d1a9e7..f5f34c1 100644
--- a/services/core/java/com/android/server/appop/OnOpModeChangedListener.java
+++ b/services/core/java/com/android/server/appop/OnOpModeChangedListener.java
@@ -16,8 +16,11 @@
package com.android.server.appop;
+import android.companion.virtual.VirtualDeviceManager;
import android.os.RemoteException;
+import java.util.Objects;
+
/**
* Listener for mode changes, encapsulates methods that should be triggered in the event of a mode
* change.
@@ -95,6 +98,20 @@
throws RemoteException;
/**
+ * Method that should be triggered when the app-op's mode is changed.
+ * @param op app-op whose mode-change is being listened to.
+ * @param uid user-is associated with the app-op.
+ * @param packageName package name associated with the app-op.
+ * @param persistentDeviceId device associated with the app-op.
+ */
+ public void onOpModeChanged(int op, int uid, String packageName, String persistentDeviceId)
+ throws RemoteException {
+ if (Objects.equals(persistentDeviceId, VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)) {
+ onOpModeChanged(op, uid, packageName);
+ }
+ }
+
+ /**
* Return human readable string representing the listener.
*/
public abstract String toString();
diff --git a/services/core/java/com/android/server/camera/CameraServiceProxy.java b/services/core/java/com/android/server/camera/CameraServiceProxy.java
index a796544..458fd82 100644
--- a/services/core/java/com/android/server/camera/CameraServiceProxy.java
+++ b/services/core/java/com/android/server/camera/CameraServiceProxy.java
@@ -1292,7 +1292,7 @@
return;
}
if (DEBUG) Slog.v(TAG, "Setting NFC reader mode. enablePolling: " + enablePolling);
- nfcAdapter.setReaderMode(enablePolling);
+ nfcAdapter.setReaderModePollingEnabled(enablePolling);
}
private static int[] toArray(Collection<Integer> c) {
diff --git a/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java b/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java
index 0f40ca0..1715254 100644
--- a/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java
+++ b/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java
@@ -16,8 +16,6 @@
package com.android.server.graphics.fonts;
-import static android.graphics.fonts.FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE;
-
import static com.android.server.graphics.fonts.FontManagerService.SystemFontException;
import android.annotation.NonNull;
@@ -580,11 +578,11 @@
return null;
}
resolvedFonts.add(new FontConfig.Font(info.mFile, null, info.getPostScriptName(),
- font.getFontStyle(), font.getIndex(), font.getFontVariationSettings(), null));
+ font.getFontStyle(), font.getIndex(), font.getFontVariationSettings(),
+ null /* family name */, FontConfig.Font.VAR_TYPE_AXES_NONE));
}
FontConfig.FontFamily family = new FontConfig.FontFamily(resolvedFonts,
- LocaleList.getEmptyLocaleList(), FontConfig.FontFamily.VARIANT_DEFAULT,
- VARIABLE_FONT_FAMILY_TYPE_NONE);
+ LocaleList.getEmptyLocaleList(), FontConfig.FontFamily.VARIANT_DEFAULT);
return new FontConfig.NamedFamilyList(Collections.singletonList(family),
fontFamily.getName());
}
diff --git a/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java b/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java
index 30a4f31..3c3cfe6 100644
--- a/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java
+++ b/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java
@@ -45,6 +45,13 @@
@VisibleForTesting
static final int STATE_WAITING_FOR_REPORT_POWER_STATUS = 1;
+ // State in which the action is delayed. If the action starts and
+ // {@link PowerManager#isInteractive} returns false, it could indicate the beginning of a
+ // standby process. In this scenario, the action will be removed when
+ // {@link HdmiCecLocalDeviceSource#disableDevice} is called, therefore we delay the action.
+ @VisibleForTesting
+ static final int STATE_CHECK_STANDBY_PROCESS_STARTED = 2;
+
// The maximum number of times we send <Give Device Power Status> before we give up.
// We wait up to RESPONSE_TIMEOUT_MS * LOOP_COUNTER_MAX = 20 seconds.
private static final int LOOP_COUNTER_MAX = 10;
@@ -87,6 +94,22 @@
boolean start() {
// Because only source device can create this action, it's safe to cast.
mSource = source();
+
+ if (!mSource.mService.getPowerManager().isInteractive()) {
+ Slog.d(TAG, "PowerManager is not interactive. Delay the action to check if standby"
+ + " started!");
+ mState = STATE_CHECK_STANDBY_PROCESS_STARTED;
+ addTimer(mState, HdmiConfig.TIMEOUT_MS);
+ } else {
+ startAction();
+ }
+
+ return true;
+ }
+
+ private void startAction() {
+ Slog.i(TAG, "Start action.");
+
sendCommand(HdmiCecMessageBuilder.buildTextViewOn(getSourceAddress(), mTargetAddress));
boolean is20TargetOnBefore = mIsCec20 && getTargetDevicePowerStatus(mSource, mTargetAddress,
@@ -116,12 +139,11 @@
maySendActiveSource();
}
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
- return true;
+ return;
}
}
mState = STATE_WAITING_FOR_REPORT_POWER_STATUS;
addTimer(mState, HdmiConfig.TIMEOUT_MS);
- return true;
}
private void setAndBroadcastActiveSource() {
@@ -174,14 +196,22 @@
if (mState != state) {
return;
}
- if (state == STATE_WAITING_FOR_REPORT_POWER_STATUS) {
- if (mPowerStatusCounter++ < LOOP_COUNTER_MAX) {
- queryDevicePowerStatus();
- addTimer(mState, HdmiConfig.TIMEOUT_MS);
- } else {
- // Couldn't wake up the TV for whatever reason. Report failure.
- finishWithCallback(HdmiControlManager.RESULT_TIMEOUT);
- }
+ switch (state) {
+ case STATE_WAITING_FOR_REPORT_POWER_STATUS:
+ if (mPowerStatusCounter++ < LOOP_COUNTER_MAX) {
+ queryDevicePowerStatus();
+ addTimer(mState, HdmiConfig.TIMEOUT_MS);
+ } else {
+ // Couldn't wake up the TV for whatever reason. Report failure.
+ finishWithCallback(HdmiControlManager.RESULT_TIMEOUT);
+ }
+ return;
+ case STATE_CHECK_STANDBY_PROCESS_STARTED:
+ Slog.d(TAG, "Action was not removed, start the action.");
+ startAction();
+ return;
+ default:
+ return;
}
}
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index fb95632..41ff415 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -210,6 +210,9 @@
mDefaultConfig = readDefaultConfig(mContext.getResources());
updateDefaultAutomaticRuleNames();
+ if (Flags.modesApi()) {
+ updateDefaultAutomaticRulePolicies();
+ }
mConfig = mDefaultConfig.copy();
synchronized (mConfigsArrayLock) {
mConfigs.put(UserHandle.USER_SYSTEM, mConfig);
@@ -1966,6 +1969,21 @@
}
}
+ // Updates the policies in the default automatic rules (provided via default XML config) to
+ // be fully filled in default values.
+ private void updateDefaultAutomaticRulePolicies() {
+ if (!Flags.modesApi()) {
+ // Should be checked before calling, but just in case.
+ return;
+ }
+ ZenPolicy defaultPolicy = mDefaultConfig.toZenPolicy();
+ for (ZenRule rule : mDefaultConfig.automaticRules.values()) {
+ if (ZenModeConfig.DEFAULT_RULE_IDS.contains(rule.id) && rule.zenPolicy == null) {
+ rule.zenPolicy = defaultPolicy.copy();
+ }
+ }
+ }
+
@VisibleForTesting
protected void applyRestrictions() {
final boolean zenOn = mZenMode != Global.ZEN_MODE_OFF;
diff --git a/services/core/java/com/android/server/notification/flags.aconfig b/services/core/java/com/android/server/notification/flags.aconfig
index 47967db..dbff442 100644
--- a/services/core/java/com/android/server/notification/flags.aconfig
+++ b/services/core/java/com/android/server/notification/flags.aconfig
@@ -63,4 +63,11 @@
namespace: "systemui"
description: "Timing test, no functionality"
bug: "316931130"
+}
+
+flag {
+ name: "notification_custom_view_uri_restriction"
+ namespace: "systemui"
+ description: "This flag enables memory restriction of notifications holding custom views with Uri Bitmaps"
+ bug: "270553691"
}
\ No newline at end of file
diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java
index 0555d90..0be8e6e 100644
--- a/services/core/java/com/android/server/pm/ComputerEngine.java
+++ b/services/core/java/com/android/server/pm/ComputerEngine.java
@@ -586,7 +586,7 @@
list.add(ri);
PackageManagerServiceUtils.applyEnforceIntentFilterMatching(
mInjector.getCompatibility(), mComponentResolver,
- list, false, intent, resolvedType, flags, filterCallingUid);
+ list, false, intent, resolvedType, filterCallingUid);
}
}
} else {
@@ -616,7 +616,7 @@
// We also have to ensure all components match the original intent
PackageManagerServiceUtils.applyEnforceIntentFilterMatching(
mInjector.getCompatibility(), mComponentResolver,
- list, false, originalIntent, resolvedType, flags, filterCallingUid);
+ list, false, originalIntent, resolvedType, filterCallingUid);
}
return skipPostResolution ? list : applyPostResolutionFilter(
@@ -700,7 +700,7 @@
list.add(ri);
PackageManagerServiceUtils.applyEnforceIntentFilterMatching(
mInjector.getCompatibility(), mComponentResolver,
- list, false, intent, resolvedType, flags, callingUid);
+ list, false, intent, resolvedType, callingUid);
}
}
} else {
@@ -712,7 +712,7 @@
// We also have to ensure all components match the original intent
PackageManagerServiceUtils.applyEnforceIntentFilterMatching(
mInjector.getCompatibility(), mComponentResolver,
- list, false, originalIntent, resolvedType, flags, callingUid);
+ list, false, originalIntent, resolvedType, callingUid);
}
return list;
diff --git a/services/core/java/com/android/server/pm/DexOptHelper.java b/services/core/java/com/android/server/pm/DexOptHelper.java
index a10bae9..3abf3a5 100644
--- a/services/core/java/com/android/server/pm/DexOptHelper.java
+++ b/services/core/java/com/android/server/pm/DexOptHelper.java
@@ -16,7 +16,10 @@
package com.android.server.pm;
+import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_RESTORE;
+import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_SETUP;
import static android.os.Trace.TRACE_TAG_DALVIK;
+import static android.os.incremental.IncrementalManager.isIncrementalPath;
import static com.android.server.LocalManagerRegistry.ManagerNotFoundException;
import static com.android.server.pm.ApexManager.ActiveApexInfo;
@@ -27,6 +30,8 @@
import static com.android.server.pm.PackageManagerService.REASON_BOOT_AFTER_OTA;
import static com.android.server.pm.PackageManagerService.REASON_CMDLINE;
import static com.android.server.pm.PackageManagerService.REASON_FIRST_BOOT;
+import static com.android.server.pm.PackageManagerService.SCAN_AS_APEX;
+import static com.android.server.pm.PackageManagerService.SCAN_AS_INSTANT_APP;
import static com.android.server.pm.PackageManagerService.STUB_SUFFIX;
import static com.android.server.pm.PackageManagerService.TAG;
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
@@ -45,6 +50,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.Flags;
+import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.SharedLibraryInfo;
import android.content.pm.dex.ArtManager;
@@ -54,6 +61,7 @@
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
+import android.provider.Settings.Global;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
@@ -1091,4 +1099,73 @@
+ " has unsupported status " + status);
}
}
+
+ /**
+ * Returns DexoptOptions by the given InstallRequest.
+ */
+ static DexoptOptions getDexoptOptionsByInstallRequest(InstallRequest installRequest,
+ DexManager dexManager) {
+ final PackageSetting ps = installRequest.getScannedPackageSetting();
+ final String packageName = ps.getPackageName();
+ final boolean isBackupOrRestore =
+ installRequest.getInstallReason() == INSTALL_REASON_DEVICE_RESTORE
+ || installRequest.getInstallReason() == INSTALL_REASON_DEVICE_SETUP;
+ final int dexoptFlags = DexoptOptions.DEXOPT_BOOT_COMPLETE
+ | DexoptOptions.DEXOPT_CHECK_FOR_PROFILES_UPDATES
+ | DexoptOptions.DEXOPT_INSTALL_WITH_DEX_METADATA_FILE
+ | (isBackupOrRestore ? DexoptOptions.DEXOPT_FOR_RESTORE : 0);
+ // Compute the compilation reason from the installation scenario.
+ final int compilationReason =
+ dexManager.getCompilationReasonForInstallScenario(
+ installRequest.getInstallScenario());
+ return new DexoptOptions(packageName, compilationReason, dexoptFlags);
+ }
+
+ /**
+ * Use ArtService to perform dexopt by the given InstallRequest.
+ */
+ static DexoptResult dexoptPackageUsingArtService(InstallRequest installRequest,
+ DexoptOptions dexoptOptions) {
+ final PackageSetting ps = installRequest.getScannedPackageSetting();
+ final String packageName = ps.getPackageName();
+
+ PackageManagerLocal packageManagerLocal =
+ LocalManagerRegistry.getManager(PackageManagerLocal.class);
+ try (PackageManagerLocal.FilteredSnapshot snapshot =
+ packageManagerLocal.withFilteredSnapshot()) {
+ boolean ignoreDexoptProfile =
+ (installRequest.getInstallFlags()
+ & PackageManager.INSTALL_IGNORE_DEXOPT_PROFILE)
+ != 0;
+ /*@DexoptFlags*/ int extraFlags =
+ ignoreDexoptProfile && Flags.useArtServiceV2()
+ ? ArtFlags.FLAG_IGNORE_PROFILE
+ : 0;
+ DexoptParams params = dexoptOptions.convertToDexoptParams(extraFlags);
+ DexoptResult dexOptResult = getArtManagerLocal().dexoptPackage(
+ snapshot, packageName, params);
+
+ return dexOptResult;
+ }
+ }
+
+ /**
+ * Returns whether to perform dexopt by the given InstallRequest.
+ */
+ static boolean shouldPerformDexopt(InstallRequest installRequest, DexoptOptions dexoptOptions,
+ Context context) {
+ final boolean isApex = ((installRequest.getScanFlags() & SCAN_AS_APEX) != 0);
+ final boolean instantApp = ((installRequest.getScanFlags() & SCAN_AS_INSTANT_APP) != 0);
+ final PackageSetting ps = installRequest.getScannedPackageSetting();
+ final AndroidPackage pkg = ps.getPkg();
+ final boolean onIncremental = isIncrementalPath(ps.getPathString());
+
+ return (!instantApp || Global.getInt(context.getContentResolver(),
+ Global.INSTANT_APP_DEXOPT_ENABLED, 0) != 0)
+ && pkg != null
+ && !pkg.isDebuggable()
+ && (!onIncremental)
+ && dexoptOptions.isCompilationEnabled()
+ && !isApex;
+ }
}
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java
index e70c5ea..28f3d59 100644
--- a/services/core/java/com/android/server/pm/InstallPackageHelper.java
+++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java
@@ -32,8 +32,6 @@
import static android.content.pm.PackageManager.INSTALL_FAILED_TEST_ONLY;
import static android.content.pm.PackageManager.INSTALL_FAILED_UID_CHANGED;
import static android.content.pm.PackageManager.INSTALL_FAILED_UPDATE_INCOMPATIBLE;
-import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_RESTORE;
-import static android.content.pm.PackageManager.INSTALL_REASON_DEVICE_SETUP;
import static android.content.pm.PackageManager.INSTALL_STAGED;
import static android.content.pm.PackageManager.INSTALL_SUCCEEDED;
import static android.content.pm.PackageManager.UNINSTALL_REASON_UNKNOWN;
@@ -170,10 +168,7 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.CollectionUtils;
import com.android.server.EventLogTags;
-import com.android.server.LocalManagerRegistry;
import com.android.server.SystemConfig;
-import com.android.server.art.model.ArtFlags;
-import com.android.server.art.model.DexoptParams;
import com.android.server.art.model.DexoptResult;
import com.android.server.criticalevents.CriticalEventLog;
import com.android.server.pm.Installer.LegacyDexoptDisabledException;
@@ -800,10 +795,27 @@
"restoreAndPostInstall userId=" + userId + " package=" + request.getPkg());
}
- // A restore should be requested at this point if (a) the install
- // succeeded, (b) the operation is not an update.
+ PackageSetting packageSetting = null;
+
final boolean update = request.isUpdate();
- boolean doRestore = !update && request.getPkg() != null;
+ boolean doRestore = false;
+ if (request.getPkg() != null && !request.isArchived()) {
+ // A restore should be requested at this point:
+ // if the install succeeded and it's not an archived install
+ if (!update) {
+ // AND the operation is not an update,
+ doRestore = true;
+ } else {
+ // OR the package has never been restored.
+ String packageName = request.getPkg().getPackageName();
+ synchronized (mPm.mLock) {
+ packageSetting = mPm.mSettings.getPackageLPr(packageName);
+ if (packageSetting != null && packageSetting.isPendingRestore()) {
+ doRestore = true;
+ }
+ }
+ }
+ }
// Set up the post-install work request bookkeeping. This will be used
// and cleaned up by the post-install event handling regardless of whether
@@ -833,7 +845,13 @@
doRestore = performRollbackManagerRestore(userId, token, request);
}
- if (!doRestore) {
+ if (doRestore) {
+ if (packageSetting != null) {
+ synchronized (mPm.mLock) {
+ packageSetting.setPendingRestore(false);
+ }
+ }
+ } else {
// No restore possible, or the Backup Manager was mysteriously not
// available -- just fire the post-install work request directly.
if (DEBUG_INSTALL) Log.v(TAG, "No restore - queue post-install for " + token);
@@ -2464,8 +2482,6 @@
final ArraySet<IncrementalStorage> incrementalStorages = new ArraySet<>();
for (ReconciledPackage reconciledPkg : reconciledPackages) {
final InstallRequest installRequest = reconciledPkg.mInstallRequest;
- final boolean instantApp = ((installRequest.getScanFlags() & SCAN_AS_INSTANT_APP) != 0);
- final boolean isApex = ((installRequest.getScanFlags() & SCAN_AS_APEX) != 0);
final PackageSetting ps = installRequest.getScannedPackageSetting();
final String packageName = ps.getPackageName();
final String codePath = ps.getPathString();
@@ -2507,28 +2523,14 @@
}
}
- // Compute the compilation reason from the installation scenario.
- final int compilationReason =
- mDexManager.getCompilationReasonForInstallScenario(
- installRequest.getInstallScenario());
-
// Construct the DexoptOptions early to see if we should skip running dexopt.
//
// Do not run PackageDexOptimizer through the local performDexOpt
// method because `pkg` may not be in `mPackages` yet.
//
// Also, don't fail application installs if the dexopt step fails.
- final boolean isBackupOrRestore =
- installRequest.getInstallReason() == INSTALL_REASON_DEVICE_RESTORE
- || installRequest.getInstallReason() == INSTALL_REASON_DEVICE_SETUP;
-
- final int dexoptFlags = DexoptOptions.DEXOPT_BOOT_COMPLETE
- | DexoptOptions.DEXOPT_CHECK_FOR_PROFILES_UPDATES
- | DexoptOptions.DEXOPT_INSTALL_WITH_DEX_METADATA_FILE
- | (isBackupOrRestore ? DexoptOptions.DEXOPT_FOR_RESTORE : 0);
- DexoptOptions dexoptOptions =
- new DexoptOptions(packageName, compilationReason, dexoptFlags);
-
+ DexoptOptions dexoptOptions = DexOptHelper.getDexoptOptionsByInstallRequest(
+ installRequest, mDexManager);
// Check whether we need to dexopt the app.
//
// NOTE: it is IMPORTANT to call dexopt:
@@ -2555,16 +2557,9 @@
//
// TODO(b/174695087): instantApp and onIncremental should be removed and their install
// path moved to SCENARIO_FAST.
- final boolean performDexopt =
- (!instantApp || android.provider.Settings.Global.getInt(
- mContext.getContentResolver(),
- android.provider.Settings.Global.INSTANT_APP_DEXOPT_ENABLED, 0) != 0)
- && pkg != null
- && !pkg.isDebuggable()
- && (!onIncremental)
- && dexoptOptions.isCompilationEnabled()
- && !isApex;
+ final boolean performDexopt = DexOptHelper.shouldPerformDexopt(installRequest,
+ dexoptOptions, mContext);
if (performDexopt) {
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
@@ -2579,23 +2574,9 @@
realPkgSetting.getPkgState().setUpdatedSystemApp(isUpdatedSystemApp);
if (useArtService()) {
- PackageManagerLocal packageManagerLocal =
- LocalManagerRegistry.getManager(PackageManagerLocal.class);
- try (PackageManagerLocal.FilteredSnapshot snapshot =
- packageManagerLocal.withFilteredSnapshot()) {
- boolean ignoreDexoptProfile =
- (installRequest.getInstallFlags()
- & PackageManager.INSTALL_IGNORE_DEXOPT_PROFILE)
- != 0;
- /*@DexoptFlags*/ int extraFlags =
- ignoreDexoptProfile && Flags.useArtServiceV2()
- ? ArtFlags.FLAG_IGNORE_PROFILE
- : 0;
- DexoptParams params = dexoptOptions.convertToDexoptParams(extraFlags);
- DexoptResult dexOptResult = DexOptHelper.getArtManagerLocal().dexoptPackage(
- snapshot, packageName, params);
- installRequest.onDexoptFinished(dexOptResult);
- }
+ DexoptResult dexOptResult = DexOptHelper.dexoptPackageUsingArtService(
+ installRequest, dexoptOptions);
+ installRequest.onDexoptFinished(dexOptResult);
} else {
try {
mPackageDexOptimizer.performDexOpt(pkg, realPkgSetting,
@@ -2919,7 +2900,7 @@
mPm.scheduleDeferredNoKillPostDelete(args);
if (Flags.improveInstallDontKill()) {
synchronized (mPm.mInstallLock) {
- PackageManagerServiceUtils.linkSplitsToOldDirs(mPm.mInstaller,
+ PackageManagerServiceUtils.linkFilesToOldDirs(mPm.mInstaller,
packageName, pkgSetting.getPath(), pkgSetting.getOldPaths());
}
}
diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java
index bc0173a..43328fc 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -1726,7 +1726,8 @@
.scheme("android-app")
.authority(callingPackage)
.build())
- .setPackage(installerPackageName);
+ .setPackage(installerPackageName)
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
@Override
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index dfe705a7..b705e84 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -598,6 +598,8 @@
static final int DEFAULT_FILE_ACCESS_MODE = 0644;
+ static final int DEFAULT_NATIVE_LIBRARY_FILE_ACCESS_MODE = 0755;
+
final Handler mHandler;
final Handler mBackgroundHandler;
@@ -1550,6 +1552,8 @@
}
pkgSetting
.setPkg(null)
+ // This package was installed as archived. Need to mark it for later restore.
+ .setPendingRestore(true)
.modifyUserState(userId)
.setInstalled(false)
.setArchiveState(archiveState);
diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
index 8531692..4f9ed03 100644
--- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
+++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
@@ -23,6 +23,7 @@
import static android.system.OsConstants.O_CREAT;
import static android.system.OsConstants.O_RDWR;
+import static com.android.internal.content.NativeLibraryHelper.LIB64_DIR_NAME;
import static com.android.internal.content.NativeLibraryHelper.LIB_DIR_NAME;
import static com.android.internal.util.FrameworkStatsLog.UNSAFE_INTENT_EVENT_REPORTED__EVENT_TYPE__EXPLICIT_INTENT_FILTER_UNMATCH;
import static com.android.server.LocalManagerRegistry.ManagerNotFoundException;
@@ -31,6 +32,7 @@
import static com.android.server.pm.PackageManagerService.DEBUG_INTENT_MATCHING;
import static com.android.server.pm.PackageManagerService.DEBUG_PREFERRED;
import static com.android.server.pm.PackageManagerService.DEFAULT_FILE_ACCESS_MODE;
+import static com.android.server.pm.PackageManagerService.DEFAULT_NATIVE_LIBRARY_FILE_ACCESS_MODE;
import static com.android.server.pm.PackageManagerService.RANDOM_CODEPATH_PREFIX;
import static com.android.server.pm.PackageManagerService.RANDOM_DIR_PREFIX;
import static com.android.server.pm.PackageManagerService.SHELL_PACKAGE_NAME;
@@ -44,7 +46,7 @@
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.compat.annotation.ChangeId;
-import android.compat.annotation.Disabled;
+import android.compat.annotation.EnabledAfter;
import android.compat.annotation.Overridable;
import android.content.Context;
import android.content.Intent;
@@ -198,7 +200,7 @@
*/
@Overridable
@ChangeId
- @Disabled /* Enforcement reverted in T: b/274147456 */
+ @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
private static final long ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS = 161252188;
/**
@@ -1192,8 +1194,7 @@
public static void applyEnforceIntentFilterMatching(
PlatformCompat compat, ComponentResolverApi resolver,
List<ResolveInfo> resolveInfos, boolean isReceiver,
- Intent intent, String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags,
- int filterCallingUid) {
+ Intent intent, String resolvedType, int filterCallingUid) {
if (DISABLE_ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS.get()) return;
// Do not enforce filter matching when the caller is system or root
@@ -1203,10 +1204,9 @@
? new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM)
: null;
- final boolean defaultOnly = (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0;
-
- final boolean enforce = compat.isChangeEnabledByUidInternal(
- ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS, filterCallingUid);
+ final boolean enforce = android.security.Flags.enforceIntentFilterMatch()
+ && compat.isChangeEnabledByUidInternal(
+ ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS, filterCallingUid);
for (int i = resolveInfos.size() - 1; i >= 0; --i) {
final ComponentInfo info = resolveInfos.get(i).getComponentInfo();
@@ -1237,8 +1237,7 @@
boolean match = false;
for (int j = 0, size = comp.getIntents().size(); j < size; ++j) {
IntentFilter intentFilter = comp.getIntents().get(j).getIntentFilter();
- if (IntentResolver.intentMatchesFilter(
- intentFilter, intent, resolvedType, defaultOnly)) {
+ if (IntentResolver.intentMatchesFilter(intentFilter, intent, resolvedType)) {
match = true;
break;
}
@@ -1557,7 +1556,7 @@
return initiatingPackageName == null || SHELL_PACKAGE_NAME.equals(initiatingPackageName);
}
- public static void linkSplitsToOldDirs(@NonNull Installer installer,
+ public static void linkFilesToOldDirs(@NonNull Installer installer,
@NonNull String packageName,
@NonNull File newPath,
@Nullable Set<File> oldPaths) {
@@ -1572,56 +1571,108 @@
if (filesInNewPath == null || filesInNewPath.length == 0) {
return;
}
- final List<String> splitApkNames = new ArrayList<String>();
- for (int i = 0; i < filesInNewPath.length; i++) {
- if (!filesInNewPath[i].isDirectory() && filesInNewPath[i].toString().endsWith(".apk")) {
- splitApkNames.add(filesInNewPath[i].getName());
+ final List<File> splitApks = new ArrayList<>();
+ for (File file : filesInNewPath) {
+ if (!file.isDirectory() && file.toString().endsWith(".apk")) {
+ splitApks.add(file);
}
}
- final int numSplits = splitApkNames.size();
- if (numSplits == 0) {
+ if (splitApks.isEmpty()) {
return;
}
+ final File[] splitApkNames = splitApks.toArray(new File[0]);
for (File oldPath : oldPaths) {
if (!oldPath.exists()) {
continue;
}
- for (int i = 0; i < numSplits; i++) {
- final String splitApkName = splitApkNames.get(i);
- final File linkedSplit = new File(oldPath, splitApkName);
- if (linkedSplit.exists()) {
- if (DEBUG) {
- Slog.d(PackageManagerService.TAG, "Skipping existing linked split <"
- + linkedSplit + ">");
- }
- continue;
- }
- final File sourceSplit = new File(newPath, splitApkName);
- try {
- installer.linkFile(packageName, splitApkName,
- newPath.getAbsolutePath(), oldPath.getAbsolutePath());
- if (DEBUG) {
- Slog.d(PackageManagerService.TAG, "Linked <"
- + sourceSplit + "> to <" + linkedSplit + ">");
- }
- } catch (Installer.InstallerException e) {
- Slog.w(PackageManagerService.TAG, "Failed to link split <"
- + sourceSplit + " > to <" + linkedSplit + ">", e);
- continue;
- }
- try {
- Os.chmod(linkedSplit.getAbsolutePath(), DEFAULT_FILE_ACCESS_MODE);
- } catch (ErrnoException e) {
- Slog.w(PackageManagerService.TAG, "Failed to set mode for linked split <"
- + linkedSplit + ">", e);
- continue;
- }
- if (!SELinux.restorecon(linkedSplit)) {
- Slog.w(PackageManagerService.TAG, "Failed to restorecon for linked split <"
- + linkedSplit + ">");
- }
+ linkFilesAndSetModes(installer, packageName, newPath, oldPath, splitApkNames,
+ DEFAULT_FILE_ACCESS_MODE);
+ linkNativeLibraries(installer, packageName, newPath, oldPath, LIB_DIR_NAME);
+ linkNativeLibraries(installer, packageName, newPath, oldPath, LIB64_DIR_NAME);
+ }
+
+ }
+
+ private static void linkNativeLibraries(@NonNull Installer installer,
+ @NonNull String packageName,
+ @NonNull File sourcePath, @NonNull File targetPath,
+ @NonNull String libDirName) {
+ final File sourceLibDir = new File(sourcePath, libDirName);
+ if (!sourceLibDir.exists()) {
+ return;
+ }
+ final File targetLibDir = new File(targetPath, libDirName);
+ if (!targetLibDir.exists()) {
+ try {
+ NativeLibraryHelper.createNativeLibrarySubdir(targetLibDir);
+ } catch (IOException e) {
+ Slog.w(PackageManagerService.TAG, "Failed to create native library dir at <"
+ + targetLibDir + ">", e);
+ return;
}
}
- //TODO(b/291212866): support native libs
+ final File[] archs = sourceLibDir.listFiles();
+ if (archs == null) {
+ return;
+ }
+ for (File arch : archs) {
+ final File targetArchDir = new File(targetLibDir, arch.getName());
+ if (!targetArchDir.exists()) {
+ try {
+ NativeLibraryHelper.createNativeLibrarySubdir(targetArchDir);
+ } catch (IOException e) {
+ Slog.w(PackageManagerService.TAG, "Failed to create native library subdir at <"
+ + targetArchDir + ">", e);
+ continue;
+ }
+ }
+ final File sourceArchDir = new File(sourceLibDir, arch.getName());
+ final File[] files = sourceArchDir.listFiles();
+ if (files == null || files.length == 0) {
+ continue;
+ }
+ linkFilesAndSetModes(installer, packageName, sourceArchDir, targetArchDir, files,
+ DEFAULT_NATIVE_LIBRARY_FILE_ACCESS_MODE);
+ }
+ }
+
+ // Link the files with specified names from under the sourcePath to be under the targetPath
+ private static void linkFilesAndSetModes(@NonNull Installer installer, String packageName,
+ @NonNull File sourcePath, @NonNull File targetPath, @NonNull File[] files, int mode) {
+ for (File file : files) {
+ final String fileName = file.getName();
+ final File sourceFile = new File(sourcePath, fileName);
+ final File targetFile = new File(targetPath, fileName);
+ if (targetFile.exists()) {
+ if (DEBUG) {
+ Slog.d(PackageManagerService.TAG, "Skipping existing linked file <"
+ + targetFile + ">");
+ }
+ continue;
+ }
+ try {
+ installer.linkFile(packageName, fileName,
+ sourcePath.getAbsolutePath(), targetPath.getAbsolutePath());
+ if (DEBUG) {
+ Slog.d(PackageManagerService.TAG, "Linked <"
+ + sourceFile + "> to <" + targetFile + ">");
+ }
+ } catch (Installer.InstallerException e) {
+ Slog.w(PackageManagerService.TAG, "Failed to link native library <"
+ + sourceFile + "> to <" + targetFile + ">", e);
+ continue;
+ }
+ try {
+ Os.chmod(targetFile.getAbsolutePath(), mode);
+ } catch (ErrnoException e) {
+ Slog.w(PackageManagerService.TAG, "Failed to set mode for linked file <"
+ + targetFile + ">", e);
+ continue;
+ }
+ if (!SELinux.restorecon(targetFile)) {
+ Slog.w(PackageManagerService.TAG, "Failed to restorecon for linked file <"
+ + targetFile + ">");
+ }
+ }
}
}
diff --git a/services/core/java/com/android/server/pm/PackageSetting.java b/services/core/java/com/android/server/pm/PackageSetting.java
index 74c482b..f474d32 100644
--- a/services/core/java/com/android/server/pm/PackageSetting.java
+++ b/services/core/java/com/android/server/pm/PackageSetting.java
@@ -94,7 +94,8 @@
INSTALL_PERMISSION_FIXED,
UPDATE_AVAILABLE,
FORCE_QUERYABLE_OVERRIDE,
- SCANNED_AS_STOPPED_SYSTEM_APP
+ SCANNED_AS_STOPPED_SYSTEM_APP,
+ PENDING_RESTORE,
})
public @interface Flags {
}
@@ -102,6 +103,7 @@
private static final int UPDATE_AVAILABLE = 1 << 1;
private static final int FORCE_QUERYABLE_OVERRIDE = 1 << 2;
private static final int SCANNED_AS_STOPPED_SYSTEM_APP = 1 << 3;
+ private static final int PENDING_RESTORE = 1 << 4;
}
private int mBooleans;
@@ -543,6 +545,20 @@
return mSharedUserAppId > 0;
}
+ /**
+ * @see PackageState#isPendingRestore()
+ */
+ public PackageSetting setPendingRestore(boolean value) {
+ setBoolean(Booleans.PENDING_RESTORE, value);
+ onChanged();
+ return this;
+ }
+
+ @Override
+ public boolean isPendingRestore() {
+ return getBoolean(Booleans.PENDING_RESTORE);
+ }
+
@Override
public String toString() {
return "PackageSetting{"
diff --git a/services/core/java/com/android/server/pm/ResolveIntentHelper.java b/services/core/java/com/android/server/pm/ResolveIntentHelper.java
index 203e1de..b664e39 100644
--- a/services/core/java/com/android/server/pm/ResolveIntentHelper.java
+++ b/services/core/java/com/android/server/pm/ResolveIntentHelper.java
@@ -459,7 +459,7 @@
list.add(ri);
PackageManagerServiceUtils.applyEnforceIntentFilterMatching(
mPlatformCompat, componentResolver, list, true, intent,
- resolvedType, flags, filterCallingUid);
+ resolvedType, filterCallingUid);
}
}
} else {
@@ -485,7 +485,7 @@
// We also have to ensure all components match the original intent
PackageManagerServiceUtils.applyEnforceIntentFilterMatching(
mPlatformCompat, componentResolver,
- list, true, originalIntent, resolvedType, flags, filterCallingUid);
+ list, true, originalIntent, resolvedType, filterCallingUid);
}
return computer.applyPostResolutionFilter(list, instantAppPkgName, false, queryingUid,
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 1ec37f4..c7ee649 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -4883,7 +4883,7 @@
@NeverCompile // Avoid size overhead of debugging code.
void dumpPackageLPr(PrintWriter pw, String prefix, String checkinTag,
- ArraySet<String> permissionNames, PackageSetting ps,
+ ArraySet<String> permissionNames, @NonNull PackageSetting ps,
LegacyPermissionState permissionsState, SimpleDateFormat sdf, Date date,
List<UserInfo> users, boolean dumpAll, boolean dumpAllComponents) {
AndroidPackage pkg = ps.getPkg();
@@ -5022,6 +5022,10 @@
pw.print(prefix); pw.print(" privateFlags="); printFlags(pw,
privateFlags, PRIVATE_FLAG_DUMP_SPEC); pw.println();
}
+ if (ps.isPendingRestore()) {
+ pw.print(prefix); pw.print(" pendingRestore=true");
+ pw.println();
+ }
if (!pkg.isUpdatableSystem()) {
pw.print(prefix); pw.print(" updatableSystem=false");
pw.println();
@@ -5232,6 +5236,9 @@
pw.print(prefix); pw.print(" privatePkgFlags="); printFlags(pw, ps.getPrivateFlags(),
PRIVATE_FLAG_DUMP_SPEC);
pw.println();
+ if (ps.isPendingRestore()) {
+ pw.print(prefix); pw.println(" pendingRestore=true");
+ }
pw.print(prefix); pw.print(" apexModuleName="); pw.println(ps.getApexModuleName());
if (pkg != null && pkg.getOverlayTarget() != null) {
diff --git a/services/core/java/com/android/server/pm/pkg/PackageState.java b/services/core/java/com/android/server/pm/pkg/PackageState.java
index a7ae4eb..e0ee199 100644
--- a/services/core/java/com/android/server/pm/pkg/PackageState.java
+++ b/services/core/java/com/android/server/pm/pkg/PackageState.java
@@ -265,6 +265,14 @@
*/
boolean hasSharedUser();
+
+ /**
+ * Whether this app needs to be restore during next install/update.
+ * E.g. if an app was installed as archived and never had a chance to restore its data.
+ * @hide
+ */
+ boolean isPendingRestore();
+
/**
* Retrieves the shared user app ID. Note that the actual shared user data is not available here
* and must be queried separately.
diff --git a/services/core/java/com/android/server/pm/verify/domain/OWNERS b/services/core/java/com/android/server/pm/verify/domain/OWNERS
index c669112..b451fe4 100644
--- a/services/core/java/com/android/server/pm/verify/domain/OWNERS
+++ b/services/core/java/com/android/server/pm/verify/domain/OWNERS
@@ -1,5 +1,4 @@
# Bug component: 36137
+include /PACKAGE_MANAGER_OWNERS
-chiuwinson@google.com
-patb@google.com
-toddke@google.com
\ No newline at end of file
+wloh@google.com
\ No newline at end of file
diff --git a/services/core/java/com/android/server/policy/PermissionPolicyService.java b/services/core/java/com/android/server/policy/PermissionPolicyService.java
index 61348b5..f15646f 100644
--- a/services/core/java/com/android/server/policy/PermissionPolicyService.java
+++ b/services/core/java/com/android/server/policy/PermissionPolicyService.java
@@ -43,6 +43,7 @@
import android.app.KeyguardManager;
import android.app.TaskInfo;
import android.app.compat.CompatChanges;
+import android.companion.virtual.VirtualDeviceManager;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
import android.content.BroadcastReceiver;
@@ -234,7 +235,12 @@
this::synchronizeUidPermissionsAndAppOpsAsync);
mAppOpsCallback = new IAppOpsCallback.Stub() {
- public void opChanged(int op, int uid, @Nullable String packageName) {
+ public void opChanged(int op, int uid, @Nullable String packageName,
+ String persistentDeviceId) {
+ if (Objects.equals(persistentDeviceId,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)) {
+ return;
+ }
if (packageName != null) {
synchronizeUidPermissionsAndAppOpsAsync(uid);
}
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java b/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
index b271a03..a4c6959 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
@@ -18,6 +18,7 @@
import android.annotation.Nullable;
import android.app.ITransientNotificationCallback;
+import android.content.ComponentName;
import android.hardware.fingerprint.IUdfpsRefreshRateRequestCallback;
import android.os.Bundle;
import android.os.IBinder;
@@ -241,4 +242,17 @@
* @see com.android.internal.statusbar.IStatusBar#showMediaOutputSwitcher
*/
void showMediaOutputSwitcher(String packageName);
+
+ /**
+ * Add a tile to the Quick Settings Panel
+ * @param tile the ComponentName of the {@link android.service.quicksettings.TileService}
+ * @param end if true, the tile will be added at the end. If false, at the beginning.
+ */
+ void addQsTileToFrontOrEnd(ComponentName tile, boolean end);
+
+ /**
+ * Remove the tile from the Quick Settings Panel
+ * @param tile the ComponentName of the {@link android.service.quicksettings.TileService}
+ */
+ void removeQsTile(ComponentName tile);
}
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index b21721a..4955358 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -89,6 +89,7 @@
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsController.Appearance;
import android.view.WindowInsetsController.Behavior;
+import android.view.accessibility.Flags;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
@@ -834,6 +835,20 @@
}
}
}
+
+ @Override
+ public void addQsTileToFrontOrEnd(ComponentName tile, boolean end) {
+ if (Flags.a11yQsShortcut()) {
+ StatusBarManagerService.this.addQsTileToFrontOrEnd(tile, end);
+ }
+ }
+
+ @Override
+ public void removeQsTile(ComponentName tile) {
+ if (Flags.a11yQsShortcut()) {
+ StatusBarManagerService.this.remTile(tile);
+ }
+ }
};
private final GlobalActionsProvider mGlobalActionsProvider = new GlobalActionsProvider() {
@@ -934,11 +949,26 @@
}
public void addTile(ComponentName component) {
+ if (Flags.a11yQsShortcut()) {
+ addQsTileToFrontOrEnd(component, false);
+ } else {
+ enforceStatusBarOrShell();
+
+ if (mBar != null) {
+ try {
+ mBar.addQsTile(component);
+ } catch (RemoteException ex) {
+ }
+ }
+ }
+ }
+
+ private void addQsTileToFrontOrEnd(ComponentName tile, boolean end) {
enforceStatusBarOrShell();
if (mBar != null) {
try {
- mBar.addQsTile(component);
+ mBar.addQsTileToFrontOrEnd(tile, end);
} catch (RemoteException ex) {
}
}
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index e434df7..089a886 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -2791,6 +2791,29 @@
}
@Override
+ public void notifyTvAdSessionData(
+ IBinder sessionToken, String type, Bundle data, int userId) {
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ final int resolvedUserId = resolveCallingUserId(callingPid, callingUid,
+ userId, "notifyTvAdSessionData");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ SessionState sessionState = getSessionStateLocked(sessionToken, callingUid,
+ resolvedUserId);
+ getSessionLocked(sessionState).notifyTvAdSessionData(type, data);
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slog.e(TAG, "error in notifyTvAdSessionData", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public int getClientPid(String sessionId) {
ensureTunerResourceAccessPermission();
final long identity = Binder.clearCallingIdentity();
@@ -4322,6 +4345,23 @@
}
}
}
+
+ @Override
+ public void onTvInputSessionData(String type, Bundle data) {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slog.d(TAG, "onTvInputSessionData()");
+ }
+ if (mSessionState.session == null || mSessionState.client == null) {
+ return;
+ }
+ try {
+ mSessionState.client.onTvInputSessionData(type, data, mSessionState.seq);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "error in onTvInputSessionData", e);
+ }
+ }
+ }
}
@VisibleForTesting
diff --git a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
index eacd3f8..ffce50e 100644
--- a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
+++ b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
@@ -937,6 +937,41 @@
}
@Override
+ public void sendAppLinkCommand(String serviceId, Bundle command, int userId) {
+ final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, "sendAppLinkCommand");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ UserState userState = getOrCreateUserStateLocked(resolvedUserId);
+ TvAdServiceState adServiceState = userState.mAdServiceMap.get(serviceId);
+ if (adServiceState == null) {
+ Slogf.e(TAG, "failed to sendAppLinkCommand - unknown service id "
+ + serviceId);
+ return;
+ }
+ ComponentName componentName = adServiceState.mInfo.getComponent();
+ AdServiceState serviceState = userState.mAdServiceStateMap.get(componentName);
+ if (serviceState == null) {
+ serviceState = new AdServiceState(componentName, serviceId, resolvedUserId);
+ serviceState.addPendingAppLinkCommand(command);
+ userState.mAdServiceStateMap.put(componentName, serviceState);
+ updateAdServiceConnectionLocked(componentName, resolvedUserId);
+ } else if (serviceState.mService != null) {
+ serviceState.mService.sendAppLinkCommand(command);
+ } else {
+ serviceState.addPendingAppLinkCommand(command);
+ updateAdServiceConnectionLocked(componentName, resolvedUserId);
+ }
+ }
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in sendAppLinkCommand", e);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public void createSession(final ITvAdClient client, final String serviceId, String type,
int seq, int userId) {
final int callingUid = Binder.getCallingUid();
@@ -1320,6 +1355,32 @@
}
@Override
+ public void notifyTvInputSessionData(
+ IBinder sessionToken, String type, Bundle data, int userId) {
+ if (DEBUG) {
+ Slogf.d(TAG, "notifyTvInputSessionData(type=%d)", type);
+ }
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+ final int resolvedUserId = resolveCallingUserId(callingPid, callingUid, userId,
+ "notifyTvInputSessionData");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ try {
+ AdSessionState sessionState =
+ getAdSessionStateLocked(sessionToken, callingUid, resolvedUserId);
+ getAdSessionLocked(sessionState).notifyTvInputSessionData(type, data);
+ } catch (RemoteException | SessionNotFoundException e) {
+ Slogf.e(TAG, "error in notifyTvInputSessionData", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
public void registerCallback(final ITvAdManagerCallback callback, int userId) {
int callingPid = Binder.getCallingPid();
int callingUid = Binder.getCallingUid();
@@ -4358,6 +4419,110 @@
}
}
+ @Override
+ public void onRequestCurrentVideoBounds() {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onRequestCurrentVideoBounds");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onRequestCurrentVideoBounds(mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onRequestCurrentVideoBounds", e);
+ }
+ }
+ }
+
+ @Override
+ public void onRequestCurrentChannelUri() {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onRequestCurrentChannelUri");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onRequestCurrentChannelUri(mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onRequestCurrentChannelUri", e);
+ }
+ }
+ }
+
+ @Override
+ public void onRequestTrackInfoList() {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onRequestTrackInfoList");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onRequestTrackInfoList(mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onRequestTrackInfoList", e);
+ }
+ }
+ }
+
+ @Override
+ public void onRequestCurrentTvInputId() {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onRequestCurrentTvInputId");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onRequestCurrentTvInputId(mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onRequestCurrentTvInputId", e);
+ }
+ }
+ }
+
+
+ @Override
+ public void onRequestSigning(String id, String algorithm, String alias, byte[] data) {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onRequestSigning");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onRequestSigning(
+ id, algorithm, alias, data, mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onRequestSigning", e);
+ }
+ }
+ }
+
+ @Override
+ public void onTvAdSessionData(String type, Bundle data) {
+ synchronized (mLock) {
+ if (DEBUG) {
+ Slogf.d(TAG, "onTvAdSessionData");
+ }
+ if (mSessionState.mSession == null || mSessionState.mClient == null) {
+ return;
+ }
+ try {
+ mSessionState.mClient.onTvAdSessionData(type, data, mSessionState.mSeq);
+ } catch (RemoteException e) {
+ Slogf.e(TAG, "error in onTvAdSessionData", e);
+ }
+ }
+ }
+
@GuardedBy("mLock")
private boolean addAdSessionTokenToClientStateLocked(ITvAdSession session) {
try {
diff --git a/services/core/java/com/android/server/vcn/VcnContext.java b/services/core/java/com/android/server/vcn/VcnContext.java
index ed04e5f..1383708 100644
--- a/services/core/java/com/android/server/vcn/VcnContext.java
+++ b/services/core/java/com/android/server/vcn/VcnContext.java
@@ -34,7 +34,7 @@
@NonNull private final Looper mLooper;
@NonNull private final VcnNetworkProvider mVcnNetworkProvider;
@NonNull private final FeatureFlags mFeatureFlags;
- @NonNull private final com.android.net.flags.FeatureFlags mCoreNetFeatureFlags;
+ @NonNull private final android.net.platform.flags.FeatureFlags mCoreNetFeatureFlags;
private final boolean mIsInTestMode;
public VcnContext(
@@ -49,7 +49,7 @@
// Auto-generated class
mFeatureFlags = new FeatureFlagsImpl();
- mCoreNetFeatureFlags = new com.android.net.flags.FeatureFlagsImpl();
+ mCoreNetFeatureFlags = new android.net.platform.flags.FeatureFlagsImpl();
}
@NonNull
diff --git a/services/core/java/com/android/server/vibrator/VibrationScaler.java b/services/core/java/com/android/server/vibrator/VibrationScaler.java
index 0a7872f..c9805c7 100644
--- a/services/core/java/com/android/server/vibrator/VibrationScaler.java
+++ b/services/core/java/com/android/server/vibrator/VibrationScaler.java
@@ -17,10 +17,10 @@
package com.android.server.vibrator;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.content.Context;
import android.hardware.vibrator.V1_0.EffectStrength;
import android.os.IExternalVibratorService;
+import android.os.VibrationAttributes;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.os.vibrator.Flags;
@@ -57,8 +57,7 @@
private final SparseArray<ScaleLevel> mScaleLevels;
private final VibrationSettings mSettingsController;
private final int mDefaultVibrationAmplitude;
-
- private SparseArray<Float> mAdaptiveHapticsScales;
+ private final SparseArray<Float> mAdaptiveHapticsScales = new SparseArray<>();
VibrationScaler(Context context, VibrationSettings settingsController) {
mSettingsController = settingsController;
@@ -147,7 +146,7 @@
// If adaptive haptics scaling is available for this usage, apply it to the segment.
if (Flags.adaptiveHapticsEnabled()
- && mAdaptiveHapticsScales != null && mAdaptiveHapticsScales.size() > 0
+ && mAdaptiveHapticsScales.size() > 0
&& mAdaptiveHapticsScales.contains(usageHint)) {
float adaptiveScale = mAdaptiveHapticsScales.get(usageHint);
segment = segment.scale(adaptiveScale);
@@ -187,13 +186,35 @@
}
/**
- * Updates the adaptive haptics scales.
- * @param scales the new vibration scales to apply.
+ * Updates the adaptive haptics scales list by adding or modifying the scale for this usage.
+ *
+ * @param usageHint one of VibrationAttributes.USAGE_*.
+ * @param scale The scaling factor that should be applied to vibrations of this usage.
*
* @hide
*/
- public void updateAdaptiveHapticsScales(@Nullable SparseArray<Float> scales) {
- mAdaptiveHapticsScales = scales;
+ public void updateAdaptiveHapticsScale(@VibrationAttributes.Usage int usageHint, float scale) {
+ mAdaptiveHapticsScales.put(usageHint, scale);
+ }
+
+ /**
+ * Removes the usage from the cached adaptive haptics scales list.
+ *
+ * @param usageHint one of VibrationAttributes.USAGE_*.
+ *
+ * @hide
+ */
+ public void removeAdaptiveHapticsScale(@VibrationAttributes.Usage int usageHint) {
+ mAdaptiveHapticsScales.remove(usageHint);
+ }
+
+ /**
+ * Removes all cached adaptive haptics scales.
+ *
+ * @hide
+ */
+ public void clearAdaptiveHapticsScales() {
+ mAdaptiveHapticsScales.clear();
}
/** Mapping of Vibrator.VIBRATION_INTENSITY_* values to {@link EffectStrength}. */
diff --git a/services/core/java/com/android/server/vibrator/VibrationSettings.java b/services/core/java/com/android/server/vibrator/VibrationSettings.java
index 839c207..fab0430 100644
--- a/services/core/java/com/android/server/vibrator/VibrationSettings.java
+++ b/services/core/java/com/android/server/vibrator/VibrationSettings.java
@@ -376,6 +376,25 @@
}
/**
+ * Returns the duration, in milliseconds, that the vibrator control service will wait for new
+ * vibration params.
+ * @return The request vibration params timeout in milliseconds.
+ * @hide
+ */
+ public int getRequestVibrationParamsTimeoutMs() {
+ return mVibrationConfig.getRequestVibrationParamsTimeoutMs();
+ }
+
+ /**
+ * The list of usages that should request vibration params before they are played. These
+ * usages don't have strong latency requirements, e.g. ringtone and notification, and can be
+ * slightly delayed.
+ */
+ public int[] getRequestVibrationParamsForUsages() {
+ return mVibrationConfig.getRequestVibrationParamsForUsages();
+ }
+
+ /**
* Return a {@link VibrationEffect} that should be played if the device do not support given
* {@code effectId}.
*
diff --git a/services/core/java/com/android/server/vibrator/VibrationStepConductor.java b/services/core/java/com/android/server/vibrator/VibrationStepConductor.java
index 624da80..9cf942e 100644
--- a/services/core/java/com/android/server/vibrator/VibrationStepConductor.java
+++ b/services/core/java/com/android/server/vibrator/VibrationStepConductor.java
@@ -21,7 +21,9 @@
import android.os.Build;
import android.os.CombinedVibration;
import android.os.IBinder;
+import android.os.VibrationAttributes;
import android.os.VibrationEffect;
+import android.os.vibrator.Flags;
import android.os.vibrator.PrebakedSegment;
import android.os.vibrator.PrimitiveSegment;
import android.os.vibrator.RampSegment;
@@ -38,6 +40,8 @@
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
/**
* Creates and manages a queue of steps for performing a VibrationEffect, as well as coordinating
@@ -65,15 +69,18 @@
public final VibrationThread.VibratorManagerHooks vibratorManagerHooks;
private final DeviceAdapter mDeviceAdapter;
+ private final VibrationScaler mVibrationScaler;
// Not guarded by lock because it's mostly used to read immutable fields by this conductor.
// This is only modified here at the prepareToStart method which always runs at the vibration
// thread, to update the adapted effect and report start time.
private final HalVibration mVibration;
-
private final PriorityQueue<Step> mNextSteps = new PriorityQueue<>();
private final Queue<Step> mPendingOnVibratorCompleteSteps = new LinkedList<>();
+ @Nullable
+ private final CompletableFuture<Void> mRequestVibrationParamsFuture;
+
// Signalling fields.
// Note that vibrator callback signals may happen inside vibrator HAL calls made by the
// VibrationThread, or on an external executor, so this lock should not be held for anything
@@ -97,10 +104,14 @@
VibrationStepConductor(HalVibration vib, VibrationSettings vibrationSettings,
DeviceAdapter deviceAdapter,
+ VibrationScaler vibrationScaler,
+ CompletableFuture<Void> requestVibrationParamsFuture,
VibrationThread.VibratorManagerHooks vibratorManagerHooks) {
this.mVibration = vib;
this.vibrationSettings = vibrationSettings;
this.mDeviceAdapter = deviceAdapter;
+ mVibrationScaler = vibrationScaler;
+ mRequestVibrationParamsFuture = requestVibrationParamsFuture;
this.vibratorManagerHooks = vibratorManagerHooks;
this.mSignalVibratorsComplete =
new IntArray(mDeviceAdapter.getAvailableVibratorIds().length);
@@ -143,7 +154,15 @@
if (Build.IS_DEBUGGABLE) {
expectIsVibrationThread(true);
}
- // Scaling happened before the effect was dispatched to this conductor (or to input devices)
+
+ if (!mVibration.callerInfo.attrs.isFlagSet(
+ VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_SCALE)) {
+ if (Flags.adaptiveHapticsEnabled()) {
+ waitForVibrationParamsIfRequired();
+ }
+ mVibration.scaleEffects(mVibrationScaler::scale);
+ }
+
mVibration.adaptToDevice(mDeviceAdapter);
CombinedVibration.Sequential sequentialEffect = toSequential(mVibration.getEffectToPlay());
mPendingVibrateSteps++;
@@ -361,6 +380,9 @@
+ mSignalCancelImmediate);
}
}
+ if (mRequestVibrationParamsFuture != null) {
+ mRequestVibrationParamsFuture.cancel(/* mayInterruptIfRunning= */true);
+ }
mLock.notify();
}
}
@@ -420,6 +442,30 @@
}
}
+ /**
+ * Blocks until the vibration params future is complete.
+ *
+ * This should be called by the VibrationThread and may be interrupted by calling
+ * `notifyCancelled` from outside it.
+ */
+ private void waitForVibrationParamsIfRequired() {
+ if (Build.IS_DEBUGGABLE) {
+ expectIsVibrationThread(true);
+ }
+
+ if (mRequestVibrationParamsFuture == null) {
+ return;
+ }
+
+ try {
+ mRequestVibrationParamsFuture.orTimeout(
+ vibrationSettings.getRequestVibrationParamsTimeoutMs(),
+ TimeUnit.MILLISECONDS).get();
+ } catch (Throwable e) {
+ Slog.w(TAG, "Failed to retrieve vibration params.", e);
+ }
+ }
+
@GuardedBy("mLock")
private boolean hasPendingNotifySignalLocked() {
if (Build.IS_DEBUGGABLE) {
diff --git a/services/core/java/com/android/server/vibrator/VibratorControlService.java b/services/core/java/com/android/server/vibrator/VibratorControlService.java
index 9d75249..8f8fe3c 100644
--- a/services/core/java/com/android/server/vibrator/VibratorControlService.java
+++ b/services/core/java/com/android/server/vibrator/VibratorControlService.java
@@ -16,11 +16,13 @@
package com.android.server.vibrator;
+import static android.os.VibrationAttributes.USAGE_ACCESSIBILITY;
import static android.os.VibrationAttributes.USAGE_ALARM;
import static android.os.VibrationAttributes.USAGE_COMMUNICATION_REQUEST;
import static android.os.VibrationAttributes.USAGE_HARDWARE_FEEDBACK;
import static android.os.VibrationAttributes.USAGE_MEDIA;
import static android.os.VibrationAttributes.USAGE_NOTIFICATION;
+import static android.os.VibrationAttributes.USAGE_PHYSICAL_EMULATION;
import static android.os.VibrationAttributes.USAGE_RINGTONE;
import static android.os.VibrationAttributes.USAGE_TOUCH;
import static android.os.VibrationAttributes.USAGE_UNKNOWN;
@@ -32,12 +34,18 @@
import android.frameworks.vibrator.IVibratorController;
import android.frameworks.vibrator.ScaleParam;
import android.frameworks.vibrator.VibrationParam;
+import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
+import android.os.VibrationAttributes;
import android.util.Slog;
-import android.util.SparseArray;
+
+import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
/**
* Implementation of {@link IVibratorControlService} which allows the registration of
@@ -47,16 +55,25 @@
*/
public final class VibratorControlService extends IVibratorControlService.Stub {
private static final String TAG = "VibratorControlService";
+ private static final int UNRECOGNIZED_VIBRATION_TYPE = -1;
+ private static final int NO_SCALE = -1;
private final VibratorControllerHolder mVibratorControllerHolder;
private final VibrationScaler mVibrationScaler;
private final Object mLock;
+ private final int[] mRequestVibrationParamsForUsages;
+
+ @GuardedBy("mLock")
+ private CompletableFuture<Void> mRequestVibrationParamsFuture = null;
+ @GuardedBy("mLock")
+ private IBinder mRequestVibrationParamsToken;
public VibratorControlService(VibratorControllerHolder vibratorControllerHolder,
- VibrationScaler vibrationScaler, Object lock) {
+ VibrationScaler vibrationScaler, VibrationSettings vibrationSettings, Object lock) {
mVibratorControllerHolder = vibratorControllerHolder;
mVibrationScaler = vibrationScaler;
mLock = lock;
+ mRequestVibrationParamsForUsages = vibrationSettings.getRequestVibrationParamsForUsages();
}
@Override
@@ -85,8 +102,9 @@
+ "controller doesn't match the registered one. " + this);
return;
}
- updateAdaptiveHapticsScales(/* params= */ null);
+ mVibrationScaler.clearAdaptiveHapticsScales();
mVibratorControllerHolder.setVibratorController(null);
+ endOngoingRequestVibrationParamsLocked(/* wasCancelled= */ true);
}
}
@@ -131,10 +149,8 @@
+ "controller doesn't match the registered one. " + this);
return;
}
- //TODO(305942827): Update this method to only clear the specified vibration types.
- // Perhaps look into whether it makes more sense to have this clear all scales and
- // rely on setVibrationParams for clearing the scales for specific vibrations.
- updateAdaptiveHapticsScales(/* params= */ null);
+
+ updateAdaptiveHapticsScales(types, NO_SCALE);
}
}
@@ -142,7 +158,26 @@
public void onRequestVibrationParamsComplete(
@NonNull IBinder requestToken, @SuppressLint("ArrayReturn") VibrationParam[] result)
throws RemoteException {
- // TODO(305942827): Cache the vibration params in VibrationScaler
+ Objects.requireNonNull(requestToken);
+
+ synchronized (mLock) {
+ if (mRequestVibrationParamsToken == null) {
+ Slog.wtf(TAG,
+ "New vibration params received but no token was cached in the service. "
+ + "New vibration params ignored.");
+ return;
+ }
+
+ if (!Objects.equals(requestToken, mRequestVibrationParamsToken)) {
+ Slog.w(TAG,
+ "New vibration params received but the provided token does not match the "
+ + "cached one. New vibration params ignored.");
+ return;
+ }
+
+ updateAdaptiveHapticsScales(result);
+ endOngoingRequestVibrationParamsLocked(/* wasCancelled= */ false);
+ }
}
@Override
@@ -156,50 +191,190 @@
}
/**
- * Extracts the vibration scales and caches them in {@link VibrationScaler}.
+ * If an {@link IVibratorController} is registered to the service, it will request the latest
+ * vibration params and return a {@link CompletableFuture} that completes when the request is
+ * fulfilled. Otherwise, ignores the call and returns null.
*
- * @param params the new vibration params to cache.
+ * @param usage a {@link android.os.VibrationAttributes} usage.
+ * @param timeoutInMillis the request's timeout in millis.
+ * @return a {@link CompletableFuture} to track the completion of the vibration param
+ * request, or null if no {@link IVibratorController} is registered.
*/
- private void updateAdaptiveHapticsScales(@Nullable VibrationParam[] params) {
- if (params == null || params.length == 0) {
- mVibrationScaler.updateAdaptiveHapticsScales(null);
- return;
- }
+ @Nullable
+ public CompletableFuture<Void> triggerVibrationParamsRequest(
+ @VibrationAttributes.Usage int usage, int timeoutInMillis) {
+ synchronized (mLock) {
+ IVibratorController vibratorController =
+ mVibratorControllerHolder.getVibratorController();
+ if (vibratorController == null) {
+ Slog.d(TAG, "Unable to request vibration params. There is no registered "
+ + "IVibrationController.");
+ return null;
+ }
- SparseArray<Float> vibrationScales = new SparseArray<>();
- for (int i = 0; i < params.length; i++) {
- ScaleParam scaleParam = params[i].getScale();
- extractVibrationScales(scaleParam, vibrationScales);
+ int vibrationType = mapToAdaptiveVibrationType(usage);
+ if (vibrationType == UNRECOGNIZED_VIBRATION_TYPE) {
+ Slog.d(TAG, "Unable to request vibration params. The provided usage " + usage
+ + " is unrecognized.");
+ return null;
+ }
+
+ try {
+ endOngoingRequestVibrationParamsLocked(/* wasCancelled= */ true);
+ mRequestVibrationParamsFuture = new CompletableFuture<>();
+ mRequestVibrationParamsToken = new Binder();
+ vibratorController.requestVibrationParams(vibrationType, timeoutInMillis,
+ mRequestVibrationParamsToken);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Failed to request vibration params.", e);
+ endOngoingRequestVibrationParamsLocked(/* wasCancelled= */ true);
+ }
+
+ return mRequestVibrationParamsFuture;
}
- mVibrationScaler.updateAdaptiveHapticsScales(vibrationScales);
}
/**
- * Extracts the vibration scales and map them to their corresponding
- * {@link android.os.VibrationAttributes} usages.
+ * If an {@link IVibratorController} is registered to the service, then it checks whether to
+ * request new vibration params before playing the vibration. Returns true if the
+ * usage is for high latency vibrations, e.g. ringtone and notification, and can be delayed
+ * slightly. Otherwise, returns false.
+ *
+ * @param usage a {@link android.os.VibrationAttributes} usage.
+ * @return true if usage is for high latency vibrations, false otherwise.
*/
- private void extractVibrationScales(ScaleParam scaleParam, SparseArray<Float> vibrationScales) {
- if ((ScaleParam.TYPE_ALARM & scaleParam.typesMask) != 0) {
- vibrationScales.put(USAGE_ALARM, scaleParam.scale);
+ public boolean shouldRequestVibrationParams(@VibrationAttributes.Usage int usage) {
+ synchronized (mLock) {
+ IVibratorController vibratorController =
+ mVibratorControllerHolder.getVibratorController();
+ if (vibratorController == null) {
+ Slog.d(TAG, "Unable to check if should request vibration params. "
+ + "There is no registered IVibrationController.");
+ return false;
+ }
+
+ return ArrayUtils.contains(mRequestVibrationParamsForUsages, usage);
+ }
+ }
+
+ /**
+ * Returns the {@link #mRequestVibrationParamsToken} which is used to validate
+ * {@link #onRequestVibrationParamsComplete(IBinder, VibrationParam[])} calls.
+ */
+ @VisibleForTesting
+ public IBinder getRequestVibrationParamsToken() {
+ synchronized (mLock) {
+ return mRequestVibrationParamsToken;
+ }
+ }
+
+ /**
+ * Completes or cancels the vibration params request future and resets the future and token
+ * to null.
+ * @param wasCancelled specifies whether the future should be ended by being cancelled or not.
+ */
+ @GuardedBy("mLock")
+ private void endOngoingRequestVibrationParamsLocked(boolean wasCancelled) {
+ mRequestVibrationParamsToken = null;
+ if (mRequestVibrationParamsFuture == null) {
+ return;
}
- if ((ScaleParam.TYPE_NOTIFICATION & scaleParam.typesMask) != 0) {
- vibrationScales.put(USAGE_NOTIFICATION, scaleParam.scale);
- vibrationScales.put(USAGE_COMMUNICATION_REQUEST, scaleParam.scale);
+ if (wasCancelled) {
+ mRequestVibrationParamsFuture.cancel(/* mayInterruptIfRunning= */ true);
+ } else {
+ mRequestVibrationParamsFuture.complete(null);
}
- if ((ScaleParam.TYPE_RINGTONE & scaleParam.typesMask) != 0) {
- vibrationScales.put(USAGE_RINGTONE, scaleParam.scale);
+ mRequestVibrationParamsFuture = null;
+ }
+
+ private static int mapToAdaptiveVibrationType(@VibrationAttributes.Usage int usage) {
+ switch (usage) {
+ case USAGE_ALARM -> {
+ return ScaleParam.TYPE_ALARM;
+ }
+ case USAGE_NOTIFICATION, USAGE_COMMUNICATION_REQUEST -> {
+ return ScaleParam.TYPE_NOTIFICATION;
+ }
+ case USAGE_RINGTONE -> {
+ return ScaleParam.TYPE_RINGTONE;
+ }
+ case USAGE_MEDIA, USAGE_UNKNOWN -> {
+ return ScaleParam.TYPE_MEDIA;
+ }
+ case USAGE_TOUCH, USAGE_HARDWARE_FEEDBACK, USAGE_ACCESSIBILITY,
+ USAGE_PHYSICAL_EMULATION -> {
+ return ScaleParam.TYPE_INTERACTIVE;
+ }
+ default -> {
+ Slog.w(TAG, "Unrecognized vibration usage " + usage);
+ return UNRECOGNIZED_VIBRATION_TYPE;
+ }
+ }
+ }
+
+ /**
+ * Updates the adaptive haptics scales cached in {@link VibrationScaler} with the
+ * provided params.
+ *
+ * @param params the new vibration params.
+ */
+ private void updateAdaptiveHapticsScales(@Nullable VibrationParam[] params) {
+ for (VibrationParam param : params) {
+ ScaleParam scaleParam = param.getScale();
+ updateAdaptiveHapticsScales(scaleParam.typesMask, scaleParam.scale);
+ }
+ }
+
+ /**
+ * Updates the adaptive haptics scales, cached in {@link VibrationScaler}, for the provided
+ * vibration types.
+ *
+ * @param types The type of vibrations.
+ * @param scale The scaling factor that should be applied to the vibrations.
+ */
+ private void updateAdaptiveHapticsScales(int types, float scale) {
+ if ((ScaleParam.TYPE_ALARM & types) != 0) {
+ updateOrRemoveAdaptiveHapticsScale(USAGE_ALARM, scale);
}
- if ((ScaleParam.TYPE_MEDIA & scaleParam.typesMask) != 0) {
- vibrationScales.put(USAGE_MEDIA, scaleParam.scale);
- vibrationScales.put(USAGE_UNKNOWN, scaleParam.scale);
+ if ((ScaleParam.TYPE_NOTIFICATION & types) != 0) {
+ updateOrRemoveAdaptiveHapticsScale(USAGE_NOTIFICATION, scale);
+ updateOrRemoveAdaptiveHapticsScale(USAGE_COMMUNICATION_REQUEST, scale);
}
- if ((ScaleParam.TYPE_INTERACTIVE & scaleParam.typesMask) != 0) {
- vibrationScales.put(USAGE_TOUCH, scaleParam.scale);
- vibrationScales.put(USAGE_HARDWARE_FEEDBACK, scaleParam.scale);
+ if ((ScaleParam.TYPE_RINGTONE & types) != 0) {
+ updateOrRemoveAdaptiveHapticsScale(USAGE_RINGTONE, scale);
}
+
+ if ((ScaleParam.TYPE_MEDIA & types) != 0) {
+ updateOrRemoveAdaptiveHapticsScale(USAGE_MEDIA, scale);
+ updateOrRemoveAdaptiveHapticsScale(USAGE_UNKNOWN, scale);
+ }
+
+ if ((ScaleParam.TYPE_INTERACTIVE & types) != 0) {
+ updateOrRemoveAdaptiveHapticsScale(USAGE_TOUCH, scale);
+ updateOrRemoveAdaptiveHapticsScale(USAGE_HARDWARE_FEEDBACK, scale);
+ }
+ }
+
+ /**
+ * Updates or removes the adaptive haptics scale for the specified usage. If the scale is set
+ * to {@link #NO_SCALE} then it will be removed from the cached usage scales in
+ * {@link VibrationScaler}. Otherwise, the cached usage scale will be updated by the new value.
+ *
+ * @param usageHint one of VibrationAttributes.USAGE_*.
+ * @param scale The scaling factor that should be applied to the vibrations. If set to
+ * {@link #NO_SCALE} then the scale will be removed.
+ */
+ private void updateOrRemoveAdaptiveHapticsScale(@VibrationAttributes.Usage int usageHint,
+ float scale) {
+ if (scale == NO_SCALE) {
+ mVibrationScaler.removeAdaptiveHapticsScale(usageHint);
+ return;
+ }
+
+ mVibrationScaler.updateAdaptiveHapticsScale(usageHint, scale);
}
}
diff --git a/services/core/java/com/android/server/vibrator/VibratorControllerHolder.java b/services/core/java/com/android/server/vibrator/VibratorControllerHolder.java
index 63e69db..79a99b3 100644
--- a/services/core/java/com/android/server/vibrator/VibratorControllerHolder.java
+++ b/services/core/java/com/android/server/vibrator/VibratorControllerHolder.java
@@ -57,7 +57,7 @@
@Override
public void binderDied(@NonNull IBinder deadBinder) {
- if (deadBinder == mVibratorController.asBinder()) {
+ if (mVibratorController != null && deadBinder == mVibratorController.asBinder()) {
setVibratorController(null);
}
}
diff --git a/services/core/java/com/android/server/vibrator/VibratorManagerService.java b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
index 2c1ab95..759450b 100644
--- a/services/core/java/com/android/server/vibrator/VibratorManagerService.java
+++ b/services/core/java/com/android/server/vibrator/VibratorManagerService.java
@@ -53,6 +53,7 @@
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
import android.os.VibratorInfo;
+import android.os.vibrator.Flags;
import android.os.vibrator.PrebakedSegment;
import android.os.vibrator.VibrationEffectSegment;
import android.os.vibrator.VibratorInfoFactory;
@@ -84,6 +85,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -161,6 +163,7 @@
private final VibrationSettings mVibrationSettings;
private final VibrationScaler mVibrationScaler;
+ private final VibratorControlService mVibratorControlService;
private final InputDeviceDelegate mInputDeviceDelegate;
private final DeviceAdapter mDeviceAdapter;
@@ -212,6 +215,9 @@
mVibrationSettings = new VibrationSettings(mContext, mHandler);
mVibrationScaler = new VibrationScaler(mContext, mVibrationSettings);
+ mVibratorControlService = new VibratorControlService(
+ injector.createVibratorControllerHolder(), mVibrationScaler, mVibrationSettings,
+ mLock);
mInputDeviceDelegate = new InputDeviceDelegate(mContext, mHandler);
VibrationCompleteListener listener = new VibrationCompleteListener(this);
@@ -272,9 +278,7 @@
injector.addService(EXTERNAL_VIBRATOR_SERVICE, new ExternalVibratorService());
if (ServiceManager.isDeclared(VIBRATOR_CONTROL_SERVICE)) {
- injector.addService(VIBRATOR_CONTROL_SERVICE,
- new VibratorControlService(new VibratorControllerHolder(), mVibrationScaler,
- mLock));
+ injector.addService(VIBRATOR_CONTROL_SERVICE, mVibratorControlService);
}
}
@@ -783,19 +787,12 @@
private Vibration.EndInfo startVibrationLocked(HalVibration vib) {
Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "startVibrationLocked");
try {
- if (!vib.callerInfo.attrs.isFlagSet(
- VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_SCALE)) {
- // Scale effect before dispatching it to the input devices or the vibration thread.
- vib.scaleEffects(mVibrationScaler::scale);
- }
- boolean inputDevicesAvailable = mInputDeviceDelegate.vibrateIfAvailable(
- vib.callerInfo, vib.getEffectToPlay());
- if (inputDevicesAvailable) {
- return new Vibration.EndInfo(Vibration.Status.FORWARDED_TO_INPUT_DEVICES);
+ if (mInputDeviceDelegate.isAvailable()) {
+ return startVibrationOnInputDevicesLocked(vib);
}
- VibrationStepConductor conductor = new VibrationStepConductor(vib, mVibrationSettings,
- mDeviceAdapter, mVibrationThreadCallbacks);
+ VibrationStepConductor conductor = createVibrationStepConductor(vib);
+
if (mCurrentVibration == null) {
return startVibrationOnThreadLocked(conductor);
}
@@ -866,6 +863,34 @@
vib.getStatsInfo(/* completionUptimeMillis= */ SystemClock.uptimeMillis()));
}
+ private VibrationStepConductor createVibrationStepConductor(HalVibration vib) {
+ CompletableFuture<Void> requestVibrationParamsFuture = null;
+
+ if (Flags.adaptiveHapticsEnabled() && !vib.callerInfo.attrs.isFlagSet(
+ VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_SCALE)
+ && mVibratorControlService.shouldRequestVibrationParams(
+ vib.callerInfo.attrs.getUsage())) {
+ requestVibrationParamsFuture =
+ mVibratorControlService.triggerVibrationParamsRequest(
+ vib.callerInfo.attrs.getUsage(),
+ mVibrationSettings.getRequestVibrationParamsTimeoutMs());
+ }
+
+ return new VibrationStepConductor(vib, mVibrationSettings, mDeviceAdapter, mVibrationScaler,
+ requestVibrationParamsFuture, mVibrationThreadCallbacks);
+ }
+
+ private Vibration.EndInfo startVibrationOnInputDevicesLocked(HalVibration vib) {
+ if (!vib.callerInfo.attrs.isFlagSet(
+ VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_SCALE)) {
+ // Scale effect before dispatching it to the input devices.
+ vib.scaleEffects(mVibrationScaler::scale);
+ }
+ mInputDeviceDelegate.vibrateIfAvailable(vib.callerInfo, vib.getEffectToPlay());
+
+ return new Vibration.EndInfo(Vibration.Status.FORWARDED_TO_INPUT_DEVICES);
+ }
+
private void logVibrationStatus(int uid, VibrationAttributes attrs,
Vibration.Status status) {
switch (status) {
@@ -1395,6 +1420,10 @@
void addService(String name, IBinder service) {
ServiceManager.addService(name, service);
}
+
+ VibratorControllerHolder createVibratorControllerHolder() {
+ return new VibratorControllerHolder();
+ }
}
/**
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index fa8c35a..19ea9f9 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -626,6 +626,8 @@
private boolean mForceShowMagnifiableBounds = false;
+ private final MagnificationSpec mMagnificationSpec = new MagnificationSpec();
+
DisplayMagnifier(WindowManagerService windowManagerService,
DisplayContent displayContent,
Display display,
@@ -655,13 +657,28 @@
mAccessibilityTracing.logTrace(LOG_TAG + ".setMagnificationSpec",
FLAGS_MAGNIFICATION_CALLBACK, "spec={" + spec + "}");
}
- mMagnifedViewport.updateMagnificationSpec(spec);
+ updateMagnificationSpec(spec);
mMagnifedViewport.recomputeBounds();
mService.applyMagnificationSpecLocked(mDisplay.getDisplayId(), spec);
mService.scheduleAnimationLocked();
}
+ void updateMagnificationSpec(MagnificationSpec spec) {
+ if (spec != null) {
+ mMagnificationSpec.initialize(spec.scale, spec.offsetX, spec.offsetY);
+ } else {
+ mMagnificationSpec.clear();
+ }
+ // If this message is pending we are in a rotation animation and do not want
+ // to show the border. We will do so when the pending message is handled.
+ if (!mHandler.hasMessages(
+ MyHandler.MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED)) {
+ mMagnifedViewport.setMagnifiedRegionBorderShown(
+ isForceShowingMagnifiableBounds(), true);
+ }
+ }
+
void setForceShowMagnifiableBounds(boolean show) {
if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) {
mAccessibilityTracing.logTrace(LOG_TAG + ".setForceShowMagnifiableBounds",
@@ -800,8 +817,7 @@
case WindowManager.LayoutParams.TYPE_QS_DIALOG:
case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL: {
Rect magnifiedRegionBounds = mTempRect2;
- mMagnifedViewport.getMagnifiedFrameInContentCoords(
- magnifiedRegionBounds);
+ getMagnifiedFrameInContentCoords(magnifiedRegionBounds);
Rect touchableRegionBounds = mTempRect1;
windowState.getTouchableRegion(mTempRegion1);
mTempRegion1.getBounds(touchableRegionBounds);
@@ -818,6 +834,14 @@
}
}
+ void getMagnifiedFrameInContentCoords(Rect rect) {
+ Region magnificationRegion = new Region();
+ mMagnifedViewport.getMagnificationRegion(magnificationRegion);
+ magnificationRegion.getBounds(rect);
+ rect.offset((int) -mMagnificationSpec.offsetX, (int) -mMagnificationSpec.offsetY);
+ rect.scale(1.0f / mMagnificationSpec.scale);
+ }
+
void notifyImeWindowVisibilityChanged(boolean shown) {
if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) {
mAccessibilityTracing.logTrace(LOG_TAG + ".notifyImeWindowVisibilityChanged",
@@ -832,13 +856,13 @@
mAccessibilityTracing.logTrace(LOG_TAG + ".getMagnificationSpecForWindow",
FLAGS_MAGNIFICATION_CALLBACK, "windowState={" + windowState + "}");
}
- MagnificationSpec spec = mMagnifedViewport.getMagnificationSpec();
- if (spec != null && !spec.isNop()) {
+
+ if (mMagnificationSpec != null && !mMagnificationSpec.isNop()) {
if (!windowState.shouldMagnify()) {
return null;
}
}
- return spec;
+ return mMagnificationSpec;
}
void getMagnificationRegion(Region outMagnificationRegion) {
@@ -852,6 +876,10 @@
mMagnifedViewport.getMagnificationRegion(outMagnificationRegion);
}
+ boolean isMagnifying() {
+ return mMagnificationSpec.scale > 1.0f;
+ }
+
void destroy() {
if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) {
mAccessibilityTracing.logTrace(LOG_TAG + ".destroy", FLAGS_MAGNIFICATION_CALLBACK);
@@ -897,8 +925,6 @@
private final Path mCircularPath;
- private final MagnificationSpec mMagnificationSpec = new MagnificationSpec();
-
private final float mBorderWidth;
private final int mHalfBorderWidth;
private final int mDrawBorderInset;
@@ -932,20 +958,6 @@
outMagnificationRegion.set(mMagnificationRegion);
}
- void updateMagnificationSpec(MagnificationSpec spec) {
- if (spec != null) {
- mMagnificationSpec.initialize(spec.scale, spec.offsetX, spec.offsetY);
- } else {
- mMagnificationSpec.clear();
- }
- // If this message is pending we are in a rotation animation and do not want
- // to show the border. We will do so when the pending message is handled.
- if (!mHandler.hasMessages(
- MyHandler.MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED)) {
- setMagnifiedRegionBorderShown(isForceShowingMagnifiableBounds(), true);
- }
- }
-
void recomputeBounds() {
getDisplaySizeLocked(mScreenSize);
final int screenWidth = mScreenSize.x;
@@ -1127,21 +1139,6 @@
}
}
- void getMagnifiedFrameInContentCoords(Rect rect) {
- MagnificationSpec spec = mMagnificationSpec;
- mMagnificationRegion.getBounds(rect);
- rect.offset((int) -spec.offsetX, (int) -spec.offsetY);
- rect.scale(1.0f / spec.scale);
- }
-
- boolean isMagnifying() {
- return mMagnificationSpec.scale > 1.0f;
- }
-
- MagnificationSpec getMagnificationSpec() {
- return mMagnificationSpec;
- }
-
void drawWindowIfNeeded() {
recomputeBounds();
mWindow.postDrawIfNeeded();
diff --git a/services/core/java/com/android/server/wm/ActivityClientController.java b/services/core/java/com/android/server/wm/ActivityClientController.java
index 2e0546e..1128d0c 100644
--- a/services/core/java/com/android/server/wm/ActivityClientController.java
+++ b/services/core/java/com/android/server/wm/ActivityClientController.java
@@ -1319,9 +1319,33 @@
try {
synchronized (mGlobalLock) {
final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
- if (r != null) {
+ if (r == null) return;
+ final TransitionController controller = r.mTransitionController;
+ if (!controller.isShellTransitionsEnabled()) {
r.setShowWhenLocked(showWhenLocked);
+ return;
}
+ if (controller.isCollecting()
+ && !mService.mKeyguardController.isKeyguardLocked(r.getDisplayId())) {
+ // Keyguard isn't locked, so this can be done as part of the collecting
+ // transition.
+ r.setShowWhenLocked(showWhenLocked);
+ return;
+ }
+ final Transition transition = new Transition(
+ showWhenLocked ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK,
+ 0 /* flags */, controller, mService.mWindowManager.mSyncEngine);
+ r.mTransitionController.startCollectOrQueue(transition, (deferred) -> {
+ transition.collect(r);
+ r.setShowWhenLocked(showWhenLocked);
+ if (transition.isNoOp()) {
+ transition.abort();
+ return;
+ }
+ controller.requestStartTransition(transition, null /* trigger */,
+ null /* remoteTransition */, null /* displayChange */);
+ transition.setReady(r, true);
+ });
}
} finally {
Binder.restoreCallingIdentity(origId);
@@ -1334,9 +1358,34 @@
try {
synchronized (mGlobalLock) {
final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
- if (r != null) {
+ if (r == null) return;
+ final TransitionController controller = r.mTransitionController;
+ // If shell transitions is not enabled just set it directly.
+ if (!controller.isShellTransitionsEnabled()) {
r.setInheritShowWhenLocked(inheritShowWhenLocked);
+ return;
}
+ if (controller.isCollecting()
+ && !mService.mKeyguardController.isKeyguardLocked(r.getDisplayId())) {
+ // Keyguard isn't locked, so this can be done as part of the collecting
+ // transition.
+ r.setInheritShowWhenLocked(inheritShowWhenLocked);
+ return;
+ }
+ final Transition transition = new Transition(
+ inheritShowWhenLocked ? TRANSIT_TO_FRONT : TRANSIT_TO_BACK,
+ 0 /* flags */, controller, mService.mWindowManager.mSyncEngine);
+ r.mTransitionController.startCollectOrQueue(transition, (deferred) -> {
+ transition.collect(r);
+ r.setInheritShowWhenLocked(inheritShowWhenLocked);
+ if (transition.isNoOp()) {
+ transition.abort();
+ return;
+ }
+ controller.requestStartTransition(transition, null /* trigger */,
+ null /* remoteTransition */, null /* displayChange */);
+ transition.setReady(r, true);
+ });
}
} finally {
Binder.restoreCallingIdentity(origId);
diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java
index 7b23004..7a3124d 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimation.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimation.java
@@ -160,7 +160,8 @@
// Invisible activity should be stopped. If the recents activity is alive and its doesn't
// need to relaunch by current configuration, then it may be already in stopped state.
- if (!targetActivity.isState(STOPPING, STOPPED)) {
+ if (!targetActivity.finishing && targetActivity.isAttached()
+ && !targetActivity.isState(STOPPING, STOPPED)) {
// Add to stopping instead of stop immediately. So the client has the chance to perform
// traversal in non-stopped state (ViewRootImpl.mStopped) that would initialize more
// things (e.g. the measure can be done earlier). The actual stop will be performed when
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index 2accf9a..1e58306 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -2917,6 +2917,26 @@
Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_WINDOW_MANAGER, TAG, cookie);
}
+ /**
+ * Get whether the transition, in its current state, is a no-op. This should be avoided. It is
+ * only here for legacy usages where we can't tell ahead-of-time whether something will
+ * generate a change.
+ */
+ boolean isNoOp() {
+ for (int i = mParticipants.size() - 1; i >= 0; --i) {
+ // This is the same criteria as the rejection logic in calculateTargets
+ final WindowContainer<?> wc = mParticipants.valueAt(i);
+ if (!wc.isAttached()) continue;
+ // The level of transition target should be at least window token.
+ if (wc.asWindowState() != null) continue;
+ final ChangeInfo changeInfo = mChanges.get(wc);
+ // Reject no-ops
+ if (!changeInfo.hasChanged()) continue;
+ return false;
+ }
+ return true;
+ }
+
@VisibleForTesting
static class ChangeInfo {
private static final int FLAG_NONE = 0;
diff --git a/services/incremental/OWNERS b/services/incremental/OWNERS
index 7ebb962..c18a9e5 100644
--- a/services/incremental/OWNERS
+++ b/services/incremental/OWNERS
@@ -1,8 +1,4 @@
# Bug component: 554432
-include /services/core/java/com/android/server/pm/OWNERS
+include /PACKAGE_MANAGER_OWNERS
-alexbuy@google.com
-schfan@google.com
-toddke@google.com
-zyy@google.com
-patb@google.com
+zyy@google.com
\ No newline at end of file
diff --git a/services/permission/java/com/android/server/permission/access/appop/AppOpService.kt b/services/permission/java/com/android/server/permission/access/appop/AppOpService.kt
index 8f464d4..fc2eb26 100644
--- a/services/permission/java/com/android/server/permission/access/appop/AppOpService.kt
+++ b/services/permission/java/com/android/server/permission/access/appop/AppOpService.kt
@@ -17,6 +17,7 @@
package com.android.server.permission.access.appop
import android.app.AppOpsManager
+import android.companion.virtual.VirtualDeviceManager
import android.os.Handler
import android.os.UserHandle
import android.util.ArrayMap
@@ -213,7 +214,10 @@
val uid = key.first
val appOpCode = key.second
- listener.onUidModeChanged(uid, appOpCode, mode)
+ listener.onUidModeChanged(uid,
+ appOpCode,
+ mode,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)
}
}
diff --git a/services/profcollect/OWNERS b/services/profcollect/OWNERS
index b380e39..be9e61f 100644
--- a/services/profcollect/OWNERS
+++ b/services/profcollect/OWNERS
@@ -1,3 +1 @@
-srhines@google.com
-yabinc@google.com
-yikong@google.com
+include platform/prebuilts/clang/host/linux-x86:/OWNERS
diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
index 582b712..fb0fbe8 100644
--- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
+++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
@@ -62,7 +62,7 @@
private static final boolean DEBUG = Log.isLoggable(LOG_TAG, Log.DEBUG);
private static final String INTENT_UPLOAD_PROFILES =
"com.android.server.profcollect.UPLOAD_PROFILES";
- private static final long BG_PROCESS_PERIOD = TimeUnit.HOURS.toMillis(4); // every 4 hours.
+ private static final long BG_PROCESS_INTERVAL = TimeUnit.HOURS.toMillis(4); // every 4 hours.
private IProfCollectd mIProfcollect;
private static ProfcollectForwardingService sSelfService;
@@ -226,7 +226,7 @@
js.schedule(new JobInfo.Builder(JOB_IDLE_PROCESS, JOB_SERVICE_NAME)
.setRequiresDeviceIdle(true)
.setRequiresCharging(true)
- .setPeriodic(BG_PROCESS_PERIOD)
+ .setPeriodic(BG_PROCESS_INTERVAL)
.setPriority(JobInfo.PRIORITY_MIN)
.build());
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java b/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java
index 47ae97f..0e85626 100644
--- a/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java
@@ -44,6 +44,7 @@
import android.app.IActivityManager;
import android.app.IUidObserver;
import android.app.usage.UsageStatsManager;
+import android.companion.virtual.VirtualDeviceManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -309,7 +310,8 @@
mRestrictedPackages.remove(p);
}
if (mAppOpsCallback != null) {
- mAppOpsCallback.opChanged(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName);
+ mAppOpsCallback.opChanged(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT);
}
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
index b39cd04..a476155 100644
--- a/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
@@ -125,6 +125,7 @@
import android.app.compat.CompatChanges;
import android.app.tare.EconomyManager;
import android.app.usage.UsageStatsManagerInternal;
+import android.companion.virtual.VirtualDeviceManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -2980,7 +2981,8 @@
mService.mLastOpScheduleExactAlarm.put(TEST_CALLING_UID, MODE_ALLOWED);
mockScheduleExactAlarmStatePreT(true, MODE_ERRORED);
- mIAppOpsCallback.opChanged(OP_SCHEDULE_EXACT_ALARM, TEST_CALLING_UID, TEST_CALLING_PACKAGE);
+ mIAppOpsCallback.opChanged(OP_SCHEDULE_EXACT_ALARM, TEST_CALLING_UID, TEST_CALLING_PACKAGE,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT);
assertAndHandleMessageSync(REMOVE_EXACT_ALARMS);
verify(mService).removeExactAlarmsOnPermissionRevoked(TEST_CALLING_UID,
TEST_CALLING_PACKAGE, true);
@@ -2993,7 +2995,8 @@
mService.mLastOpScheduleExactAlarm.put(TEST_CALLING_UID, MODE_ALLOWED);
mockScheduleExactAlarmStatePreT(true, MODE_ERRORED);
- mIAppOpsCallback.opChanged(OP_SCHEDULE_EXACT_ALARM, TEST_CALLING_UID, TEST_CALLING_PACKAGE);
+ mIAppOpsCallback.opChanged(OP_SCHEDULE_EXACT_ALARM, TEST_CALLING_UID, TEST_CALLING_PACKAGE,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT);
verify(mService.mHandler, never()).sendMessageAtTime(
argThat(m -> m.what == REMOVE_EXACT_ALARMS), anyLong());
@@ -3008,7 +3011,8 @@
mService.mLastOpScheduleExactAlarm.put(TEST_CALLING_UID, MODE_ERRORED);
mockScheduleExactAlarmStatePreT(true, MODE_ALLOWED);
- mIAppOpsCallback.opChanged(OP_SCHEDULE_EXACT_ALARM, TEST_CALLING_UID, TEST_CALLING_PACKAGE);
+ mIAppOpsCallback.opChanged(OP_SCHEDULE_EXACT_ALARM, TEST_CALLING_UID, TEST_CALLING_PACKAGE,
+ VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT);
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
final ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
diff --git a/services/tests/servicestests/Android.bp b/services/tests/servicestests/Android.bp
index e22d99d..5611415 100644
--- a/services/tests/servicestests/Android.bp
+++ b/services/tests/servicestests/Android.bp
@@ -84,6 +84,7 @@
"flag-junit",
"ravenwood-junit",
"net_flags_lib",
+ "CtsVirtualDeviceCommonLib",
],
libs: [
diff --git a/services/tests/servicestests/src/com/android/server/appop/AppOpsActiveWatcherTest.java b/services/tests/servicestests/src/com/android/server/appop/AppOpsActiveWatcherTest.java
index a2aaccc..b487dc6 100644
--- a/services/tests/servicestests/src/com/android/server/appop/AppOpsActiveWatcherTest.java
+++ b/services/tests/servicestests/src/com/android/server/appop/AppOpsActiveWatcherTest.java
@@ -16,6 +16,8 @@
package com.android.server.appop;
+import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
+
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertFalse;
@@ -31,17 +33,23 @@
import android.app.AppOpsManager;
import android.app.AppOpsManager.OnOpActiveChangedListener;
+import android.companion.virtual.VirtualDeviceManager;
+import android.companion.virtual.VirtualDeviceParams;
+import android.content.AttributionSource;
import android.content.Context;
import android.os.Process;
+import android.virtualdevice.cts.common.FakeAssociationRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests app ops version upgrades
@@ -50,6 +58,8 @@
@RunWith(AndroidJUnit4.class)
public class AppOpsActiveWatcherTest {
+ @Rule
+ public FakeAssociationRule mFakeAssociationRule = new FakeAssociationRule();
private static final long NOTIFICATION_TIMEOUT_MILLIS = 5000;
@Test
@@ -69,7 +79,7 @@
verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(1)).onOpActiveChanged(eq(AppOpsManager.OPSTR_CAMERA),
eq(Process.myUid()), eq(getContext().getPackageName()),
- isNull(), eq(true), anyInt(), anyInt());
+ isNull(), eq(Context.DEVICE_ID_DEFAULT), eq(true), anyInt(), anyInt());
// This should be the only callback we got
verifyNoMoreInteractions(listener);
@@ -88,7 +98,7 @@
verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(1)).onOpActiveChanged(eq(AppOpsManager.OPSTR_CAMERA),
eq(Process.myUid()), eq(getContext().getPackageName()), isNull(),
- eq(false), anyInt(), anyInt());
+ eq(Context.DEVICE_ID_DEFAULT), eq(false), anyInt(), anyInt());
// Verify that the op is not active
assertThat(appOpsManager.isOperationActive(AppOpsManager.OP_CAMERA,
@@ -126,7 +136,7 @@
verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(1)).onOpActiveChanged(eq(AppOpsManager.OPSTR_CAMERA),
eq(Process.myUid()), eq(getContext().getPackageName()), isNull(),
- eq(true), anyInt(), anyInt());
+ eq(Context.DEVICE_ID_DEFAULT), eq(true), anyInt(), anyInt());
// Finish up
appOpsManager.finishOp(AppOpsManager.OP_CAMERA);
@@ -134,6 +144,64 @@
}
@Test
+ public void testWatchActiveOpsForExternalDevice() {
+ final VirtualDeviceManager virtualDeviceManager = getContext().getSystemService(
+ VirtualDeviceManager.class);
+ AtomicInteger virtualDeviceId = new AtomicInteger();
+ runWithShellPermissionIdentity(() -> {
+ final VirtualDeviceManager.VirtualDevice virtualDevice =
+ virtualDeviceManager.createVirtualDevice(
+ mFakeAssociationRule.getAssociationInfo().getId(),
+ new VirtualDeviceParams.Builder().setName("virtual_device").build());
+ virtualDeviceId.set(virtualDevice.getDeviceId());
+ });
+ final OnOpActiveChangedListener listener = mock(OnOpActiveChangedListener.class);
+ AttributionSource attributionSource = new AttributionSource(Process.myUid(),
+ getContext().getOpPackageName(), getContext().getAttributionTag(),
+ virtualDeviceId.get());
+
+ final AppOpsManager appOpsManager = getContext().getSystemService(AppOpsManager.class);
+ appOpsManager.startWatchingActive(new String[]{AppOpsManager.OPSTR_CAMERA,
+ AppOpsManager.OPSTR_RECORD_AUDIO}, getContext().getMainExecutor(), listener);
+
+ appOpsManager.startOpNoThrow(getContext().getAttributionSource().getToken(),
+ AppOpsManager.OP_CAMERA, attributionSource, false, "",
+ AppOpsManager.ATTRIBUTION_FLAGS_NONE, AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE);
+
+ verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
+ .times(1)).onOpActiveChanged(eq(AppOpsManager.OPSTR_CAMERA),
+ eq(Process.myUid()), eq(getContext().getOpPackageName()),
+ eq(getContext().getAttributionTag()), eq(virtualDeviceId.get()), eq(true),
+ eq(AppOpsManager.ATTRIBUTION_FLAGS_NONE),
+ eq(AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE));
+ verifyNoMoreInteractions(listener);
+
+ appOpsManager.finishOp(getContext().getAttributionSource().getToken(),
+ AppOpsManager.OP_CAMERA, attributionSource);
+
+ verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
+ .times(1)).onOpActiveChanged(eq(AppOpsManager.OPSTR_CAMERA),
+ eq(Process.myUid()), eq(getContext().getOpPackageName()),
+ eq(getContext().getAttributionTag()), eq(virtualDeviceId.get()), eq(false),
+ eq(AppOpsManager.ATTRIBUTION_FLAGS_NONE),
+ eq(AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE));
+ verifyNoMoreInteractions(listener);
+
+ appOpsManager.stopWatchingActive(listener);
+
+ appOpsManager.startOpNoThrow(getContext().getAttributionSource().getToken(),
+ AppOpsManager.OP_CAMERA, attributionSource, false, "",
+ AppOpsManager.ATTRIBUTION_FLAGS_NONE, AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE);
+
+ verifyNoMoreInteractions(listener);
+
+ appOpsManager.finishOp(getContext().getAttributionSource().getToken(),
+ AppOpsManager.OP_CAMERA, attributionSource);
+
+ verifyNoMoreInteractions(listener);
+ }
+
+ @Test
public void testIsRunning() throws Exception {
final AppOpsManager appOpsManager = getContext().getSystemService(AppOpsManager.class);
// Start the op
diff --git a/services/tests/servicestests/src/com/android/server/appop/AppOpsNotedWatcherTest.java b/services/tests/servicestests/src/com/android/server/appop/AppOpsNotedWatcherTest.java
index b5229d8..1abd4eb 100644
--- a/services/tests/servicestests/src/com/android/server/appop/AppOpsNotedWatcherTest.java
+++ b/services/tests/servicestests/src/com/android/server/appop/AppOpsNotedWatcherTest.java
@@ -22,27 +22,36 @@
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
import android.app.AppOpsManager;
import android.app.AppOpsManager.OnOpNotedListener;
+import android.companion.virtual.VirtualDeviceManager;
+import android.companion.virtual.VirtualDeviceParams;
+import android.content.AttributionSource;
import android.content.Context;
import android.os.Process;
+import android.virtualdevice.cts.common.FakeAssociationRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* Tests watching noted ops.
*/
@SmallTest
@RunWith(AndroidJUnit4.class)
public class AppOpsNotedWatcherTest {
-
+ @Rule
+ public FakeAssociationRule mFakeAssociationRule = new FakeAssociationRule();
private static final long NOTIFICATION_TIMEOUT_MILLIS = 5000;
@Test
@@ -66,12 +75,14 @@
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(1)).onOpNoted(eq(AppOpsManager.OPSTR_FINE_LOCATION),
eq(Process.myUid()), eq(getContext().getPackageName()),
- eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
+ eq(getContext().getAttributionTag()), eq(Context.DEVICE_ID_DEFAULT),
+ eq(AppOpsManager.OP_FLAG_SELF),
eq(AppOpsManager.MODE_ALLOWED));
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(1)).onOpNoted(eq(AppOpsManager.OPSTR_CAMERA),
eq(Process.myUid()), eq(getContext().getPackageName()),
- eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
+ eq(getContext().getAttributionTag()), eq(Context.DEVICE_ID_DEFAULT),
+ eq(AppOpsManager.OP_FLAG_SELF),
eq(AppOpsManager.MODE_ALLOWED));
// Stop watching
@@ -96,13 +107,54 @@
verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(2)).onOpNoted(eq(AppOpsManager.OPSTR_FINE_LOCATION),
eq(Process.myUid()), eq(getContext().getPackageName()),
- eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
+ eq(getContext().getAttributionTag()), eq(Context.DEVICE_ID_DEFAULT),
+ eq(AppOpsManager.OP_FLAG_SELF),
eq(AppOpsManager.MODE_ALLOWED));
// Finish up
appOpsManager.stopWatchingNoted(listener);
}
+ @Test
+ public void testWatchNotedOpsForExternalDevice() {
+ final AppOpsManager.OnOpNotedListener listener = mock(
+ AppOpsManager.OnOpNotedListener.class);
+ final VirtualDeviceManager virtualDeviceManager = getContext().getSystemService(
+ VirtualDeviceManager.class);
+ AtomicInteger virtualDeviceId = new AtomicInteger();
+ runWithShellPermissionIdentity(() -> {
+ final VirtualDeviceManager.VirtualDevice virtualDevice =
+ virtualDeviceManager.createVirtualDevice(
+ mFakeAssociationRule.getAssociationInfo().getId(),
+ new VirtualDeviceParams.Builder().setName("virtual_device").build());
+ virtualDeviceId.set(virtualDevice.getDeviceId());
+ });
+ AttributionSource attributionSource = new AttributionSource(Process.myUid(),
+ getContext().getOpPackageName(), getContext().getAttributionTag(),
+ virtualDeviceId.get());
+
+ final AppOpsManager appOpsManager = getContext().getSystemService(AppOpsManager.class);
+ appOpsManager.startWatchingNoted(new int[]{AppOpsManager.OP_FINE_LOCATION,
+ AppOpsManager.OP_CAMERA}, listener);
+
+ appOpsManager.noteOpNoThrow(AppOpsManager.OP_FINE_LOCATION, attributionSource, "message");
+
+ verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
+ .times(1)).onOpNoted(eq(AppOpsManager.OPSTR_FINE_LOCATION),
+ eq(Process.myUid()), eq(getContext().getOpPackageName()),
+ eq(getContext().getAttributionTag()), eq(virtualDeviceId.get()),
+ eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED));
+
+ appOpsManager.finishOp(getContext().getAttributionSource().getToken(),
+ AppOpsManager.OP_FINE_LOCATION, attributionSource);
+
+ verifyNoMoreInteractions(listener);
+
+ appOpsManager.stopWatchingNoted(listener);
+
+ verifyNoMoreInteractions(listener);
+ }
+
private static Context getContext() {
return InstrumentationRegistry.getContext();
}
diff --git a/services/tests/servicestests/src/com/android/server/appop/AppOpsStartedWatcherTest.java b/services/tests/servicestests/src/com/android/server/appop/AppOpsStartedWatcherTest.java
index e98a4dd..2890078 100644
--- a/services/tests/servicestests/src/com/android/server/appop/AppOpsStartedWatcherTest.java
+++ b/services/tests/servicestests/src/com/android/server/appop/AppOpsStartedWatcherTest.java
@@ -16,6 +16,8 @@
package com.android.server.appop;
+import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
+
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
@@ -25,22 +27,31 @@
import android.app.AppOpsManager;
import android.app.AppOpsManager.OnOpStartedListener;
+import android.companion.virtual.VirtualDeviceManager;
+import android.companion.virtual.VirtualDeviceParams;
+import android.content.AttributionSource;
import android.content.Context;
import android.os.Process;
+import android.virtualdevice.cts.common.FakeAssociationRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
+import java.util.concurrent.atomic.AtomicInteger;
+
/** Tests watching started ops. */
@SmallTest
@RunWith(AndroidJUnit4.class)
public class AppOpsStartedWatcherTest {
+ @Rule
+ public FakeAssociationRule mFakeAssociationRule = new FakeAssociationRule();
private static final long NOTIFICATION_TIMEOUT_MILLIS = 5000;
@Test
@@ -63,15 +74,17 @@
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(1)).onOpStarted(eq(AppOpsManager.OP_FINE_LOCATION),
eq(Process.myUid()), eq(getContext().getPackageName()),
- eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
- eq(AppOpsManager.MODE_ALLOWED), eq(OnOpStartedListener.START_TYPE_STARTED),
+ eq(getContext().getAttributionTag()), eq(Context.DEVICE_ID_DEFAULT),
+ eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED),
+ eq(OnOpStartedListener.START_TYPE_STARTED),
eq(AppOpsManager.ATTRIBUTION_FLAGS_NONE),
eq(AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE));
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(1)).onOpStarted(eq(AppOpsManager.OP_CAMERA),
eq(Process.myUid()), eq(getContext().getPackageName()),
- eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
- eq(AppOpsManager.MODE_ALLOWED), eq(OnOpStartedListener.START_TYPE_STARTED),
+ eq(getContext().getAttributionTag()), eq(Context.DEVICE_ID_DEFAULT),
+ eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED),
+ eq(OnOpStartedListener.START_TYPE_STARTED),
eq(AppOpsManager.ATTRIBUTION_FLAGS_NONE),
eq(AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE));
@@ -97,8 +110,9 @@
verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
.times(2)).onOpStarted(eq(AppOpsManager.OP_CAMERA),
eq(Process.myUid()), eq(getContext().getPackageName()),
- eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
- eq(AppOpsManager.MODE_ALLOWED), eq(OnOpStartedListener.START_TYPE_STARTED),
+ eq(getContext().getAttributionTag()), eq(Context.DEVICE_ID_DEFAULT),
+ eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED),
+ eq(OnOpStartedListener.START_TYPE_STARTED),
eq(AppOpsManager.ATTRIBUTION_FLAGS_NONE),
eq(AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE));
verifyNoMoreInteractions(listener);
@@ -109,6 +123,50 @@
appOpsManager.stopWatchingStarted(listener);
}
+ @Test
+ public void testWatchStartedOpsForExternalDevice() {
+ final VirtualDeviceManager virtualDeviceManager = getContext().getSystemService(
+ VirtualDeviceManager.class);
+ AtomicInteger virtualDeviceId = new AtomicInteger();
+ runWithShellPermissionIdentity(() -> {
+ final VirtualDeviceManager.VirtualDevice virtualDevice =
+ virtualDeviceManager.createVirtualDevice(
+ mFakeAssociationRule.getAssociationInfo().getId(),
+ new VirtualDeviceParams.Builder().setName("virtual_device").build());
+ virtualDeviceId.set(virtualDevice.getDeviceId());
+ });
+ final OnOpStartedListener listener = mock(OnOpStartedListener.class);
+ AttributionSource attributionSource = new AttributionSource(Process.myUid(),
+ getContext().getOpPackageName(), getContext().getAttributionTag(),
+ virtualDeviceId.get());
+
+ final AppOpsManager appOpsManager = getContext().getSystemService(AppOpsManager.class);
+ appOpsManager.startWatchingStarted(new int[]{AppOpsManager.OP_FINE_LOCATION,
+ AppOpsManager.OP_CAMERA}, listener);
+
+ appOpsManager.startOpNoThrow(getContext().getAttributionSource().getToken(),
+ AppOpsManager.OP_FINE_LOCATION, attributionSource, false,
+ "message", 0, AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE);
+
+ verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
+ .times(1)).onOpStarted(eq(AppOpsManager.OP_FINE_LOCATION),
+ eq(Process.myUid()), eq(getContext().getOpPackageName()),
+ eq(getContext().getAttributionTag()), eq(virtualDeviceId.get()),
+ eq(AppOpsManager.OP_FLAG_SELF),
+ eq(AppOpsManager.MODE_ALLOWED), eq(OnOpStartedListener.START_TYPE_STARTED),
+ eq(AppOpsManager.ATTRIBUTION_FLAGS_NONE),
+ eq(AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE));
+
+ appOpsManager.finishOp(getContext().getAttributionSource().getToken(),
+ AppOpsManager.OP_FINE_LOCATION, attributionSource);
+
+ verifyNoMoreInteractions(listener);
+
+ appOpsManager.stopWatchingStarted(listener);
+
+ verifyNoMoreInteractions(listener);
+ }
+
private static Context getContext() {
return InstrumentationRegistry.getContext();
}
diff --git a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceTest.java b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceTest.java
index 07dd59d2..a4628ee 100644
--- a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceTest.java
+++ b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceTest.java
@@ -18,6 +18,8 @@
import static android.companion.virtual.VirtualDeviceParams.DEVICE_POLICY_CUSTOM;
import static android.companion.virtual.VirtualDeviceParams.DEVICE_POLICY_DEFAULT;
+import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_AUDIO;
+import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_CAMERA;
import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_SENSORS;
import static android.content.Context.DEVICE_ID_DEFAULT;
import static android.content.Context.DEVICE_ID_INVALID;
@@ -135,4 +137,34 @@
when(mVirtualDevice.getDevicePolicy(POLICY_TYPE_SENSORS)).thenReturn(DEVICE_POLICY_CUSTOM);
assertThat(virtualDevice.hasCustomSensorSupport()).isTrue();
}
+
+ @Test
+ public void virtualDevice_hasCustomAudioInputSupport() throws Exception {
+ mSetFlagsRule.enableFlags(Flags.FLAG_VDM_PUBLIC_APIS);
+
+ VirtualDevice virtualDevice =
+ new VirtualDevice(
+ mVirtualDevice, VIRTUAL_DEVICE_ID, /*persistentId=*/null, /*name=*/null);
+
+ when(mVirtualDevice.getDevicePolicy(POLICY_TYPE_AUDIO)).thenReturn(DEVICE_POLICY_DEFAULT);
+ assertThat(virtualDevice.hasCustomAudioInputSupport()).isFalse();
+
+ when(mVirtualDevice.getDevicePolicy(POLICY_TYPE_AUDIO)).thenReturn(DEVICE_POLICY_CUSTOM);
+ assertThat(virtualDevice.hasCustomAudioInputSupport()).isTrue();
+ }
+
+ @Test
+ public void virtualDevice_hasCustomCameraSupport() throws Exception {
+ mSetFlagsRule.enableFlags(Flags.FLAG_VDM_PUBLIC_APIS);
+
+ VirtualDevice virtualDevice =
+ new VirtualDevice(
+ mVirtualDevice, VIRTUAL_DEVICE_ID, /*persistentId=*/null, /*name=*/null);
+
+ when(mVirtualDevice.getDevicePolicy(POLICY_TYPE_CAMERA)).thenReturn(DEVICE_POLICY_DEFAULT);
+ assertThat(virtualDevice.hasCustomCameraSupport()).isFalse();
+
+ when(mVirtualDevice.getDevicePolicy(POLICY_TYPE_CAMERA)).thenReturn(DEVICE_POLICY_CUSTOM);
+ assertThat(virtualDevice.hasCustomCameraSupport()).isTrue();
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java b/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java
index 3de167e..dacff4c 100644
--- a/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java
+++ b/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java
@@ -23,7 +23,6 @@
import android.content.Context;
import android.graphics.FontListParser;
-import android.graphics.fonts.FontFamily;
import android.graphics.fonts.FontManager;
import android.graphics.fonts.FontStyle;
import android.graphics.fonts.FontUpdateRequest;
@@ -324,15 +323,16 @@
Function<Map<String, File>, FontConfig> configSupplier = (map) -> {
FontConfig.Font fooFont = new FontConfig.Font(
new File(mPreinstalledFontDirs.get(0), "foo.ttf"), null, "foo",
- new FontStyle(400, FontStyle.FONT_SLANT_UPRIGHT), 0, null, null);
+ new FontStyle(400, FontStyle.FONT_SLANT_UPRIGHT), 0, null, null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE);
FontConfig.Font barFont = new FontConfig.Font(
new File(mPreinstalledFontDirs.get(1), "bar.ttf"), null, "bar",
- new FontStyle(400, FontStyle.FONT_SLANT_UPRIGHT), 0, null, null);
+ new FontStyle(400, FontStyle.FONT_SLANT_UPRIGHT), 0, null, null,
+ FontConfig.Font.VAR_TYPE_AXES_NONE);
FontConfig.FontFamily family = new FontConfig.FontFamily(
Arrays.asList(fooFont, barFont), null,
- FontConfig.FontFamily.VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE);
+ FontConfig.FontFamily.VARIANT_DEFAULT);
return new FontConfig(Collections.emptyList(),
Collections.emptyList(),
Collections.singletonList(new FontConfig.NamedFamilyList(
@@ -492,10 +492,9 @@
mConfigFile, mCurrentTimeSupplier, (map) -> {
FontConfig.Font font = new FontConfig.Font(
file, null, "bar", new FontStyle(400, FontStyle.FONT_SLANT_UPRIGHT),
- 0, null, null);
+ 0, null, null, FontConfig.Font.VAR_TYPE_AXES_NONE);
FontConfig.FontFamily family = new FontConfig.FontFamily(
- Collections.singletonList(font), null, FontConfig.FontFamily.VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE);
+ Collections.singletonList(font), null, FontConfig.FontFamily.VARIANT_DEFAULT);
return new FontConfig(
Collections.emptyList(),
Collections.emptyList(),
@@ -647,10 +646,9 @@
mConfigFile, mCurrentTimeSupplier, (map) -> {
FontConfig.Font font = new FontConfig.Font(
file, null, "test", new FontStyle(400, FontStyle.FONT_SLANT_UPRIGHT), 0, null,
- null);
+ null, FontConfig.Font.VAR_TYPE_AXES_NONE);
FontConfig.FontFamily family = new FontConfig.FontFamily(
- Collections.singletonList(font), null, FontConfig.FontFamily.VARIANT_DEFAULT,
- FontFamily.Builder.VARIABLE_FONT_FAMILY_TYPE_NONE);
+ Collections.singletonList(font), null, FontConfig.FontFamily.VARIANT_DEFAULT);
return new FontConfig(Collections.emptyList(), Collections.emptyList(),
Collections.singletonList(new FontConfig.NamedFamilyList(
Collections.singletonList(family), "sans-serif")),
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java
index 1172a87..4641802 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java
@@ -19,6 +19,7 @@
import static com.android.server.SystemService.PHASE_SYSTEM_SERVICES_READY;
import static com.android.server.hdmi.Constants.ADDR_TV;
import static com.android.server.hdmi.HdmiControlService.INITIATED_BY_ENABLE_CEC;
+import static com.android.server.hdmi.HdmiControlService.WAKE_UP_SCREEN_ON;
import static com.android.server.hdmi.OneTouchPlayAction.STATE_WAITING_FOR_REPORT_POWER_STATUS;
import static com.google.common.truth.Truth.assertThat;
@@ -46,6 +47,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.concurrent.TimeUnit;
/** Tests for {@link OneTouchPlayAction} */
@SmallTest
@@ -70,6 +72,7 @@
private Context mContextSpy;
private HdmiControlService mHdmiControlService;
+ private HdmiCecController mHdmiCecController;
private FakeNativeWrapper mNativeWrapper;
private FakePowerManagerWrapper mPowerManager;
private FakeHdmiCecConfig mHdmiCecConfig;
@@ -108,10 +111,10 @@
mHdmiControlService.setHdmiCecConfig(mHdmiCecConfig);
setHdmiControlEnabled(hdmiControlEnabled);
mNativeWrapper = new FakeNativeWrapper();
- HdmiCecController hdmiCecController = HdmiCecController.createWithNativeWrapper(
+ mHdmiCecController = HdmiCecController.createWithNativeWrapper(
this.mHdmiControlService, mNativeWrapper, mHdmiControlService.getAtomWriter());
mHdmiControlService.setDeviceConfig(new FakeDeviceConfigWrapper());
- mHdmiControlService.setCecController(hdmiCecController);
+ mHdmiControlService.setCecController(mHdmiCecController);
mHdmiControlService.setHdmiMhlController(HdmiMhlControllerStub.create(mHdmiControlService));
mHdmiControlService.initService();
mHdmiControlService.onBootPhase(PHASE_SYSTEM_SERVICES_READY);
@@ -618,6 +621,53 @@
assertThat(callback.getResult()).isEqualTo(HdmiControlManager.RESULT_SUCCESS);
}
+ @Test
+ public void onWakeUp_notInteractive_startOneTouchPlay() throws Exception {
+ setUp(true);
+
+ mHdmiControlService.onWakeUp(WAKE_UP_SCREEN_ON);
+ mPowerManager.setInteractive(false);
+ mTestLooper.dispatchAll();
+
+ assertThat(mPowerManager.isInteractive()).isFalse();
+ mNativeWrapper.clearResultMessages();
+ mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
+ mTestLooper.dispatchAll();
+
+ HdmiCecMessage textViewOn =
+ HdmiCecMessageBuilder.buildTextViewOn(
+ mHdmiControlService.playback().getDeviceInfo().getLogicalAddress(),
+ ADDR_TV);
+ assertThat(mNativeWrapper.getResultMessages()).contains(textViewOn);
+ }
+
+
+ @Test
+ public void onWakeUp_interruptedByOnStandby_notInteractive_OneTouchPlayNotStarted()
+ throws Exception {
+ setUp(true);
+ long allocationDelay = TimeUnit.SECONDS.toMillis(1);
+ mHdmiCecController.setLogicalAddressAllocationDelay(allocationDelay);
+ mTestLooper.dispatchAll();
+
+ mHdmiControlService.onWakeUp(WAKE_UP_SCREEN_ON);
+ mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF);
+ mPowerManager.setInteractive(false);
+ mTestLooper.dispatchAll();
+
+ assertThat(mPowerManager.isInteractive()).isFalse();
+ mNativeWrapper.clearResultMessages();
+ mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
+ mTestLooper.dispatchAll();
+
+ HdmiCecMessage textViewOn =
+ HdmiCecMessageBuilder.buildTextViewOn(
+ mHdmiControlService.playback().getDeviceInfo().getLogicalAddress(),
+ ADDR_TV);
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(textViewOn);
+
+ }
+
private static class TestActionTimer implements ActionTimer {
private int mState;
diff --git a/services/tests/servicestests/src/com/android/server/pm/SuspendPackagesTest.java b/services/tests/servicestests/src/com/android/server/pm/SuspendPackagesTest.java
index 398148f..2e5feff 100644
--- a/services/tests/servicestests/src/com/android/server/pm/SuspendPackagesTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/SuspendPackagesTest.java
@@ -273,7 +273,7 @@
final CountDownLatch latch = new CountDownLatch(1);
final IAppOpsCallback watcher = new IAppOpsCallback.Stub() {
@Override
- public void opChanged(int op, int uid, String packageName) {
+ public void opChanged(int op, int uid, String packageName, String persistentDeviceId) {
if (op == code && packageName.equals(TEST_APP_PACKAGE_NAME)) {
latch.countDown();
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 9c2cba8..ef0ac33 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -227,8 +227,6 @@
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
-import android.platform.test.rule.DeniedDevices;
-import android.platform.test.rule.DeviceProduct;
import android.platform.test.rule.LimitDevicesRule;
import android.provider.DeviceConfig;
import android.provider.MediaStore;
@@ -336,7 +334,6 @@
@RunWith(AndroidTestingRunner.class)
@SuppressLint("GuardedBy") // It's ok for this test to access guarded methods from the service.
@RunWithLooper
-@DeniedDevices(denied = {DeviceProduct.CF_AUTO})
public class NotificationManagerServiceTest extends UiServiceTestCase {
private static final String TEST_CHANNEL_ID = "NotificationManagerServiceTestChannelId";
private static final String TEST_PACKAGE = "The.name.is.Package.Test.Package";
@@ -593,7 +590,7 @@
when(mAtm.getTaskToShowPermissionDialogOn(anyString(), anyInt()))
.thenReturn(INVALID_TASK_ID);
mContext.addMockSystemService(AppOpsManager.class, mock(AppOpsManager.class));
- when(mUm.getProfileIds(0, false)).thenReturn(new int[]{0});
+ when(mUm.getProfileIds(eq(mUserId), eq(false))).thenReturn(new int[] { mUserId });
when(mPackageManagerClient.hasSystemFeature(FEATURE_TELECOM)).thenReturn(true);
@@ -881,9 +878,7 @@
private void simulatePackageRemovedBroadcast(String pkg, int uid) {
// mimics receive broadcast that package is removed, but doesn't remove the package.
final Bundle extras = new Bundle();
- extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,
- new String[]{pkg});
- extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST, new int[]{uid});
+ extras.putInt(Intent.EXTRA_UID, uid);
final Intent intent = new Intent(Intent.ACTION_PACKAGE_REMOVED);
intent.setData(Uri.parse("package:" + pkg));
@@ -1031,7 +1026,7 @@
private NotificationRecord generateNotificationRecord(NotificationChannel channel,
long postTime) {
- final StatusBarNotification sbn = generateSbn(PKG, mUid, postTime, 0);
+ final StatusBarNotification sbn = generateSbn(PKG, mUid, postTime, mUserId);
return new NotificationRecord(mContext, sbn, channel);
}
@@ -1766,7 +1761,7 @@
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testEnqueueNotification_appBlocked", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
verify(mWorkerHandler, never()).post(
any(NotificationManagerService.EnqueueNotificationRunnable.class));
@@ -1776,7 +1771,7 @@
public void testEnqueueNotificationWithTag_PopulatesGetActiveNotifications() throws Exception {
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testEnqueueNotificationWithTag_PopulatesGetActiveNotifications", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
StatusBarNotification[] notifs = mBinderService.getActiveNotifications(PKG);
assertEquals(1, notifs.length);
@@ -1787,7 +1782,7 @@
public void testEnqueueNotificationWithTag_WritesExpectedLogs() throws Exception {
final String tag = "testEnqueueNotificationWithTag_WritesExpectedLog";
mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
assertEquals(1, mNotificationRecordLogger.numCalls());
@@ -1828,12 +1823,12 @@
Notification original = new Notification.Builder(mContext,
mTestNotificationChannel.getId())
.setSmallIcon(android.R.drawable.sym_def_app_icon).build();
- mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, original, 0);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, original, mUserId);
Notification update = new Notification.Builder(mContext,
mTestNotificationChannel.getId())
.setSmallIcon(android.R.drawable.sym_def_app_icon)
.setCategory(Notification.CATEGORY_ALARM).build();
- mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, update, 0);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, update, mUserId);
waitForIdle();
assertEquals(2, mNotificationRecordLogger.numCalls());
@@ -1853,9 +1848,9 @@
public void testEnqueueNotificationWithTag_DoesNotLogOnMinorUpdate() throws Exception {
final String tag = "testEnqueueNotificationWithTag_DoesNotLogOnMinorUpdate";
mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
assertEquals(2, mNotificationRecordLogger.numCalls());
assertTrue(mNotificationRecordLogger.get(0).wasLogged);
@@ -1869,10 +1864,10 @@
final String tag = "testEnqueueNotificationWithTag_DoesNotLogOnTitleUpdate";
mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0,
generateNotificationRecord(null).getNotification(),
- 0);
+ mUserId);
final Notification notif = generateNotificationRecord(null).getNotification();
notif.extras.putString(Notification.EXTRA_TITLE, "Changed title");
- mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, notif, 0);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, notif, mUserId);
waitForIdle();
assertEquals(2, mNotificationRecordLogger.numCalls());
assertEquals(NOTIFICATION_POSTED, mNotificationRecordLogger.event(0));
@@ -1885,11 +1880,11 @@
Notification notification = new Notification.Builder(mContext,
mTestNotificationChannel.getId())
.setSmallIcon(android.R.drawable.sym_def_app_icon).build();
- mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, notification, 0);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, notification, mUserId);
waitForIdle();
- mBinderService.cancelNotificationWithTag(PKG, PKG, tag, 0, 0);
+ mBinderService.cancelNotificationWithTag(PKG, PKG, tag, 0, mUserId);
waitForIdle();
- mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, notification, 0);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, tag, 0, notification, mUserId);
waitForIdle();
assertEquals(3, mNotificationRecordLogger.numCalls());
@@ -1949,7 +1944,7 @@
.build();
n.actions[1] = null;
- mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", 0, n, 0);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", 0, n, mUserId);
waitForIdle();
StatusBarNotification[] posted = mBinderService.getActiveNotifications(PKG);
@@ -1970,7 +1965,7 @@
n.actions[0] = null;
n.actions[1] = null;
- mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", 0, n, 0);
+ mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag", 0, n, mUserId);
waitForIdle();
StatusBarNotification[] posted = mBinderService.getActiveNotifications(PKG);
@@ -1982,7 +1977,7 @@
public void enqueueNotificationWithTag_usesAndFinishesTracker() throws Exception {
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testEnqueueNotificationWithTag_PopulatesGetActiveNotifications", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
assertThat(mPostNotificationTrackerFactory.mCreatedTrackers).hasSize(1);
assertThat(mPostNotificationTrackerFactory.mCreatedTrackers.get(0).isOngoing()).isTrue();
@@ -2000,7 +1995,7 @@
assertThrows(Exception.class,
() -> mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testEnqueueNotificationWithTag_PopulatesGetActiveNotifications", 0,
- /* notification= */ null, 0));
+ /* notification= */ null, mUserId));
waitForIdle();
@@ -2017,7 +2012,7 @@
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testEnqueueNotificationWithTag_PopulatesGetActiveNotifications", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
assertThat(mBinderService.getActiveNotifications(PKG)).hasLength(0);
@@ -2032,7 +2027,7 @@
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testEnqueueNotificationWithTag_PopulatesGetActiveNotifications", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
assertThat(mBinderService.getActiveNotifications(PKG)).hasLength(0);
@@ -2044,7 +2039,7 @@
public void enqueueNotification_acquiresAndReleasesWakeLock() throws Exception {
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"enqueueNotification_acquiresAndReleasesWakeLock", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
verify(mPowerManager).newWakeLock(eq(PARTIAL_WAKE_LOCK), anyString());
assertThat(mAcquiredWakeLocks).hasSize(1);
@@ -2062,7 +2057,7 @@
assertThrows(Exception.class,
() -> mBinderService.enqueueNotificationWithTag(PKG, PKG,
"enqueueNotification_throws_acquiresAndReleasesWakeLock", 0,
- /* notification= */ null, 0));
+ /* notification= */ null, mUserId));
verify(mPowerManager).newWakeLock(eq(PARTIAL_WAKE_LOCK), anyString());
assertThat(mAcquiredWakeLocks).hasSize(1);
@@ -2077,7 +2072,7 @@
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"enqueueNotification_notEnqueued_acquiresAndReleasesWakeLock", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
verify(mPowerManager).newWakeLock(eq(PARTIAL_WAKE_LOCK), anyString());
assertThat(mAcquiredWakeLocks).hasSize(1);
@@ -2098,7 +2093,7 @@
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"enqueueNotification_notPosted_acquiresAndReleasesWakeLock", 0,
- notif, 0);
+ notif, mUserId);
verify(mPowerManager).newWakeLock(eq(PARTIAL_WAKE_LOCK), anyString());
assertThat(mAcquiredWakeLocks).hasSize(1);
@@ -2123,7 +2118,7 @@
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"enqueueNotification_setsWakeLockWorkSource", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
InOrder inOrder = inOrder(mPowerManager, wakeLock);
@@ -2137,7 +2132,7 @@
@Test
public void testCancelNonexistentNotification() throws Exception {
mBinderService.cancelNotificationWithTag(PKG, PKG,
- "testCancelNonexistentNotification", 0, 0);
+ "testCancelNonexistentNotification", 0, mUserId);
waitForIdle();
// The notification record logger doesn't even get called when a nonexistent notification
// is cancelled, because that happens very frequently and is not interesting.
@@ -2148,9 +2143,9 @@
public void testCancelNotificationImmediatelyAfterEnqueue() throws Exception {
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testCancelNotificationImmediatelyAfterEnqueue", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
mBinderService.cancelNotificationWithTag(PKG, PKG,
- "testCancelNotificationImmediatelyAfterEnqueue", 0, 0);
+ "testCancelNotificationImmediatelyAfterEnqueue", 0, mUserId);
waitForIdle();
StatusBarNotification[] notifs =
mBinderService.getActiveNotifications(PKG);
@@ -2185,13 +2180,13 @@
public void testCancelNotificationWhilePostedAndEnqueued() throws Exception {
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testCancelNotificationWhilePostedAndEnqueued", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
waitForIdle();
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testCancelNotificationWhilePostedAndEnqueued", 0,
- generateNotificationRecord(null).getNotification(), 0);
+ generateNotificationRecord(null).getNotification(), mUserId);
mBinderService.cancelNotificationWithTag(PKG, PKG,
- "testCancelNotificationWhilePostedAndEnqueued", 0, 0);
+ "testCancelNotificationWhilePostedAndEnqueued", 0, mUserId);
waitForIdle();
StatusBarNotification[] notifs =
mBinderService.getActiveNotifications(PKG);
@@ -3406,12 +3401,12 @@
@Test
public void testPostNotification_appPermissionFixed() throws Exception {
when(mPermissionHelper.hasPermission(mUid)).thenReturn(true);
- when(mPermissionHelper.isPermissionFixed(PKG, 0)).thenReturn(true);
+ when(mPermissionHelper.isPermissionFixed(PKG, mUserId)).thenReturn(true);
NotificationRecord temp = generateNotificationRecord(mTestNotificationChannel);
mBinderService.enqueueNotificationWithTag(PKG, PKG,
"testPostNotification_appPermissionFixed", 0,
- temp.getNotification(), 0);
+ temp.getNotification(), mUserId);
waitForIdle();
assertThat(mService.getNotificationRecordCount()).isEqualTo(1);
StatusBarNotification[] notifs =
@@ -3443,7 +3438,7 @@
Notification.TvExtender tv = new Notification.TvExtender().setChannelId("foo");
mBinderService.enqueueNotificationWithTag(PKG, PKG, "testTvExtenderChannelOverride_onTv", 0,
- generateNotificationRecord(null, tv).getNotification(), 0);
+ generateNotificationRecord(null, tv).getNotification(), mUserId);
verify(mPreferencesHelper, times(1)).getConversationNotificationChannel(
anyString(), anyInt(), eq("foo"), eq(null), anyBoolean(), anyBoolean());
}
@@ -3458,7 +3453,7 @@
Notification.TvExtender tv = new Notification.TvExtender().setChannelId("foo");
mBinderService.enqueueNotificationWithTag(PKG, PKG, "testTvExtenderChannelOverride_notOnTv",
- 0, generateNotificationRecord(null, tv).getNotification(), 0);
+ 0, generateNotificationRecord(null, tv).getNotification(), mUserId);
verify(mPreferencesHelper, times(1)).getConversationNotificationChannel(
anyString(), anyInt(), eq(mTestNotificationChannel.getId()), eq(null),
anyBoolean(), anyBoolean());
@@ -11859,10 +11854,10 @@
@Test
public void testGetActiveNotification_filtersUsers() throws Exception {
- when(mUm.getProfileIds(0, false)).thenReturn(new int[]{0, 10});
+ when(mUm.getProfileIds(mUserId, false)).thenReturn(new int[]{mUserId, 10});
NotificationRecord nr0 =
- generateNotificationRecord(mTestNotificationChannel, 0);
+ generateNotificationRecord(mTestNotificationChannel, mUserId);
mBinderService.enqueueNotificationWithTag(PKG, PKG, "tag0",
nr0.getSbn().getId(), nr0.getSbn().getNotification(), nr0.getSbn().getUserId());
@@ -12316,7 +12311,7 @@
.setFullScreenIntent(mock(PendingIntent.class), true)
.build();
- mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE, true);
+ mService.fixNotification(n, PKG, "tag", 9, mUserId, mUid, NOT_FOREGROUND_SERVICE, true);
final int stickyFlag = n.flags & Notification.FLAG_FSI_REQUESTED_BUT_DENIED;
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index 87e822c..5d114f4 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -2123,6 +2123,25 @@
}
@Test
+ @EnableFlags(Flags.FLAG_MODES_API)
+ public void testDefaultRulesFromConfig_modesApi_getPolicies() {
+ // After mZenModeHelper was created, set some things in the policy so it's changed from
+ // default.
+ setupZenConfig();
+
+ // Find default rules; check they have non-null policies; check that they match the default
+ // and not whatever has been set up in setupZenConfig.
+ ArrayMap<String, ZenModeConfig.ZenRule> rules = mZenModeHelper.mConfig.automaticRules;
+ for (String defaultId : ZenModeConfig.DEFAULT_RULE_IDS) {
+ assertThat(rules).containsKey(defaultId);
+ ZenRule rule = rules.get(defaultId);
+ assertThat(rule.zenPolicy).isNotNull();
+
+ assertThat(rule.zenPolicy).isEqualTo(mZenModeHelper.getDefaultZenPolicy());
+ }
+ }
+
+ @Test
public void testAddAutomaticZenRule_beyondSystemLimit() {
for (int i = 0; i < RULE_LIMIT_PER_PACKAGE; i++) {
ScheduleInfo si = new ScheduleInfo();
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibrationScalerTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibrationScalerTest.java
index f9fe6a9..b431888 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibrationScalerTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibrationScalerTest.java
@@ -53,7 +53,6 @@
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
-import android.util.SparseArray;
import androidx.test.InstrumentationRegistry;
@@ -270,10 +269,8 @@
setDefaultIntensity(USAGE_RINGTONE, VIBRATION_INTENSITY_HIGH);
setDefaultIntensity(USAGE_NOTIFICATION, VIBRATION_INTENSITY_HIGH);
- SparseArray<Float> adaptiveHapticsScales = new SparseArray<>();
- adaptiveHapticsScales.put(USAGE_RINGTONE, 0.5f);
- adaptiveHapticsScales.put(USAGE_NOTIFICATION, 0.5f);
- mVibrationScaler.updateAdaptiveHapticsScales(adaptiveHapticsScales);
+ mVibrationScaler.updateAdaptiveHapticsScale(USAGE_RINGTONE, 0.5f);
+ mVibrationScaler.updateAdaptiveHapticsScale(USAGE_NOTIFICATION, 0.5f);
StepSegment scaled = getFirstSegment(mVibrationScaler.scale(
VibrationEffect.createOneShot(128, 128), USAGE_RINGTONE));
@@ -287,6 +284,50 @@
assertTrue(scaled.getAmplitude() < 0.5);
}
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ADAPTIVE_HAPTICS_ENABLED)
+ public void scale_clearAdaptiveHapticsScales_clearsAllCachedScales() {
+ setDefaultIntensity(USAGE_RINGTONE, VIBRATION_INTENSITY_HIGH);
+ setDefaultIntensity(USAGE_NOTIFICATION, VIBRATION_INTENSITY_HIGH);
+
+ mVibrationScaler.updateAdaptiveHapticsScale(USAGE_RINGTONE, 0.5f);
+ mVibrationScaler.updateAdaptiveHapticsScale(USAGE_NOTIFICATION, 0.5f);
+ mVibrationScaler.clearAdaptiveHapticsScales();
+
+ StepSegment scaled = getFirstSegment(mVibrationScaler.scale(
+ VibrationEffect.createOneShot(128, 128), USAGE_RINGTONE));
+ // Ringtone scales up.
+ assertTrue(scaled.getAmplitude() > 0.5);
+
+ scaled = getFirstSegment(mVibrationScaler.scale(
+ VibrationEffect.createWaveform(new long[]{128}, new int[]{128}, -1),
+ USAGE_NOTIFICATION));
+ // Notification scales up.
+ assertTrue(scaled.getAmplitude() > 0.5);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ADAPTIVE_HAPTICS_ENABLED)
+ public void scale_removeAdaptiveHapticsScale_removesCachedScale() {
+ setDefaultIntensity(USAGE_RINGTONE, VIBRATION_INTENSITY_HIGH);
+ setDefaultIntensity(USAGE_NOTIFICATION, VIBRATION_INTENSITY_HIGH);
+
+ mVibrationScaler.updateAdaptiveHapticsScale(USAGE_RINGTONE, 0.5f);
+ mVibrationScaler.updateAdaptiveHapticsScale(USAGE_NOTIFICATION, 0.5f);
+ mVibrationScaler.removeAdaptiveHapticsScale(USAGE_NOTIFICATION);
+
+ StepSegment scaled = getFirstSegment(mVibrationScaler.scale(
+ VibrationEffect.createOneShot(128, 128), USAGE_RINGTONE));
+ // Ringtone scales down.
+ assertTrue(scaled.getAmplitude() < 0.5);
+
+ scaled = getFirstSegment(mVibrationScaler.scale(
+ VibrationEffect.createWaveform(new long[]{128}, new int[]{128}, -1),
+ USAGE_NOTIFICATION));
+ // Notification scales up.
+ assertTrue(scaled.getAmplitude() > 0.5);
+ }
+
private void setDefaultIntensity(@VibrationAttributes.Usage int usage,
@Vibrator.VibrationIntensity int intensity) {
when(mVibrationConfigMock.getDefaultVibrationIntensity(eq(usage))).thenReturn(intensity);
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
index b0aef47..6e478d8 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibrationThreadTest.java
@@ -16,6 +16,7 @@
package com.android.server.vibrator;
+import static android.os.VibrationAttributes.USAGE_RINGTONE;
import static android.os.VibrationEffect.VibrationParameter.targetAmplitude;
import static android.os.VibrationEffect.VibrationParameter.targetFrequency;
@@ -54,12 +55,16 @@
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.os.test.TestLooper;
+import android.os.vibrator.Flags;
import android.os.vibrator.PrebakedSegment;
import android.os.vibrator.PrimitiveSegment;
import android.os.vibrator.RampSegment;
import android.os.vibrator.StepSegment;
import android.os.vibrator.VibrationConfig;
import android.os.vibrator.VibrationEffectSegment;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.util.SparseArray;
import androidx.test.InstrumentationRegistry;
@@ -81,6 +86,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
import java.util.function.BooleanSupplier;
import java.util.stream.Collectors;
@@ -95,6 +101,9 @@
private static final int TEST_RAMP_STEP_DURATION = 5;
@Rule public MockitoRule mMockitoRule = MockitoJUnit.rule();
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule =
+ DeviceFlagsValueProvider.createCheckFlagsRule();
@Mock private PackageManagerInternal mPackageManagerInternalMock;
@Mock private VibrationThread.VibratorManagerHooks mManagerHooks;
@@ -104,6 +113,7 @@
private final Map<Integer, FakeVibratorControllerProvider> mVibratorProviders = new HashMap<>();
private VibrationSettings mVibrationSettings;
+ private VibrationScaler mVibrationScaler;
private TestLooper mTestLooper;
private TestLooperAutoDispatcher mCustomTestLooperDispatcher;
private VibrationThread mThread;
@@ -132,6 +142,7 @@
Context context = InstrumentationRegistry.getContext();
mVibrationSettings = new VibrationSettings(context, new Handler(mTestLooper.getLooper()),
mVibrationConfigMock);
+ mVibrationScaler = new VibrationScaler(context, mVibrationSettings);
mockVibrators(VIBRATOR_ID);
@@ -231,6 +242,45 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ADAPTIVE_HAPTICS_ENABLED)
+ public void vibrate_singleWaveformWithAdaptiveHapticsScaling_scalesAmplitudesProperly() {
+ mVibratorProviders.get(VIBRATOR_ID).setCapabilities(IVibrator.CAP_AMPLITUDE_CONTROL);
+
+ VibrationEffect effect = VibrationEffect.createWaveform(
+ new long[]{5, 5, 5}, new int[]{1, 1, 1}, -1);
+ CompletableFuture<Void> mRequestVibrationParamsFuture = CompletableFuture.runAsync(() -> {
+ mVibrationScaler.updateAdaptiveHapticsScale(USAGE_RINGTONE, 0.5f);
+ });
+ long vibrationId = startThreadAndDispatcher(effect, mRequestVibrationParamsFuture,
+ USAGE_RINGTONE);
+ waitForCompletion();
+
+ assertEquals(Arrays.asList(expectedOneShot(15)),
+ mVibratorProviders.get(VIBRATOR_ID).getEffectSegments(vibrationId));
+ List<Float> amplitudes = mVibratorProviders.get(VIBRATOR_ID).getAmplitudes();
+ for (int i = 0; i < amplitudes.size(); i++) {
+ assertTrue(amplitudes.get(i) < 1 / 255f);
+ }
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ADAPTIVE_HAPTICS_ENABLED)
+ public void vibrate_withVibrationParamsRequestStalling_timeoutRequestAndApplyNoScaling() {
+ mVibratorProviders.get(VIBRATOR_ID).setCapabilities(IVibrator.CAP_AMPLITUDE_CONTROL);
+ VibrationEffect effect = VibrationEffect.createWaveform(
+ new long[]{5, 5, 5}, new int[]{1, 1, 1}, -1);
+
+ CompletableFuture<Void> neverCompletingFuture = new CompletableFuture<>();
+ long vibrationId = startThreadAndDispatcher(effect, neverCompletingFuture, USAGE_RINGTONE);
+ waitForCompletion();
+
+ assertEquals(Arrays.asList(expectedOneShot(15)),
+ mVibratorProviders.get(VIBRATOR_ID).getEffectSegments(vibrationId));
+ assertEquals(expectedAmplitudes(1, 1, 1),
+ mVibratorProviders.get(VIBRATOR_ID).getAmplitudes());
+ }
+
+ @Test
public void vibrate_singleVibratorRepeatingWaveform_runsVibrationUntilThreadCancelled()
throws Exception {
FakeVibratorControllerProvider fakeVibrator = mVibratorProviders.get(VIBRATOR_ID);
@@ -1610,10 +1660,26 @@
}
private long startThreadAndDispatcher(HalVibration vib) {
+ return startThreadAndDispatcher(vib, /* requestVibrationParamsFuture= */ null);
+ }
+
+ private long startThreadAndDispatcher(VibrationEffect effect,
+ CompletableFuture<Void> requestVibrationParamsFuture, int usage) {
+ VibrationAttributes attrs = new VibrationAttributes.Builder()
+ .setUsage(usage)
+ .build();
+ HalVibration vib = new HalVibration(mVibrationToken,
+ CombinedVibration.createParallel(effect),
+ new Vibration.CallerInfo(attrs, UID, DEVICE_ID, PACKAGE_NAME, "reason"));
+ return startThreadAndDispatcher(vib, requestVibrationParamsFuture);
+ }
+
+ private long startThreadAndDispatcher(HalVibration vib,
+ CompletableFuture<Void> requestVibrationParamsFuture) {
mControllers = createVibratorControllers();
DeviceAdapter deviceAdapter = new DeviceAdapter(mVibrationSettings, mControllers);
- mVibrationConductor =
- new VibrationStepConductor(vib, mVibrationSettings, deviceAdapter, mManagerHooks);
+ mVibrationConductor = new VibrationStepConductor(vib, mVibrationSettings, deviceAdapter,
+ mVibrationScaler, requestVibrationParamsFuture, mManagerHooks);
assertTrue(mThread.runVibrationOnVibrationThread(mVibrationConductor));
return mVibrationConductor.getVibration().id;
}
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java
index 1e0b1df..2823223 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibratorControlServiceTest.java
@@ -18,29 +18,47 @@
import static android.os.VibrationAttributes.USAGE_ALARM;
import static android.os.VibrationAttributes.USAGE_COMMUNICATION_REQUEST;
+import static android.os.VibrationAttributes.USAGE_HARDWARE_FEEDBACK;
+import static android.os.VibrationAttributes.USAGE_MEDIA;
import static android.os.VibrationAttributes.USAGE_NOTIFICATION;
+import static android.os.VibrationAttributes.USAGE_RINGTONE;
+import static android.os.VibrationAttributes.USAGE_TOUCH;
+import static android.os.VibrationAttributes.USAGE_UNKNOWN;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+import android.content.ComponentName;
+import android.content.pm.PackageManagerInternal;
import android.frameworks.vibrator.ScaleParam;
import android.frameworks.vibrator.VibrationParam;
+import android.os.Binder;
+import android.os.Handler;
+import android.os.IBinder;
import android.os.RemoteException;
+import android.os.test.TestLooper;
import android.util.SparseArray;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.internal.util.ArrayUtils;
+import com.android.server.LocalServices;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
public class VibratorControlServiceTest {
@@ -49,35 +67,45 @@
@Mock
private VibrationScaler mMockVibrationScaler;
- @Captor
- private ArgumentCaptor<SparseArray<Float>> mVibrationScalesCaptor;
+ @Mock
+ private PackageManagerInternal mPackageManagerInternalMock;
+ private FakeVibratorController mFakeVibratorController;
private VibratorControlService mVibratorControlService;
+ private VibrationSettings mVibrationSettings;
private final Object mLock = new Object();
@Before
public void setUp() throws Exception {
+ when(mPackageManagerInternalMock.getSystemUiServiceComponent())
+ .thenReturn(new ComponentName("", ""));
+ LocalServices.removeServiceForTest(PackageManagerInternal.class);
+ LocalServices.addService(PackageManagerInternal.class, mPackageManagerInternalMock);
+
+ TestLooper testLooper = new TestLooper();
+ mVibrationSettings = new VibrationSettings(
+ ApplicationProvider.getApplicationContext(), new Handler(testLooper.getLooper()));
+
+ mFakeVibratorController = new FakeVibratorController();
mVibratorControlService = new VibratorControlService(new VibratorControllerHolder(),
- mMockVibrationScaler, mLock);
+ mMockVibrationScaler, mVibrationSettings, mLock);
}
@Test
public void testRegisterVibratorController() throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
- mVibratorControlService.registerVibratorController(fakeController);
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
- assertThat(fakeController.isLinkedToDeath).isTrue();
+ assertThat(mFakeVibratorController.isLinkedToDeath).isTrue();
}
@Test
public void testUnregisterVibratorController_providingTheRegisteredController_performsRequest()
throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
- mVibratorControlService.registerVibratorController(fakeController);
- mVibratorControlService.unregisterVibratorController(fakeController);
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
+ mVibratorControlService.unregisterVibratorController(mFakeVibratorController);
- verify(mMockVibrationScaler).updateAdaptiveHapticsScales(null);
- assertThat(fakeController.isLinkedToDeath).isFalse();
+ verify(mMockVibrationScaler).clearAdaptiveHapticsScales();
+ assertThat(mFakeVibratorController.isLinkedToDeath).isFalse();
}
@Test
@@ -93,41 +121,80 @@
}
@Test
+ public void testOnRequestVibrationParamsComplete_cachesAdaptiveHapticsScalesCorrectly()
+ throws RemoteException {
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
+ int timeoutInMillis = 10;
+ CompletableFuture<Void> future =
+ mVibratorControlService.triggerVibrationParamsRequest(USAGE_RINGTONE,
+ timeoutInMillis);
+ IBinder token = mVibratorControlService.getRequestVibrationParamsToken();
+
+ SparseArray<Float> vibrationScales = new SparseArray<>();
+ vibrationScales.put(ScaleParam.TYPE_ALARM, 0.7f);
+ vibrationScales.put(ScaleParam.TYPE_NOTIFICATION, 0.4f);
+
+ mVibratorControlService.onRequestVibrationParamsComplete(token,
+ generateVibrationParams(vibrationScales));
+
+ verify(mMockVibrationScaler).updateAdaptiveHapticsScale(USAGE_ALARM, 0.7f);
+ verify(mMockVibrationScaler).updateAdaptiveHapticsScale(USAGE_NOTIFICATION, 0.4f);
+ // Setting ScaleParam.TYPE_NOTIFICATION will update vibration scaling for both
+ // notification and communication request usages.
+ verify(mMockVibrationScaler).updateAdaptiveHapticsScale(USAGE_COMMUNICATION_REQUEST, 0.4f);
+ verifyNoMoreInteractions(mMockVibrationScaler);
+
+ assertThat(future.isDone()).isTrue();
+ assertThat(future.isCompletedExceptionally()).isFalse();
+ }
+
+ @Test
+ public void testOnRequestVibrationParamsComplete_withIncorrectToken_ignoresRequest()
+ throws RemoteException, InterruptedException {
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
+ int timeoutInMillis = 10;
+ CompletableFuture<Void> unusedFuture =
+ mVibratorControlService.triggerVibrationParamsRequest(USAGE_RINGTONE,
+ timeoutInMillis);
+
+ SparseArray<Float> vibrationScales = new SparseArray<>();
+ vibrationScales.put(ScaleParam.TYPE_ALARM, 0.7f);
+ vibrationScales.put(ScaleParam.TYPE_NOTIFICATION, 0.4f);
+
+ mVibratorControlService.onRequestVibrationParamsComplete(new Binder(),
+ generateVibrationParams(vibrationScales));
+
+ verifyZeroInteractions(mMockVibrationScaler);
+ }
+
+ @Test
public void testSetVibrationParams_cachesAdaptiveHapticsScalesCorrectly()
throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
- mVibratorControlService.registerVibratorController(fakeController);
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
SparseArray<Float> vibrationScales = new SparseArray<>();
vibrationScales.put(ScaleParam.TYPE_ALARM, 0.7f);
vibrationScales.put(ScaleParam.TYPE_NOTIFICATION, 0.4f);
mVibratorControlService.setVibrationParams(generateVibrationParams(vibrationScales),
- fakeController);
+ mFakeVibratorController);
- verify(mMockVibrationScaler).updateAdaptiveHapticsScales(mVibrationScalesCaptor.capture());
- SparseArray<Float> cachedVibrationScales = mVibrationScalesCaptor.getValue();
- assertThat(cachedVibrationScales.size()).isEqualTo(3);
- assertThat(cachedVibrationScales.keyAt(0)).isEqualTo(USAGE_ALARM);
- assertThat(cachedVibrationScales.valueAt(0)).isEqualTo(0.7f);
- assertThat(cachedVibrationScales.keyAt(1)).isEqualTo(USAGE_NOTIFICATION);
- assertThat(cachedVibrationScales.valueAt(1)).isEqualTo(0.4f);
+ verify(mMockVibrationScaler).updateAdaptiveHapticsScale(USAGE_ALARM, 0.7f);
+ verify(mMockVibrationScaler).updateAdaptiveHapticsScale(USAGE_NOTIFICATION, 0.4f);
// Setting ScaleParam.TYPE_NOTIFICATION will update vibration scaling for both
// notification and communication request usages.
- assertThat(cachedVibrationScales.keyAt(2)).isEqualTo(USAGE_COMMUNICATION_REQUEST);
- assertThat(cachedVibrationScales.valueAt(2)).isEqualTo(0.4f);
+ verify(mMockVibrationScaler).updateAdaptiveHapticsScale(USAGE_COMMUNICATION_REQUEST, 0.4f);
+ verifyNoMoreInteractions(mMockVibrationScaler);
}
@Test
public void testSetVibrationParams_withUnregisteredController_ignoresRequest()
throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
-
SparseArray<Float> vibrationScales = new SparseArray<>();
vibrationScales.put(ScaleParam.TYPE_ALARM, 0.7f);
vibrationScales.put(ScaleParam.TYPE_NOTIFICATION, 0.4f);
mVibratorControlService.setVibrationParams(generateVibrationParams(vibrationScales),
- fakeController);
+ mFakeVibratorController);
verifyZeroInteractions(mMockVibrationScaler);
}
@@ -135,23 +202,72 @@
@Test
public void testClearVibrationParams_clearsCachedAdaptiveHapticsScales()
throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
- mVibratorControlService.registerVibratorController(fakeController);
- mVibratorControlService.clearVibrationParams(ScaleParam.TYPE_ALARM, fakeController);
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
+ int types = buildVibrationTypesMask(ScaleParam.TYPE_ALARM, ScaleParam.TYPE_NOTIFICATION);
- verify(mMockVibrationScaler).updateAdaptiveHapticsScales(null);
+ mVibratorControlService.clearVibrationParams(types, mFakeVibratorController);
+
+ verify(mMockVibrationScaler).removeAdaptiveHapticsScale(USAGE_ALARM);
+ verify(mMockVibrationScaler).removeAdaptiveHapticsScale(USAGE_NOTIFICATION);
+ // Clearing ScaleParam.TYPE_NOTIFICATION will clear vibration scaling for both
+ // notification and communication request usages.
+ verify(mMockVibrationScaler).removeAdaptiveHapticsScale(USAGE_COMMUNICATION_REQUEST);
}
@Test
public void testClearVibrationParams_withUnregisteredController_ignoresRequest()
throws RemoteException {
- FakeVibratorController fakeController = new FakeVibratorController();
-
- mVibratorControlService.clearVibrationParams(ScaleParam.TYPE_ALARM, fakeController);
+ mVibratorControlService.clearVibrationParams(ScaleParam.TYPE_ALARM,
+ mFakeVibratorController);
verifyZeroInteractions(mMockVibrationScaler);
}
+ @Test
+ public void testRequestVibrationParams_createsFutureRequestProperly()
+ throws RemoteException {
+ int timeoutInMillis = 10;
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
+ CompletableFuture<Void> future =
+ mVibratorControlService.triggerVibrationParamsRequest(USAGE_RINGTONE,
+ timeoutInMillis);
+ try {
+ future.orTimeout(timeoutInMillis, TimeUnit.MILLISECONDS).get();
+ } catch (Throwable ignored) {
+ }
+ assertThat(mFakeVibratorController.didRequestVibrationParams).isTrue();
+ assertThat(mFakeVibratorController.requestVibrationType).isEqualTo(
+ ScaleParam.TYPE_RINGTONE);
+ assertThat(mFakeVibratorController.requestTimeoutInMillis).isEqualTo(timeoutInMillis);
+ }
+
+ @Test
+ public void testShouldRequestVibrationParams_returnsTrueForVibrationsThatShouldRequestParams()
+ throws RemoteException {
+ int[] vibrations =
+ new int[]{USAGE_ALARM, USAGE_RINGTONE, USAGE_MEDIA, USAGE_TOUCH, USAGE_NOTIFICATION,
+ USAGE_HARDWARE_FEEDBACK, USAGE_UNKNOWN, USAGE_COMMUNICATION_REQUEST};
+ mVibratorControlService.registerVibratorController(mFakeVibratorController);
+
+ for (int vibration : vibrations) {
+ assertThat(mVibratorControlService.shouldRequestVibrationParams(vibration))
+ .isEqualTo(ArrayUtils.contains(
+ mVibrationSettings.getRequestVibrationParamsForUsages(), vibration));
+ }
+ }
+
+ @Test
+ public void testShouldRequestVibrationParams_unregisteredVibratorController_returnsFalse()
+ throws RemoteException {
+ int[] vibrations =
+ new int[]{USAGE_ALARM, USAGE_RINGTONE, USAGE_MEDIA, USAGE_TOUCH, USAGE_NOTIFICATION,
+ USAGE_HARDWARE_FEEDBACK, USAGE_UNKNOWN, USAGE_COMMUNICATION_REQUEST};
+
+ for (int vibration : vibrations) {
+ assertThat(mVibratorControlService.shouldRequestVibrationParams(vibration)).isFalse();
+ }
+ }
+
private VibrationParam[] generateVibrationParams(SparseArray<Float> vibrationScales) {
List<VibrationParam> vibrationParamList = new ArrayList<>();
for (int i = 0; i < vibrationScales.size(); i++) {
@@ -173,4 +289,12 @@
return vibrationParam;
}
+
+ private int buildVibrationTypesMask(int... types) {
+ int typesMask = 0;
+ for (int type : types) {
+ typesMask |= type;
+ }
+ return typesMask;
+ }
}
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
index d6b2116..bdbb6c6 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java
@@ -318,6 +318,12 @@
return new HapticFeedbackVibrationProvider(
resources, vibratorInfo, mHapticFeedbackVibrationMap);
}
+
+ VibratorControllerHolder createVibratorControllerHolder() {
+ VibratorControllerHolder holder = new VibratorControllerHolder();
+ holder.setVibratorController(new FakeVibratorController());
+ return holder;
+ }
});
return mService;
}
@@ -965,8 +971,9 @@
new long[]{10, 10_000}, new int[]{255, 0}, 1);
vibrate(service, repeatingEffect, ALARM_ATTRS);
- // VibrationThread will start this vibration async, wait until the off waveform step.
- assertTrue(waitUntil(s -> fakeVibrator.getOffCount() > 0, service, TEST_TIMEOUT_MILLIS));
+ // VibrationThread will start this vibration async, wait until it has started.
+ assertTrue(waitUntil(s -> !fakeVibrator.getAllEffectSegments().isEmpty(), service,
+ TEST_TIMEOUT_MILLIS));
vibrateAndWaitUntilFinished(service, VibrationEffect.get(VibrationEffect.EFFECT_CLICK),
ALARM_ATTRS);
@@ -1019,8 +1026,9 @@
new long[]{10, 10_000}, new int[]{255, 0}, -1);
vibrate(service, alarmEffect, ALARM_ATTRS);
- // VibrationThread will start this vibration async, wait until the off waveform step.
- assertTrue(waitUntil(s -> fakeVibrator.getOffCount() > 0, service, TEST_TIMEOUT_MILLIS));
+ // VibrationThread will start this vibration async, wait until it has started.
+ assertTrue(waitUntil(s -> !fakeVibrator.getAllEffectSegments().isEmpty(), service,
+ TEST_TIMEOUT_MILLIS));
vibrateAndWaitUntilFinished(service, VibrationEffect.get(VibrationEffect.EFFECT_CLICK),
UNKNOWN_ATTRS);
diff --git a/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java b/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java
index 7e23587..3912206 100644
--- a/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java
+++ b/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorController.java
@@ -20,6 +20,7 @@
import android.frameworks.vibrator.IVibratorController;
import android.os.IBinder;
import android.os.RemoteException;
+import android.os.VibrationAttributes;
/**
* Provides a fake implementation of {@link android.frameworks.vibrator.IVibratorController} for
@@ -28,10 +29,16 @@
public final class FakeVibratorController extends IVibratorController.Stub {
public boolean isLinkedToDeath = false;
+ public boolean didRequestVibrationParams = false;
+ public int requestVibrationType = VibrationAttributes.USAGE_UNKNOWN;
+ public long requestTimeoutInMillis = 0;
@Override
- public void requestVibrationParams(int i, long l, IBinder iBinder) throws RemoteException {
-
+ public void requestVibrationParams(int vibrationType, long timeoutInMillis, IBinder iBinder)
+ throws RemoteException {
+ didRequestVibrationParams = true;
+ requestVibrationType = vibrationType;
+ requestTimeoutInMillis = timeoutInMillis;
}
@Override
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index a0f0338..89661a4 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -6638,11 +6638,7 @@
}
}
- /**
- * @hide
- */
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
- private ITelephony getITelephony() {
+ private static ITelephony getITelephony() {
// Keeps cache disabled until test fixes are checked into AOSP.
if (!sServiceHandleCacheEnabled) {
return ITelephony.Stub.asInterface(
@@ -18696,11 +18692,7 @@
@SimState
public static int getSimStateForSlotIndex(int slotIndex) {
try {
- ITelephony telephony = ITelephony.Stub.asInterface(
- TelephonyFrameworkInitializer
- .getTelephonyServiceManager()
- .getTelephonyServiceRegisterer()
- .get());
+ ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getSimStateForSlotIndex(slotIndex);
}
diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java
index 09d2108..9b8e62f 100644
--- a/telephony/java/android/telephony/euicc/EuiccManager.java
+++ b/telephony/java/android/telephony/euicc/EuiccManager.java
@@ -43,6 +43,7 @@
import android.util.Log;
import com.android.internal.telephony.euicc.IEuiccController;
+import com.android.internal.telephony.flags.Flags;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -897,9 +898,7 @@
/** @hide */
public EuiccManager(Context context) {
mContext = context;
- TelephonyManager tm = (TelephonyManager)
- context.getSystemService(Context.TELEPHONY_SERVICE);
- mCardId = tm.getCardIdForDefaultEuicc();
+ mCardId = getCardIdForDefaultEuicc();
}
/** @hide */
@@ -1646,14 +1645,9 @@
private boolean refreshCardIdIfUninitialized() {
// Refresh mCardId if its UNINITIALIZED_CARD_ID
if (mCardId == TelephonyManager.UNINITIALIZED_CARD_ID) {
- TelephonyManager tm = (TelephonyManager)
- mContext.getSystemService(Context.TELEPHONY_SERVICE);
- mCardId = tm.getCardIdForDefaultEuicc();
+ mCardId = getCardIdForDefaultEuicc();
}
- if (mCardId == TelephonyManager.UNINITIALIZED_CARD_ID) {
- return false;
- }
- return true;
+ return mCardId != TelephonyManager.UNINITIALIZED_CARD_ID;
}
private static void sendUnavailableError(PendingIntent callbackIntent) {
@@ -1672,6 +1666,23 @@
.get());
}
+ private int getCardIdForDefaultEuicc() {
+ int cardId = TelephonyManager.UNINITIALIZED_CARD_ID;
+
+ if (Flags.enforceTelephonyFeatureMappingForPublicApis()) {
+ PackageManager pm = mContext.getPackageManager();
+ if (pm != null && pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_EUICC)) {
+ TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
+ cardId = tm.getCardIdForDefaultEuicc();
+ }
+ } else {
+ TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
+ cardId = tm.getCardIdForDefaultEuicc();
+ }
+
+ return cardId;
+ }
+
/**
* Returns whether the passing portIndex is available.
* A port is available if it is active without enabled profile on it or
diff --git a/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java b/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
index 6015e931..381c574 100644
--- a/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
+++ b/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
@@ -101,7 +101,7 @@
@Mock protected Context mContext;
@Mock protected Network mNetwork;
@Mock protected FeatureFlags mFeatureFlags;
- @Mock protected com.android.net.flags.FeatureFlags mCoreNetFeatureFlags;
+ @Mock protected android.net.platform.flags.FeatureFlags mCoreNetFeatureFlags;
@Mock protected TelephonySubscriptionSnapshot mSubscriptionSnapshot;
@Mock protected TelephonyManager mTelephonyManager;
@Mock protected IPowerManager mPowerManagerService;
diff --git a/tools/aapt2/Android.bp b/tools/aapt2/Android.bp
index 275a0e2..938a5ed 100644
--- a/tools/aapt2/Android.bp
+++ b/tools/aapt2/Android.bp
@@ -232,3 +232,39 @@
],
},
}
+
+cc_genrule {
+ name: "aapt2_results",
+ srcs: [
+ ":aapt2_tests",
+ "integration-tests/CompileTest/**/*",
+ "integration-tests/CommandTests/**/*",
+ "integration-tests/ConvertTest/**/*",
+ "integration-tests/DumpTest/**/*",
+ ],
+ host_supported: true,
+ device_supported: false,
+ target: {
+ windows: {
+ compile_multilib: "64",
+ },
+ },
+ out: ["result.xml"],
+ cmd: "mkdir -p $(genDir)/integration-tests/CompileTest/ && " +
+ "cp $(locations integration-tests/CompileTest/**/*) $(genDir)/integration-tests/CompileTest/ && " +
+ "mkdir -p $(genDir)/integration-tests/CommandTests/ && " +
+ "cp $(locations integration-tests/CommandTests/**/*) $(genDir)/integration-tests/CompileTest/ && " +
+ "mkdir -p $(genDir)/integration-tests/ConvertTest/ && " +
+ "cp $(locations integration-tests/ConvertTest/**/*) $(genDir)/integration-tests/ConvertTest/ && " +
+ "mkdir -p $(genDir)/integration-tests/DumpTest/ && " +
+ "cp $(locations integration-tests/DumpTest/**/*) $(genDir)/integration-tests/DumpTest/ && " +
+ "cp $(locations :aapt2_tests) $(genDir)/ && " +
+ "$(genDir)/aapt2_tests " +
+ "--gtest_output=xml:$(out) " +
+ ">/dev/null 2>&1 ; true",
+}
+
+phony_rule {
+ name: "aapt2_run_host_unit_tests",
+ phony_deps: ["aapt2_results"],
+}
diff --git a/tools/aapt2/Android.mk b/tools/aapt2/Android.mk
index 34a1b11..15ae2ba 100644
--- a/tools/aapt2/Android.mk
+++ b/tools/aapt2/Android.mk
@@ -1,22 +1,4 @@
-LOCAL_PATH := $(call my-dir)
-
include $(CLEAR_VARS)
-
-aapt2_results := $(call intermediates-dir-for,PACKAGING,aapt2_run_host_unit_tests)/result.xml
-
-# Target for running host unit tests on post/pre-submit.
-.PHONY: aapt2_run_host_unit_tests
-aapt2_run_host_unit_tests: $(aapt2_results)
-
-$(call dist-for-goals,aapt2_run_host_unit_tests,$(aapt2_results):gtest/aapt2_host_unit_tests_result.xml)
-
-# Always run the tests again, even if they haven't changed
-$(aapt2_results): .KATI_IMPLICIT_OUTPUTS := $(aapt2_results)-nocache
-$(aapt2_results): $(HOST_OUT_NATIVE_TESTS)/aapt2_tests/aapt2_tests
- -$(HOST_OUT_NATIVE_TESTS)/aapt2_tests/aapt2_tests --gtest_output=xml:$@ > /dev/null 2>&1
-
+aapt2_results := ./out/soong/.intermediates/frameworks/base/tools/aapt2/aapt2_results
$(call declare-1p-target,$(aapt2_results))
-
aapt2_results :=
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/EventLog_host.java b/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/EventLog_host.java
index 292e8da..6480cfc 100644
--- a/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/EventLog_host.java
+++ b/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/EventLog_host.java
@@ -15,9 +15,9 @@
*/
package com.android.hoststubgen.nativesubstitution;
-import android.util.Log;
-import android.util.Log.Level;
+import com.android.internal.os.RuntimeInit;
+import java.io.PrintStream;
import java.util.Collection;
public class EventLog_host {
@@ -54,7 +54,7 @@
}
}
sb.append(']');
- System.out.println(sb.toString());
+ getRealOut().println(sb.toString());
return sb.length();
}
@@ -66,4 +66,16 @@
Collection<android.util.EventLog.Event> output) {
throw new UnsupportedOperationException();
}
+
+ /**
+ * Return the "real" {@code System.out} if it's been swapped by {@code RavenwoodRuleImpl}, so
+ * that we don't end up in a recursive loop.
+ */
+ private static PrintStream getRealOut() {
+ if (RuntimeInit.sOut$ravenwood != null) {
+ return RuntimeInit.sOut$ravenwood;
+ } else {
+ return System.out;
+ }
+ }
}
diff --git a/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Log_host.java b/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Log_host.java
index ee55c7a..cdfa302 100644
--- a/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Log_host.java
+++ b/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Log_host.java
@@ -18,6 +18,8 @@
import android.util.Log;
import android.util.Log.Level;
+import com.android.internal.os.RuntimeInit;
+
import java.io.PrintStream;
public class Log_host {
@@ -27,7 +29,6 @@
}
public static int println_native(int bufID, int priority, String tag, String msg) {
- final PrintStream out = System.out;
final String buffer;
switch (bufID) {
case Log.LOG_ID_MAIN: buffer = "main"; break;
@@ -50,7 +51,7 @@
};
for (String s : msg.split("\\n")) {
- out.println(String.format("logd: [%s] %s %s: %s", buffer, prio, tag, s));
+ getRealOut().println(String.format("logd: [%s] %s %s: %s", buffer, prio, tag, s));
}
return msg.length();
}
@@ -58,4 +59,16 @@
public static int logger_entry_max_payload_native() {
return 4068; // [ravenwood] This is what people use in various places.
}
+
+ /**
+ * Return the "real" {@code System.out} if it's been swapped by {@code RavenwoodRuleImpl}, so
+ * that we don't end up in a recursive loop.
+ */
+ private static PrintStream getRealOut() {
+ if (RuntimeInit.sOut$ravenwood != null) {
+ return RuntimeInit.sOut$ravenwood;
+ } else {
+ return System.out;
+ }
+ }
}
diff --git a/wifi/java/src/android/net/wifi/nl80211/DeviceWiphyCapabilities.java b/wifi/java/src/android/net/wifi/nl80211/DeviceWiphyCapabilities.java
index 21700d5..6d57a87 100644
--- a/wifi/java/src/android/net/wifi/nl80211/DeviceWiphyCapabilities.java
+++ b/wifi/java/src/android/net/wifi/nl80211/DeviceWiphyCapabilities.java
@@ -16,11 +16,13 @@
package android.net.wifi.nl80211;
+import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiAnnotations.ChannelWidth;
import android.net.wifi.WifiAnnotations.WifiStandard;
+import android.net.wifi.flags.Flags;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@@ -48,6 +50,7 @@
private boolean mChannelWidth320MhzSupported;
private int mMaxNumberTxSpatialStreams;
private int mMaxNumberRxSpatialStreams;
+ private int mMaxNumberAkms;
/** public constructor */
@@ -61,6 +64,7 @@
mChannelWidth320MhzSupported = false;
mMaxNumberTxSpatialStreams = 1;
mMaxNumberRxSpatialStreams = 1;
+ mMaxNumberAkms = 1;
}
/**
@@ -199,6 +203,25 @@
}
/**
+ * Get the maximum number of AKM suites supported in the connection request to the driver.
+ *
+ * @return maximum number of AKMs
+ */
+ @FlaggedApi(Flags.FLAG_GET_DEVICE_CROSS_AKM_ROAMING_SUPPORT)
+ public int getMaxNumberAkms() {
+ return mMaxNumberAkms;
+ }
+
+ /**
+ * Set the maximum number of AKM suites supported in the connection request to the driver.
+ *
+ * @hide
+ */
+ public void setMaxNumberAkms(int akms) {
+ mMaxNumberAkms = akms;
+ }
+
+ /**
* Set maximum number of receive spatial streams
*
* @param streams number of streams
@@ -226,7 +249,8 @@
&& mChannelWidth80p80MhzSupported == capa.mChannelWidth80p80MhzSupported
&& mChannelWidth320MhzSupported == capa.mChannelWidth320MhzSupported
&& mMaxNumberTxSpatialStreams == capa.mMaxNumberTxSpatialStreams
- && mMaxNumberRxSpatialStreams == capa.mMaxNumberRxSpatialStreams;
+ && mMaxNumberRxSpatialStreams == capa.mMaxNumberRxSpatialStreams
+ && mMaxNumberAkms == capa.mMaxNumberAkms;
}
/** override hash code */
@@ -235,7 +259,7 @@
return Objects.hash(m80211nSupported, m80211acSupported, m80211axSupported,
m80211beSupported, mChannelWidth160MhzSupported, mChannelWidth80p80MhzSupported,
mChannelWidth320MhzSupported, mMaxNumberTxSpatialStreams,
- mMaxNumberRxSpatialStreams);
+ mMaxNumberRxSpatialStreams, mMaxNumberAkms);
}
/** implement Parcelable interface */
@@ -259,6 +283,7 @@
out.writeBoolean(mChannelWidth320MhzSupported);
out.writeInt(mMaxNumberTxSpatialStreams);
out.writeInt(mMaxNumberRxSpatialStreams);
+ out.writeInt(mMaxNumberAkms);
}
@Override
@@ -276,6 +301,7 @@
.append(mChannelWidth320MhzSupported ? "Yes" : "No");
sb.append("mMaxNumberTxSpatialStreams: ").append(mMaxNumberTxSpatialStreams);
sb.append("mMaxNumberRxSpatialStreams: ").append(mMaxNumberRxSpatialStreams);
+ sb.append("mMaxNumberAkms: ").append(mMaxNumberAkms);
return sb.toString();
}
@@ -298,6 +324,7 @@
capabilities.mChannelWidth320MhzSupported = in.readBoolean();
capabilities.mMaxNumberTxSpatialStreams = in.readInt();
capabilities.mMaxNumberRxSpatialStreams = in.readInt();
+ capabilities.mMaxNumberAkms = in.readInt();
return capabilities;
}
diff --git a/wifi/tests/src/android/net/wifi/nl80211/DeviceWiphyCapabilitiesTest.java b/wifi/tests/src/android/net/wifi/nl80211/DeviceWiphyCapabilitiesTest.java
index 7b900fe..5a3ca2b 100644
--- a/wifi/tests/src/android/net/wifi/nl80211/DeviceWiphyCapabilitiesTest.java
+++ b/wifi/tests/src/android/net/wifi/nl80211/DeviceWiphyCapabilitiesTest.java
@@ -49,6 +49,7 @@
capa.setChannelWidthSupported(ScanResult.CHANNEL_WIDTH_80MHZ_PLUS_MHZ, false);
capa.setMaxNumberTxSpatialStreams(2);
capa.setMaxNumberRxSpatialStreams(1);
+ capa.setMaxNumberAkms(2);
Parcel parcel = Parcel.obtain();
capa.writeToParcel(parcel, 0);
diff --git a/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java b/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java
index 362eb14..02da835 100644
--- a/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/nl80211/WifiNl80211ManagerTest.java
@@ -1130,6 +1130,7 @@
capaExpected.setChannelWidthSupported(ScanResult.CHANNEL_WIDTH_80MHZ_PLUS_MHZ, false);
capaExpected.setMaxNumberTxSpatialStreams(2);
capaExpected.setMaxNumberRxSpatialStreams(1);
+ capaExpected.setMaxNumberAkms(2);
when(mWificond.getDeviceWiphyCapabilities(TEST_INTERFACE_NAME))
.thenReturn(capaExpected);
diff --git a/wifi/wifi.aconfig b/wifi/wifi.aconfig
new file mode 100644
index 0000000..6ac986e
--- /dev/null
+++ b/wifi/wifi.aconfig
@@ -0,0 +1,9 @@
+package: "android.net.wifi.flags"
+
+flag {
+ name: "get_device_cross_akm_roaming_support"
+ namespace: "wifi"
+ description: "Add new API to get the device support for CROSS-AKM roaming"
+ bug: "313038031"
+ is_fixed_read_only: true
+}