Check app targetSdkVersion when check minWidth/Height for multi window
Bug: 197654537 Test: manually with app target S- with large min width/height Change-Id: I2dd0902cb255cbe111ebab86dbf59be1a32e0cfc
This commit is contained in:
@@ -22,6 +22,7 @@ import android.app.Activity;
|
||||
import android.app.compat.CompatChanges;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.Disabled;
|
||||
import android.compat.annotation.EnabledSince;
|
||||
import android.compat.annotation.Overridable;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.ComponentName;
|
||||
@@ -1040,6 +1041,14 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
|
||||
@TestApi
|
||||
public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 16 / 9f;
|
||||
|
||||
/**
|
||||
* Compares activity window layout min width/height with require space for multi window to
|
||||
* determine if it can be put into multi window mode.
|
||||
*/
|
||||
@ChangeId
|
||||
@EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
|
||||
private static final long CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW = 197654537L;
|
||||
|
||||
/**
|
||||
* Convert Java change bits to native.
|
||||
*
|
||||
@@ -1480,6 +1489,17 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we should compare activity window layout min width/height with require space for
|
||||
* multi window to determine if it can be put into multi window mode.
|
||||
* @hide
|
||||
*/
|
||||
public boolean shouldCheckMinWidthHeightForMultiWindow() {
|
||||
return CompatChanges.isChangeEnabled(CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW,
|
||||
applicationInfo.packageName,
|
||||
UserHandle.getUserHandleForUid(applicationInfo.uid));
|
||||
}
|
||||
|
||||
public void dump(Printer pw, String prefix) {
|
||||
dump(pw, prefix, DUMP_FLAG_ALL);
|
||||
}
|
||||
|
||||
@@ -2801,7 +2801,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
final ActivityInfo.WindowLayout windowLayout = info.windowLayout;
|
||||
return windowLayout == null
|
||||
|| tda.supportsActivityMinWidthHeightMultiWindow(windowLayout.minWidth,
|
||||
windowLayout.minHeight);
|
||||
windowLayout.minHeight, info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,7 @@ import android.annotation.ColorInt;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.WindowConfiguration;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.UserHandle;
|
||||
import android.util.IntArray;
|
||||
@@ -1704,13 +1705,17 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
|
||||
* Whether we can show activity requesting the given min width/height in multi window below
|
||||
* this {@link TaskDisplayArea}.
|
||||
*/
|
||||
boolean supportsActivityMinWidthHeightMultiWindow(int minWidth, int minHeight) {
|
||||
final int configRespectsActivityMinWidthHeightMultiWindow =
|
||||
mAtmService.mRespectsActivityMinWidthHeightMultiWindow;
|
||||
boolean supportsActivityMinWidthHeightMultiWindow(int minWidth, int minHeight,
|
||||
@Nullable ActivityInfo activityInfo) {
|
||||
if (activityInfo != null && !activityInfo.shouldCheckMinWidthHeightForMultiWindow()) {
|
||||
return true;
|
||||
}
|
||||
if (minWidth <= 0 && minHeight <= 0) {
|
||||
// No request min width/height.
|
||||
return true;
|
||||
}
|
||||
final int configRespectsActivityMinWidthHeightMultiWindow =
|
||||
mAtmService.mRespectsActivityMinWidthHeightMultiWindow;
|
||||
if (configRespectsActivityMinWidthHeightMultiWindow == -1) {
|
||||
// Device override to ignore min width/height.
|
||||
return true;
|
||||
|
||||
@@ -1758,7 +1758,9 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tda.supportsActivityMinWidthHeightMultiWindow(mMinWidth, mMinHeight);
|
||||
final ActivityRecord rootActivity = getTask().getRootActivity();
|
||||
return tda.supportsActivityMinWidthHeightMultiWindow(mMinWidth, mMinHeight,
|
||||
rootActivity != null ? rootActivity.info : null);
|
||||
}
|
||||
|
||||
private int getTaskId() {
|
||||
|
||||
Reference in New Issue
Block a user