Loading core/java/android/app/ActivityClient.java +12 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,18 @@ public class ActivityClient { } } /** * Returns the windowing mode of the task that hosts the activity, or {@code -1} if task is not * found. */ public int getTaskWindowingMode(IBinder activityToken) { try { return getActivityClientController().getTaskWindowingMode(activityToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the non-finishing activity token below in the same task if it belongs to the same * process. Loading core/java/android/app/IActivityClientController.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ interface IActivityClientController { boolean willActivityBeVisible(in IBinder token); int getDisplayId(in IBinder activityToken); int getTaskForActivity(in IBinder token, in boolean onlyRoot); int getTaskWindowingMode(in IBinder activityToken); IBinder getActivityTokenBelow(IBinder token); ComponentName getCallingActivity(in IBinder token); String getCallingPackage(in IBinder token); Loading core/java/android/hardware/camera2/marshal/impl/MarshalQueryableArray.java +13 −25 Original line number Diff line number Diff line Loading @@ -45,46 +45,41 @@ public class MarshalQueryableArray<T> implements MarshalQueryable<T> { private static final boolean DEBUG = false; private static interface PrimitiveArrayFiller { public void fillPosition(Object arr, int index, ByteBuffer buffer); public void fillArray(Object arr, int size, ByteBuffer buffer); static PrimitiveArrayFiller getPrimitiveArrayFiller(Class<?> componentType) { if (componentType == int.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { int i = buffer.getInt(); Array.setInt(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asIntBuffer().get(int[].class.cast(arr), 0, size); } }; } else if (componentType == float.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { float i = buffer.getFloat(); Array.setFloat(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asFloatBuffer().get(float[].class.cast(arr), 0, size); } }; } else if (componentType == long.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { long i = buffer.getLong(); Array.setLong(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asLongBuffer().get(long[].class.cast(arr), 0, size); } }; } else if (componentType == double.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { double i = buffer.getDouble(); Array.setDouble(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asDoubleBuffer().get(double[].class.cast(arr), 0, size); } }; } else if (componentType == byte.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { byte i = buffer.get(); Array.setByte(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.get(byte[].class.cast(arr), 0, size); } }; } Loading @@ -93,13 +88,6 @@ public class MarshalQueryableArray<T> implements MarshalQueryable<T> { } }; static void unmarshalPrimitiveArray(Object arr, int size, ByteBuffer buffer, PrimitiveArrayFiller filler) { for (int i = 0; i < size; i++) { filler.fillPosition(arr, i, buffer); } } private class MarshalerArray extends Marshaler<T> { private final Class<T> mClass; private final Marshaler<?> mComponentMarshaler; Loading Loading @@ -150,8 +138,8 @@ public class MarshalQueryableArray<T> implements MarshalQueryable<T> { array = Array.newInstance(mComponentClass, arraySize); if (isUnwrappedPrimitiveClass(mComponentClass) && mComponentClass == getPrimitiveTypeClass(mNativeType)) { unmarshalPrimitiveArray(array, arraySize, buffer, PrimitiveArrayFiller.getPrimitiveArrayFiller(mComponentClass)); PrimitiveArrayFiller.getPrimitiveArrayFiller(mComponentClass).fillArray(array, arraySize, buffer); } else { for (int i = 0; i < arraySize; ++i) { Object elem = mComponentMarshaler.unmarshal(buffer); Loading core/java/android/window/TransitionInfo.java +8 −1 Original line number Diff line number Diff line Loading @@ -110,8 +110,11 @@ public final class TransitionInfo implements Parcelable { /** The container is an input-method window. */ public static final int FLAG_IS_INPUT_METHOD = 1 << 8; /** The container is ActivityEmbedding embedded. */ public static final int FLAG_IS_EMBEDDED = 1 << 9; /** The first unused bit. This can be used by remotes to attach custom flags to this change. */ public static final int FLAG_FIRST_CUSTOM = 1 << 9; public static final int FLAG_FIRST_CUSTOM = 1 << 10; /** @hide */ @IntDef(prefix = { "FLAG_" }, value = { Loading @@ -125,6 +128,7 @@ public final class TransitionInfo implements Parcelable { FLAG_OCCLUDES_KEYGUARD, FLAG_DISPLAY_HAS_ALERT_WINDOWS, FLAG_IS_INPUT_METHOD, FLAG_IS_EMBEDDED, FLAG_FIRST_CUSTOM }) public @interface ChangeFlags {} Loading Loading @@ -325,6 +329,9 @@ public final class TransitionInfo implements Parcelable { if ((flags & FLAG_DISPLAY_HAS_ALERT_WINDOWS) != 0) { sb.append((sb.length() == 0 ? "" : "|") + "DISPLAY_HAS_ALERT_WINDOWS"); } if ((flags & FLAG_IS_EMBEDDED) != 0) { sb.append((sb.length() == 0 ? "" : "|") + "IS_EMBEDDED"); } if ((flags & FLAG_FIRST_CUSTOM) != 0) { sb.append((sb.length() == 0 ? "" : "|") + "FIRST_CUSTOM"); } Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java +34 −44 Original line number Diff line number Diff line Loading @@ -25,8 +25,7 @@ import static androidx.window.util.ExtensionHelper.transformToWindowSpaceRect; import android.annotation.Nullable; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.AppTask; import android.app.ActivityClient; import android.app.Application; import android.app.WindowConfiguration; import android.content.Context; Loading @@ -34,7 +33,6 @@ import android.graphics.Rect; import android.os.Bundle; import android.os.IBinder; import android.util.ArrayMap; import android.util.Log; import androidx.annotation.NonNull; import androidx.window.common.CommonFoldingFeature; Loading Loading @@ -179,15 +177,11 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { private List<DisplayFeature> getDisplayFeatures( @NonNull Activity activity, List<CommonFoldingFeature> storedFeatures) { List<DisplayFeature> features = new ArrayList<>(); int displayId = activity.getDisplay().getDisplayId(); if (displayId != DEFAULT_DISPLAY) { Log.w(TAG, "This sample doesn't support display features on secondary displays"); return features; } else if (isTaskInMultiWindowMode(activity)) { // It is recommended not to report any display features in multi-window mode, since it // won't be possible to synchronize the display feature positions with window movement. if (!shouldReportDisplayFeatures(activity)) { return features; } else { } int displayId = activity.getDisplay().getDisplayId(); for (CommonFoldingFeature baseFeature : storedFeatures) { Integer state = convertToExtensionState(baseFeature.getState()); if (state == null) { Loading @@ -198,38 +192,34 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { transformToWindowSpaceRect(activity, featureRect); if (!isRectZero(featureRect)) { // TODO(b/228641877) Remove guarding if when fixed. // TODO(b/228641877): Remove guarding when fixed. features.add(new FoldingFeature(featureRect, baseFeature.getType(), state)); } } return features; } } /** * Checks whether the task associated with the activity is in multi-window. If task info is not * available it defaults to {@code true}. * Checks whether display features should be reported for the activity. * TODO(b/238948678): Support reporting display features in all windowing modes. */ private boolean isTaskInMultiWindowMode(@NonNull Activity activity) { final ActivityManager am = activity.getSystemService(ActivityManager.class); if (am == null) { return true; } final List<AppTask> appTasks = am.getAppTasks(); final int taskId = activity.getTaskId(); AppTask task = null; for (AppTask t : appTasks) { if (t.getTaskInfo().taskId == taskId) { task = t; break; } private boolean shouldReportDisplayFeatures(@NonNull Activity activity) { int displayId = activity.getDisplay().getDisplayId(); if (displayId != DEFAULT_DISPLAY) { // Display features are not supported on secondary displays. return false; } if (task == null) { // The task might be removed on the server already. return true; final int taskWindowingMode = ActivityClient.getInstance().getTaskWindowingMode( activity.getActivityToken()); if (taskWindowingMode == -1) { // If we cannot determine the task windowing mode for any reason, it is likely that we // won't be able to determine its position correctly as well. DisplayFeatures' bounds // in this case can't be computed correctly, so we should skip. return false; } return WindowConfiguration.inMultiWindowMode(task.getTaskInfo().getWindowingMode()); // It is recommended not to report any display features in multi-window mode, since it // won't be possible to synchronize the display feature positions with window movement. return !WindowConfiguration.inMultiWindowMode(taskWindowingMode); } /** Loading Loading
core/java/android/app/ActivityClient.java +12 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,18 @@ public class ActivityClient { } } /** * Returns the windowing mode of the task that hosts the activity, or {@code -1} if task is not * found. */ public int getTaskWindowingMode(IBinder activityToken) { try { return getActivityClientController().getTaskWindowingMode(activityToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the non-finishing activity token below in the same task if it belongs to the same * process. Loading
core/java/android/app/IActivityClientController.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ interface IActivityClientController { boolean willActivityBeVisible(in IBinder token); int getDisplayId(in IBinder activityToken); int getTaskForActivity(in IBinder token, in boolean onlyRoot); int getTaskWindowingMode(in IBinder activityToken); IBinder getActivityTokenBelow(IBinder token); ComponentName getCallingActivity(in IBinder token); String getCallingPackage(in IBinder token); Loading
core/java/android/hardware/camera2/marshal/impl/MarshalQueryableArray.java +13 −25 Original line number Diff line number Diff line Loading @@ -45,46 +45,41 @@ public class MarshalQueryableArray<T> implements MarshalQueryable<T> { private static final boolean DEBUG = false; private static interface PrimitiveArrayFiller { public void fillPosition(Object arr, int index, ByteBuffer buffer); public void fillArray(Object arr, int size, ByteBuffer buffer); static PrimitiveArrayFiller getPrimitiveArrayFiller(Class<?> componentType) { if (componentType == int.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { int i = buffer.getInt(); Array.setInt(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asIntBuffer().get(int[].class.cast(arr), 0, size); } }; } else if (componentType == float.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { float i = buffer.getFloat(); Array.setFloat(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asFloatBuffer().get(float[].class.cast(arr), 0, size); } }; } else if (componentType == long.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { long i = buffer.getLong(); Array.setLong(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asLongBuffer().get(long[].class.cast(arr), 0, size); } }; } else if (componentType == double.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { double i = buffer.getDouble(); Array.setDouble(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.asDoubleBuffer().get(double[].class.cast(arr), 0, size); } }; } else if (componentType == byte.class) { return new PrimitiveArrayFiller() { @Override public void fillPosition(Object arr, int index, ByteBuffer buffer) { byte i = buffer.get(); Array.setByte(arr, index, i); public void fillArray(Object arr, int size, ByteBuffer buffer) { buffer.get(byte[].class.cast(arr), 0, size); } }; } Loading @@ -93,13 +88,6 @@ public class MarshalQueryableArray<T> implements MarshalQueryable<T> { } }; static void unmarshalPrimitiveArray(Object arr, int size, ByteBuffer buffer, PrimitiveArrayFiller filler) { for (int i = 0; i < size; i++) { filler.fillPosition(arr, i, buffer); } } private class MarshalerArray extends Marshaler<T> { private final Class<T> mClass; private final Marshaler<?> mComponentMarshaler; Loading Loading @@ -150,8 +138,8 @@ public class MarshalQueryableArray<T> implements MarshalQueryable<T> { array = Array.newInstance(mComponentClass, arraySize); if (isUnwrappedPrimitiveClass(mComponentClass) && mComponentClass == getPrimitiveTypeClass(mNativeType)) { unmarshalPrimitiveArray(array, arraySize, buffer, PrimitiveArrayFiller.getPrimitiveArrayFiller(mComponentClass)); PrimitiveArrayFiller.getPrimitiveArrayFiller(mComponentClass).fillArray(array, arraySize, buffer); } else { for (int i = 0; i < arraySize; ++i) { Object elem = mComponentMarshaler.unmarshal(buffer); Loading
core/java/android/window/TransitionInfo.java +8 −1 Original line number Diff line number Diff line Loading @@ -110,8 +110,11 @@ public final class TransitionInfo implements Parcelable { /** The container is an input-method window. */ public static final int FLAG_IS_INPUT_METHOD = 1 << 8; /** The container is ActivityEmbedding embedded. */ public static final int FLAG_IS_EMBEDDED = 1 << 9; /** The first unused bit. This can be used by remotes to attach custom flags to this change. */ public static final int FLAG_FIRST_CUSTOM = 1 << 9; public static final int FLAG_FIRST_CUSTOM = 1 << 10; /** @hide */ @IntDef(prefix = { "FLAG_" }, value = { Loading @@ -125,6 +128,7 @@ public final class TransitionInfo implements Parcelable { FLAG_OCCLUDES_KEYGUARD, FLAG_DISPLAY_HAS_ALERT_WINDOWS, FLAG_IS_INPUT_METHOD, FLAG_IS_EMBEDDED, FLAG_FIRST_CUSTOM }) public @interface ChangeFlags {} Loading Loading @@ -325,6 +329,9 @@ public final class TransitionInfo implements Parcelable { if ((flags & FLAG_DISPLAY_HAS_ALERT_WINDOWS) != 0) { sb.append((sb.length() == 0 ? "" : "|") + "DISPLAY_HAS_ALERT_WINDOWS"); } if ((flags & FLAG_IS_EMBEDDED) != 0) { sb.append((sb.length() == 0 ? "" : "|") + "IS_EMBEDDED"); } if ((flags & FLAG_FIRST_CUSTOM) != 0) { sb.append((sb.length() == 0 ? "" : "|") + "FIRST_CUSTOM"); } Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java +34 −44 Original line number Diff line number Diff line Loading @@ -25,8 +25,7 @@ import static androidx.window.util.ExtensionHelper.transformToWindowSpaceRect; import android.annotation.Nullable; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.AppTask; import android.app.ActivityClient; import android.app.Application; import android.app.WindowConfiguration; import android.content.Context; Loading @@ -34,7 +33,6 @@ import android.graphics.Rect; import android.os.Bundle; import android.os.IBinder; import android.util.ArrayMap; import android.util.Log; import androidx.annotation.NonNull; import androidx.window.common.CommonFoldingFeature; Loading Loading @@ -179,15 +177,11 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { private List<DisplayFeature> getDisplayFeatures( @NonNull Activity activity, List<CommonFoldingFeature> storedFeatures) { List<DisplayFeature> features = new ArrayList<>(); int displayId = activity.getDisplay().getDisplayId(); if (displayId != DEFAULT_DISPLAY) { Log.w(TAG, "This sample doesn't support display features on secondary displays"); return features; } else if (isTaskInMultiWindowMode(activity)) { // It is recommended not to report any display features in multi-window mode, since it // won't be possible to synchronize the display feature positions with window movement. if (!shouldReportDisplayFeatures(activity)) { return features; } else { } int displayId = activity.getDisplay().getDisplayId(); for (CommonFoldingFeature baseFeature : storedFeatures) { Integer state = convertToExtensionState(baseFeature.getState()); if (state == null) { Loading @@ -198,38 +192,34 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { transformToWindowSpaceRect(activity, featureRect); if (!isRectZero(featureRect)) { // TODO(b/228641877) Remove guarding if when fixed. // TODO(b/228641877): Remove guarding when fixed. features.add(new FoldingFeature(featureRect, baseFeature.getType(), state)); } } return features; } } /** * Checks whether the task associated with the activity is in multi-window. If task info is not * available it defaults to {@code true}. * Checks whether display features should be reported for the activity. * TODO(b/238948678): Support reporting display features in all windowing modes. */ private boolean isTaskInMultiWindowMode(@NonNull Activity activity) { final ActivityManager am = activity.getSystemService(ActivityManager.class); if (am == null) { return true; } final List<AppTask> appTasks = am.getAppTasks(); final int taskId = activity.getTaskId(); AppTask task = null; for (AppTask t : appTasks) { if (t.getTaskInfo().taskId == taskId) { task = t; break; } private boolean shouldReportDisplayFeatures(@NonNull Activity activity) { int displayId = activity.getDisplay().getDisplayId(); if (displayId != DEFAULT_DISPLAY) { // Display features are not supported on secondary displays. return false; } if (task == null) { // The task might be removed on the server already. return true; final int taskWindowingMode = ActivityClient.getInstance().getTaskWindowingMode( activity.getActivityToken()); if (taskWindowingMode == -1) { // If we cannot determine the task windowing mode for any reason, it is likely that we // won't be able to determine its position correctly as well. DisplayFeatures' bounds // in this case can't be computed correctly, so we should skip. return false; } return WindowConfiguration.inMultiWindowMode(task.getTaskInfo().getWindowingMode()); // It is recommended not to report any display features in multi-window mode, since it // won't be possible to synchronize the display feature positions with window movement. return !WindowConfiguration.inMultiWindowMode(taskWindowingMode); } /** Loading