Merge "Always use SizeSpecDefaultImpl on TV" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
eb260e9acc
@@ -21,6 +21,7 @@ import static com.android.wm.shell.pip.PipUtils.dpToPx;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
@@ -366,11 +367,8 @@ public class PipSizeSpecHandler {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mPipDisplayLayoutState = pipDisplayLayoutState;
|
mPipDisplayLayoutState = pipDisplayLayoutState;
|
||||||
|
|
||||||
boolean enablePipSizeLargeScreen = SystemProperties
|
|
||||||
.getBoolean("persist.wm.debug.enable_pip_size_large_screen", true);
|
|
||||||
|
|
||||||
// choose between two implementations of size spec logic
|
// choose between two implementations of size spec logic
|
||||||
if (enablePipSizeLargeScreen) {
|
if (supportsPipSizeLargeScreen()) {
|
||||||
mSizeSpecSourceImpl = new SizeSpecLargeScreenOptimizedImpl();
|
mSizeSpecSourceImpl = new SizeSpecLargeScreenOptimizedImpl();
|
||||||
} else {
|
} else {
|
||||||
mSizeSpecSourceImpl = new SizeSpecDefaultImpl();
|
mSizeSpecSourceImpl = new SizeSpecDefaultImpl();
|
||||||
@@ -515,6 +513,18 @@ public class PipSizeSpecHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean supportsPipSizeLargeScreen() {
|
||||||
|
// TODO(b/271468706): switch Tv to having a dedicated SizeSpecSource once the SizeSpecSource
|
||||||
|
// can be injected
|
||||||
|
return SystemProperties
|
||||||
|
.getBoolean("persist.wm.debug.enable_pip_size_large_screen", true) && !isTv();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTv() {
|
||||||
|
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);
|
||||||
|
}
|
||||||
|
|
||||||
/** Dumps internal state. */
|
/** Dumps internal state. */
|
||||||
public void dump(PrintWriter pw, String prefix) {
|
public void dump(PrintWriter pw, String prefix) {
|
||||||
final String innerPrefix = prefix + " ";
|
final String innerPrefix = prefix + " ";
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.wm.shell.pip.phone;
|
|||||||
|
|
||||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
|
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -76,7 +75,7 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
|
|||||||
@Mock private Resources mResources;
|
@Mock private Resources mResources;
|
||||||
|
|
||||||
private PipDisplayLayoutState mPipDisplayLayoutState;
|
private PipDisplayLayoutState mPipDisplayLayoutState;
|
||||||
private PipSizeSpecHandler mPipSizeSpecHandler;
|
private TestPipSizeSpecHandler mPipSizeSpecHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up static Mockito session for SystemProperties and mocks necessary static methods.
|
* Sets up static Mockito session for SystemProperties and mocks necessary static methods.
|
||||||
@@ -84,8 +83,6 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
|
|||||||
private static void setUpStaticSystemPropertiesSession() {
|
private static void setUpStaticSystemPropertiesSession() {
|
||||||
sStaticMockitoSession = mockitoSession()
|
sStaticMockitoSession = mockitoSession()
|
||||||
.mockStatic(SystemProperties.class).startMocking();
|
.mockStatic(SystemProperties.class).startMocking();
|
||||||
// make sure the feature flag is on
|
|
||||||
when(SystemProperties.getBoolean(anyString(), anyBoolean())).thenReturn(true);
|
|
||||||
when(SystemProperties.get(anyString(), anyString())).thenAnswer(invocation -> {
|
when(SystemProperties.get(anyString(), anyString())).thenAnswer(invocation -> {
|
||||||
String property = invocation.getArgument(0);
|
String property = invocation.getArgument(0);
|
||||||
if (property.equals("com.android.wm.shell.pip.phone.def_percentage")) {
|
if (property.equals("com.android.wm.shell.pip.phone.def_percentage")) {
|
||||||
@@ -161,7 +158,7 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
|
|||||||
mPipDisplayLayoutState.setDisplayLayout(displayLayout);
|
mPipDisplayLayoutState.setDisplayLayout(displayLayout);
|
||||||
|
|
||||||
setUpStaticSystemPropertiesSession();
|
setUpStaticSystemPropertiesSession();
|
||||||
mPipSizeSpecHandler = new PipSizeSpecHandler(mContext, mPipDisplayLayoutState);
|
mPipSizeSpecHandler = new TestPipSizeSpecHandler(mContext, mPipDisplayLayoutState);
|
||||||
|
|
||||||
// no overridden min edge size by default
|
// no overridden min edge size by default
|
||||||
mPipSizeSpecHandler.setOverrideMinSize(null);
|
mPipSizeSpecHandler.setOverrideMinSize(null);
|
||||||
@@ -214,4 +211,16 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
|
|||||||
|
|
||||||
Assert.assertEquals(expectedSize, actualSize);
|
Assert.assertEquals(expectedSize, actualSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class TestPipSizeSpecHandler extends PipSizeSpecHandler {
|
||||||
|
|
||||||
|
TestPipSizeSpecHandler(Context context, PipDisplayLayoutState displayLayoutState) {
|
||||||
|
super(context, displayLayoutState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean supportsPipSizeLargeScreen() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user