Merge "Cache Device Motion Prediction Availability" into udc-dev
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 9610f2c..81a3479 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -65,6 +65,15 @@
]
},
{
+ "name": "FrameworksInputMethodSystemServerTests",
+ "options": [
+ {"include-filter": "com.android.server.inputmethod"},
+ {"exclude-annotation": "android.platform.test.annotations.FlakyTest"},
+ {"exclude-annotation": "androidx.test.filters.FlakyTest"},
+ {"exclude-annotation": "org.junit.Ignore"}
+ ]
+ },
+ {
"name": "ExtServicesUnitTests",
"options": [
{
diff --git a/core/java/android/view/HandwritingInitiator.java b/core/java/android/view/HandwritingInitiator.java
index d38ef1f..a47783c 100644
--- a/core/java/android/view/HandwritingInitiator.java
+++ b/core/java/android/view/HandwritingInitiator.java
@@ -170,6 +170,9 @@
findBestCandidateView(mState.mStylusDownX, mState.mStylusDownY);
if (candidateView != null) {
if (candidateView == getConnectedView()) {
+ if (!candidateView.hasFocus()) {
+ requestFocusWithoutReveal(candidateView);
+ }
startHandwriting(candidateView);
} else if (candidateView.getHandwritingDelegatorCallback() != null) {
String delegatePackageName =
@@ -181,13 +184,7 @@
candidateView, delegatePackageName);
candidateView.getHandwritingDelegatorCallback().run();
} else {
- if (candidateView.getRevealOnFocusHint()) {
- candidateView.setRevealOnFocusHint(false);
- candidateView.requestFocus();
- candidateView.setRevealOnFocusHint(true);
- } else {
- candidateView.requestFocus();
- }
+ requestFocusWithoutReveal(candidateView);
}
}
}
@@ -380,6 +377,16 @@
return false;
}
+ private static void requestFocusWithoutReveal(View view) {
+ if (view.getRevealOnFocusHint()) {
+ view.setRevealOnFocusHint(false);
+ view.requestFocus();
+ view.setRevealOnFocusHint(true);
+ } else {
+ view.requestFocus();
+ }
+ }
+
/**
* Given the location of the stylus event, return the best candidate view to initialize
* handwriting mode.
diff --git a/core/tests/coretests/src/android/view/stylus/HandwritingInitiatorTest.java b/core/tests/coretests/src/android/view/stylus/HandwritingInitiatorTest.java
index a3dec84..1ec2613 100644
--- a/core/tests/coretests/src/android/view/stylus/HandwritingInitiatorTest.java
+++ b/core/tests/coretests/src/android/view/stylus/HandwritingInitiatorTest.java
@@ -337,6 +337,27 @@
}
@Test
+ public void onTouchEvent_focusView_inputConnectionAlreadyBuilt_stylusMoveOnce_withinHWArea() {
+ mHandwritingInitiator.onInputConnectionCreated(mTestView1);
+
+ final int x1 = (sHwArea1.left + sHwArea1.right) / 2;
+ final int y1 = (sHwArea1.top + sHwArea1.bottom) / 2;
+ MotionEvent stylusEvent1 = createStylusEvent(ACTION_DOWN, x1, y1, 0);
+ mHandwritingInitiator.onTouchEvent(stylusEvent1);
+
+ final int x2 = x1 + mHandwritingSlop * 2;
+ final int y2 = y1;
+
+ MotionEvent stylusEvent2 = createStylusEvent(ACTION_MOVE, x2, y2, 0);
+ mHandwritingInitiator.onTouchEvent(stylusEvent2);
+
+ // View has input connection but not focus, so HandwritingInitiator will request focus
+ // before starting handwriting.
+ verify(mTestView1).requestFocus();
+ verify(mHandwritingInitiator).startHandwriting(mTestView1);
+ }
+
+ @Test
public void onTouchEvent_focusView_stylusMoveOnce_withinExtendedHWArea() {
final int x1 = sHwArea1.left - HW_BOUNDS_OFFSETS_LEFT_PX / 2;
final int y1 = sHwArea1.top - HW_BOUNDS_OFFSETS_TOP_PX / 2;
diff --git a/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt
index 738b37c..2d47356 100644
--- a/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt
+++ b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt
@@ -39,14 +39,14 @@
import platform.test.screenshot.matchers.BitmapMatcher
/** A rule for View screenshot diff unit tests. */
-class ViewScreenshotTestRule(
+open class ViewScreenshotTestRule(
emulationSpec: DeviceEmulationSpec,
private val matcher: BitmapMatcher = UnitTestBitmapMatcher,
assetsPathRelativeToBuildRoot: String
) : TestRule {
private val colorsRule = MaterialYouColorsRule()
private val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
- private val screenshotRule =
+ protected val screenshotRule =
ScreenshotTestRule(
SystemUIGoldenImagePathManager(
getEmulatedDevicePathConfig(emulationSpec),
@@ -64,15 +64,10 @@
return delegateRule.apply(base, description)
}
- /**
- * Compare the content of the view provided by [viewProvider] with the golden image identified
- * by [goldenIdentifier] in the context of [emulationSpec].
- */
- fun screenshotTest(
- goldenIdentifier: String,
+ protected fun takeScreenshot(
mode: Mode = Mode.WrapContent,
viewProvider: (ComponentActivity) -> View,
- ) {
+ ): Bitmap {
activityRule.scenario.onActivity { activity ->
// Make sure that the activity draws full screen and fits the whole display instead of
// the system bars.
@@ -99,7 +94,19 @@
contentView = content.getChildAt(0)
}
- val bitmap = contentView?.toBitmap() ?: error("contentView is null")
+ return contentView?.toBitmap() ?: error("contentView is null")
+ }
+
+ /**
+ * Compare the content of the view provided by [viewProvider] with the golden image identified
+ * by [goldenIdentifier] in the context of [emulationSpec].
+ */
+ fun screenshotTest(
+ goldenIdentifier: String,
+ mode: Mode = Mode.WrapContent,
+ viewProvider: (ComponentActivity) -> View,
+ ) {
+ val bitmap = takeScreenshot(mode, viewProvider)
screenshotRule.assertBitmapAgainstGolden(
bitmap,
goldenIdentifier,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModel.kt
index 1057231..4b24e7a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModel.kt
@@ -124,7 +124,8 @@
isDefault -> icon
wifiConstants.alwaysShowIconIfEnabled -> icon
!connectivityConstants.hasDataCapabilities -> icon
- wifiNetwork is WifiNetworkModel.Active && wifiNetwork.isValidated -> icon
+ // See b/272509965: Even if we have an active and validated wifi network, we
+ // don't want to show the icon if wifi isn't the default network.
else -> WifiIcon.Hidden
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt
index ae227b4..d9d4013 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt
@@ -21,6 +21,7 @@
import android.util.Log.TerribleFailure
import android.util.Log.TerribleFailureHandler
import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.FlakyTest
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.Interpolators
@@ -47,6 +48,7 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
+@FlakyTest(bugId = 270760395)
class KeyguardTransitionRepositoryTest : SysuiTestCase() {
private lateinit var underTest: KeyguardTransitionRepository
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt
index 12b1664..1c71f8b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt
@@ -368,40 +368,37 @@
// network = CarrierMerged => not shown
TestCase(
+ enabled = true,
+ isDefault = true,
+ forceHidden = false,
network =
WifiNetworkModel.CarrierMerged(NETWORK_ID, subscriptionId = 1, level = 1),
expected = null,
),
- // network = Inactive => not shown
+ // isDefault = false => no networks shown
TestCase(
+ isDefault = false,
network = WifiNetworkModel.Inactive,
expected = null,
),
-
- // network = Unavailable => not shown
TestCase(
+ isDefault = false,
network = WifiNetworkModel.Unavailable,
expected = null,
),
-
- // network = Active & validated = false => not shown
TestCase(
+ isDefault = false,
network = WifiNetworkModel.Active(NETWORK_ID, isValidated = false, level = 3),
expected = null,
),
- // network = Active & validated = true => shown
+ // Even though this network is active and validated, we still doesn't want it shown
+ // because wifi isn't the default connection (b/272509965).
TestCase(
+ isDefault = false,
network = WifiNetworkModel.Active(NETWORK_ID, isValidated = true, level = 4),
- expected =
- Expected(
- iconResource = WIFI_FULL_ICONS[4],
- contentDescription = { context ->
- context.getString(WIFI_CONNECTION_STRENGTH[4])
- },
- description = "Full internet level 4 icon",
- ),
+ expected = null,
),
)
}
diff --git a/services/core/java/com/android/server/locales/AppLocaleChangedAtomRecord.java b/services/core/java/com/android/server/locales/AppLocaleChangedAtomRecord.java
index 282e3c1..2be2ef8 100644
--- a/services/core/java/com/android/server/locales/AppLocaleChangedAtomRecord.java
+++ b/services/core/java/com/android/server/locales/AppLocaleChangedAtomRecord.java
@@ -30,7 +30,8 @@
String mPrevLocales = "";
int mStatus = FrameworkStatsLog
.APPLICATION_LOCALES_CHANGED__STATUS__STATUS_UNSPECIFIED;
-
+ int mCaller = FrameworkStatsLog
+ .APPLICATION_LOCALES_CHANGED__CALLER__CALLER_UNKNOWN;
AppLocaleChangedAtomRecord(int callingUid) {
this.mCallingUid = callingUid;
}
@@ -50,4 +51,8 @@
void setStatus(int status) {
this.mStatus = status;
}
+
+ void setCaller(int caller) {
+ this.mCaller = caller;
+ }
}
diff --git a/services/core/java/com/android/server/locales/LocaleManagerService.java b/services/core/java/com/android/server/locales/LocaleManagerService.java
index 48d06ca..e3a555b 100644
--- a/services/core/java/com/android/server/locales/LocaleManagerService.java
+++ b/services/core/java/com/android/server/locales/LocaleManagerService.java
@@ -551,7 +551,8 @@
atomRecordForMetrics.mTargetUid,
atomRecordForMetrics.mNewLocales,
atomRecordForMetrics.mPrevLocales,
- atomRecordForMetrics.mStatus);
+ atomRecordForMetrics.mStatus,
+ atomRecordForMetrics.mCaller);
}
/**
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt
index c23cf34..d72f528 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTest.kt
@@ -37,7 +37,7 @@
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-class CloseImeOnDismissPopupDialogTest(flicker: FlickerTest) : BaseTest(flicker) {
+open class CloseImeOnDismissPopupDialogTest(flicker: FlickerTest) : BaseTest(flicker) {
private val imeTestApp = ImeEditorPopupDialogAppHelper(instrumentation)
/** {@inheritDoc} */
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTestCfArm.kt
new file mode 100644
index 0000000..432df20
--- /dev/null
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeOnDismissPopupDialogTestCfArm.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 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 com.android.server.wm.flicker.ime
+
+import android.tools.common.Rotation
+import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
+import android.tools.device.flicker.legacy.FlickerTest
+import android.tools.device.flicker.legacy.FlickerTestFactory
+import org.junit.FixMethodOrder
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.junit.runners.Parameterized
+
+@RunWith(Parameterized::class)
+@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class CloseImeOnDismissPopupDialogTestCfArm(flicker: FlickerTest) :
+ CloseImeOnDismissPopupDialogTest(flicker) {
+ companion object {
+ @Parameterized.Parameters(name = "{0}")
+ @JvmStatic
+ fun getParams(): Collection<FlickerTest> {
+ return FlickerTestFactory.nonRotationTests(
+ supportedRotations = listOf(Rotation.ROTATION_0)
+ )
+ }
+ }
+}
\ No newline at end of file