Merge "Don't report non-foldables as unfolded." into tm-qpr-dev
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.classifier;
|
package com.android.systemui.classifier;
|
||||||
|
|
||||||
|
import static com.android.systemui.classifier.FalsingModule.IS_FOLDABLE_DEVICE;
|
||||||
|
|
||||||
import android.hardware.devicestate.DeviceStateManager.FoldStateListener;
|
import android.hardware.devicestate.DeviceStateManager.FoldStateListener;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -30,6 +32,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acts as a cache and utility class for FalsingClassifiers.
|
* Acts as a cache and utility class for FalsingClassifiers.
|
||||||
@@ -46,6 +49,7 @@ public class FalsingDataProvider {
|
|||||||
private BatteryController mBatteryController;
|
private BatteryController mBatteryController;
|
||||||
private final FoldStateListener mFoldStateListener;
|
private final FoldStateListener mFoldStateListener;
|
||||||
private final DockManager mDockManager;
|
private final DockManager mDockManager;
|
||||||
|
private boolean mIsFoldableDevice;
|
||||||
private final float mXdpi;
|
private final float mXdpi;
|
||||||
private final float mYdpi;
|
private final float mYdpi;
|
||||||
private final List<SessionListener> mSessionListeners = new ArrayList<>();
|
private final List<SessionListener> mSessionListeners = new ArrayList<>();
|
||||||
@@ -70,7 +74,8 @@ public class FalsingDataProvider {
|
|||||||
DisplayMetrics displayMetrics,
|
DisplayMetrics displayMetrics,
|
||||||
BatteryController batteryController,
|
BatteryController batteryController,
|
||||||
FoldStateListener foldStateListener,
|
FoldStateListener foldStateListener,
|
||||||
DockManager dockManager) {
|
DockManager dockManager,
|
||||||
|
@Named(IS_FOLDABLE_DEVICE) boolean isFoldableDevice) {
|
||||||
mXdpi = displayMetrics.xdpi;
|
mXdpi = displayMetrics.xdpi;
|
||||||
mYdpi = displayMetrics.ydpi;
|
mYdpi = displayMetrics.ydpi;
|
||||||
mWidthPixels = displayMetrics.widthPixels;
|
mWidthPixels = displayMetrics.widthPixels;
|
||||||
@@ -78,6 +83,7 @@ public class FalsingDataProvider {
|
|||||||
mBatteryController = batteryController;
|
mBatteryController = batteryController;
|
||||||
mFoldStateListener = foldStateListener;
|
mFoldStateListener = foldStateListener;
|
||||||
mDockManager = dockManager;
|
mDockManager = dockManager;
|
||||||
|
mIsFoldableDevice = isFoldableDevice;
|
||||||
|
|
||||||
FalsingClassifier.logInfo("xdpi, ydpi: " + getXdpi() + ", " + getYdpi());
|
FalsingClassifier.logInfo("xdpi, ydpi: " + getXdpi() + ", " + getYdpi());
|
||||||
FalsingClassifier.logInfo("width, height: " + getWidthPixels() + ", " + getHeightPixels());
|
FalsingClassifier.logInfo("width, height: " + getWidthPixels() + ", " + getHeightPixels());
|
||||||
@@ -417,7 +423,7 @@ public class FalsingDataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnfolded() {
|
public boolean isUnfolded() {
|
||||||
return Boolean.FALSE.equals(mFoldStateListener.getFolded());
|
return mIsFoldableDevice && Boolean.FALSE.equals(mFoldStateListener.getFolded());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Implement to be alerted abotu the beginning and ending of falsing tracking. */
|
/** Implement to be alerted abotu the beginning and ending of falsing tracking. */
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public interface FalsingModule {
|
|||||||
String LONG_TAP_TOUCH_SLOP = "falsing_long_tap_slop";
|
String LONG_TAP_TOUCH_SLOP = "falsing_long_tap_slop";
|
||||||
String DOUBLE_TAP_TOUCH_SLOP = "falsing_double_tap_touch_slop";
|
String DOUBLE_TAP_TOUCH_SLOP = "falsing_double_tap_touch_slop";
|
||||||
String DOUBLE_TAP_TIMEOUT_MS = "falsing_double_tap_timeout_ms";
|
String DOUBLE_TAP_TIMEOUT_MS = "falsing_double_tap_timeout_ms";
|
||||||
|
String IS_FOLDABLE_DEVICE = "falsing_foldable_device";
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@Binds
|
@Binds
|
||||||
@@ -89,4 +90,16 @@ public interface FalsingModule {
|
|||||||
static float providesLongTapTouchSlop(ViewConfiguration viewConfiguration) {
|
static float providesLongTapTouchSlop(ViewConfiguration viewConfiguration) {
|
||||||
return viewConfiguration.getScaledTouchSlop() * 1.25f;
|
return viewConfiguration.getScaledTouchSlop() * 1.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
@Provides
|
||||||
|
@Named(IS_FOLDABLE_DEVICE)
|
||||||
|
static boolean providesIsFoldableDevice(@Main Resources resources) {
|
||||||
|
try {
|
||||||
|
return resources.getIntArray(
|
||||||
|
com.android.internal.R.array.config_foldedDeviceStates).length != 0;
|
||||||
|
} catch (Resources.NotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class ClassifierTest extends SysuiTestCase {
|
|||||||
displayMetrics.widthPixels = 1000;
|
displayMetrics.widthPixels = 1000;
|
||||||
displayMetrics.heightPixels = 1000;
|
displayMetrics.heightPixels = 1000;
|
||||||
mDataProvider = new FalsingDataProvider(
|
mDataProvider = new FalsingDataProvider(
|
||||||
displayMetrics, mBatteryController, mFoldStateListener, mDockManager);
|
displayMetrics, mBatteryController, mFoldStateListener, mDockManager, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|||||||
@@ -54,18 +54,18 @@ public class FalsingDataProviderTest extends ClassifierTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private FoldStateListener mFoldStateListener;
|
private FoldStateListener mFoldStateListener;
|
||||||
private final DockManagerFake mDockManager = new DockManagerFake();
|
private final DockManagerFake mDockManager = new DockManagerFake();
|
||||||
|
private DisplayMetrics mDisplayMetrics;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
super.setup();
|
super.setup();
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
mDisplayMetrics = new DisplayMetrics();
|
||||||
displayMetrics.xdpi = 100;
|
mDisplayMetrics.xdpi = 100;
|
||||||
displayMetrics.ydpi = 100;
|
mDisplayMetrics.ydpi = 100;
|
||||||
displayMetrics.widthPixels = 1000;
|
mDisplayMetrics.widthPixels = 1000;
|
||||||
displayMetrics.heightPixels = 1000;
|
mDisplayMetrics.heightPixels = 1000;
|
||||||
mDataProvider = new FalsingDataProvider(
|
mDataProvider = createWithFoldCapability(false);
|
||||||
displayMetrics, mBatteryController, mFoldStateListener, mDockManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -345,20 +345,42 @@ public class FalsingDataProviderTest extends ClassifierTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_FoldedState_Folded() {
|
public void test_UnfoldedState_Folded() {
|
||||||
|
FalsingDataProvider falsingDataProvider = createWithFoldCapability(true);
|
||||||
when(mFoldStateListener.getFolded()).thenReturn(true);
|
when(mFoldStateListener.getFolded()).thenReturn(true);
|
||||||
assertThat(mDataProvider.isUnfolded()).isFalse();
|
assertThat(falsingDataProvider.isUnfolded()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_FoldedState_Unfolded() {
|
public void test_UnfoldedState_Unfolded() {
|
||||||
|
FalsingDataProvider falsingDataProvider = createWithFoldCapability(true);
|
||||||
when(mFoldStateListener.getFolded()).thenReturn(false);
|
when(mFoldStateListener.getFolded()).thenReturn(false);
|
||||||
assertThat(mDataProvider.isUnfolded()).isTrue();
|
assertThat(falsingDataProvider.isUnfolded()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_FoldedState_NotFoldable() {
|
public void test_Nonfoldabled_TrueFoldState() {
|
||||||
|
FalsingDataProvider falsingDataProvider = createWithFoldCapability(false);
|
||||||
|
when(mFoldStateListener.getFolded()).thenReturn(true);
|
||||||
|
assertThat(falsingDataProvider.isUnfolded()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_Nonfoldabled_FalseFoldState() {
|
||||||
|
FalsingDataProvider falsingDataProvider = createWithFoldCapability(false);
|
||||||
|
when(mFoldStateListener.getFolded()).thenReturn(false);
|
||||||
|
assertThat(falsingDataProvider.isUnfolded()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_Nonfoldabled_NullFoldState() {
|
||||||
|
FalsingDataProvider falsingDataProvider = createWithFoldCapability(true);
|
||||||
when(mFoldStateListener.getFolded()).thenReturn(null);
|
when(mFoldStateListener.getFolded()).thenReturn(null);
|
||||||
assertThat(mDataProvider.isUnfolded()).isFalse();
|
assertThat(falsingDataProvider.isUnfolded()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private FalsingDataProvider createWithFoldCapability(boolean foldable) {
|
||||||
|
return new FalsingDataProvider(
|
||||||
|
mDisplayMetrics, mBatteryController, mFoldStateListener, mDockManager, foldable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user