mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 18:28:20 +00:00
Merge changes from topic "running-in-test-camel" into tm-qpr-dev
* changes: Expose IS_RUNNING_IN_TEST_HARNESS as static method. Make isTooltipEnabled a getter due to its mutable dependencies.
This commit is contained in:
committed by
Android (Google) Code Review
commit
d2d2913812
@@ -118,7 +118,7 @@ public class AppEventProducer implements StatsLogConsumer {
|
||||
private void sendEvent(AppTarget target, LauncherAtom.ItemInfo locationInfo, int eventId,
|
||||
int targetPredictor) {
|
||||
// TODO: remove the running test check when b/231648228 is fixed.
|
||||
if (target != null && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (target != null && !Utilities.isRunningInTestHarness()) {
|
||||
AppTargetEvent event = new AppTargetEvent.Builder(target, eventId)
|
||||
.setLaunchLocation(getContainer(locationInfo))
|
||||
.build();
|
||||
|
||||
@@ -280,7 +280,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
* Returns {@code true} if a Taskbar education should be shown on application launch.
|
||||
*/
|
||||
public boolean shouldShowEduOnAppLaunch() {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
|
||||
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
|
||||
import static com.android.launcher3.Utilities.IS_RUNNING_IN_TEST_HARNESS;
|
||||
import static com.android.launcher3.Utilities.isRunningInTestHarness;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
|
||||
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING;
|
||||
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN;
|
||||
@@ -337,8 +337,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
int windowFlags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
| WindowManager.LayoutParams.FLAG_SLIPPERY
|
||||
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
|
||||
if (DisplayController.isTransientTaskbar(this)
|
||||
&& !IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (DisplayController.isTransientTaskbar(this) && !isRunningInTestHarness()) {
|
||||
windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.airbnb.lottie.LottieProperty.COLOR_FILTER
|
||||
import com.airbnb.lottie.model.KeyPath
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.Utilities.IS_RUNNING_IN_TEST_HARNESS
|
||||
import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_EDU_TOOLTIP
|
||||
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_EDU_OPEN
|
||||
import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController
|
||||
@@ -56,7 +55,8 @@ annotation class TaskbarEduTooltipStep
|
||||
class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
|
||||
LoggableTaskbarController {
|
||||
|
||||
private val isTooltipEnabled = !IS_RUNNING_IN_TEST_HARNESS && ENABLE_TASKBAR_EDU_TOOLTIP.get()
|
||||
private val isTooltipEnabled: Boolean
|
||||
get() = !Utilities.isRunningInTestHarness() && ENABLE_TASKBAR_EDU_TOOLTIP.get()
|
||||
private val isOpen: Boolean
|
||||
get() = tooltip?.isOpen ?: false
|
||||
|
||||
|
||||
@@ -460,7 +460,7 @@ import java.util.StringJoiner;
|
||||
updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0);
|
||||
|
||||
// Sync the first frame where we swap taskbar and hotseat.
|
||||
if (firstFrameVisChanged && mCanSyncViews && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (firstFrameVisChanged && mCanSyncViews && !Utilities.isRunningInTestHarness()) {
|
||||
ViewRootSync.synchronizeNextDraw(mLauncher.getHotseat(),
|
||||
mControllers.taskbarActivityContext.getDragLayer(),
|
||||
() -> {});
|
||||
|
||||
@@ -297,7 +297,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
}
|
||||
return supportsVisualStashing()
|
||||
&& isInApp()
|
||||
&& (!Utilities.IS_RUNNING_IN_TEST_HARNESS || mEnableManualStashingDuringTests)
|
||||
&& (!Utilities.isRunningInTestHarness() || mEnableManualStashingDuringTests)
|
||||
&& !DisplayController.isTransientTaskbar(mActivity);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public final class RecentsViewStateController extends
|
||||
builder.addOnFrameCallback(() -> mRecentsView.loadVisibleTaskData(FLAG_UPDATE_ALL));
|
||||
mRecentsView.updateEmptyMessage();
|
||||
// TODO(b/246283207): Remove logging once root cause of flake detected.
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
Log.d("b/246283207", "RecentsView#setStateWithAnimationInternal getCurrentPage(): "
|
||||
+ mRecentsView.getCurrentPage()
|
||||
+ ", getScrollForPage(getCurrentPage())): "
|
||||
|
||||
@@ -139,7 +139,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
if (IS_VERBOSE) {
|
||||
Log.d(TAG, String.format("\nwriteSnapshot(%d):\n%s", instanceId.getId(), info));
|
||||
}
|
||||
if (!Utilities.ATLEAST_R || Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (!Utilities.ATLEAST_R || Utilities.isRunningInTestHarness()) {
|
||||
return;
|
||||
}
|
||||
SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_SNAPSHOT,
|
||||
@@ -438,7 +438,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
// TODO: remove this when b/231648228 is fixed.
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
return;
|
||||
}
|
||||
int cardinality = mCardinality.orElseGet(() -> getCardinality(atomInfo));
|
||||
@@ -636,7 +636,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
private static int getCardinality(LauncherAtom.ItemInfo info) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
return 0;
|
||||
}
|
||||
switch (info.getContainerInfo().getContainerCase()) {
|
||||
@@ -758,7 +758,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
private static int getHierarchy(LauncherAtom.ItemInfo info) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
return 0;
|
||||
}
|
||||
if (info.getContainerInfo().getContainerCase() == FOLDER) {
|
||||
@@ -801,7 +801,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
private static int getSearchAttributes(LauncherAtom.ItemInfo info) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
return 0;
|
||||
}
|
||||
ContainerInfo containerInfo = info.getContainerInfo();
|
||||
|
||||
@@ -129,7 +129,7 @@ public class MotionPauseDetector {
|
||||
* @param pointerIndex Index for the pointer being tracked in the motion event
|
||||
*/
|
||||
public void addPosition(MotionEvent ev, int pointerIndex) {
|
||||
long timeoutMs = Utilities.IS_RUNNING_IN_TEST_HARNESS
|
||||
long timeoutMs = Utilities.isRunningInTestHarness()
|
||||
? TEST_HARNESS_TRIGGER_TIMEOUT
|
||||
: mMakePauseHarderToTrigger
|
||||
? HARDER_TRIGGER_TIMEOUT
|
||||
@@ -195,7 +195,7 @@ public class MotionPauseDetector {
|
||||
if (mIsPaused != isPaused) {
|
||||
mIsPaused = isPaused;
|
||||
String logString = "onMotionPauseChanged, paused=" + mIsPaused + " reason=" + reason;
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
Log.d(TAG, logString);
|
||||
}
|
||||
ActiveGestureLog.INSTANCE.addLog(logString);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class QuickstepOnboardingPrefs extends OnboardingPrefs<QuickstepLauncher>
|
||||
});
|
||||
}
|
||||
|
||||
if (!Utilities.IS_RUNNING_IN_TEST_HARNESS
|
||||
if (!Utilities.isRunningInTestHarness()
|
||||
&& !hasReachedMaxCount(HOTSEAT_DISCOVERY_TIP_COUNT)) {
|
||||
stateManager.addStateListener(new StateListener<LauncherState>() {
|
||||
boolean mFromAllApps = false;
|
||||
|
||||
@@ -1718,7 +1718,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
int finalTargetPage = targetPage;
|
||||
runOnPageScrollsInitialized(() -> {
|
||||
// TODO(b/246283207): Remove logging once root cause of flake detected.
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
Log.d("b/246283207", "RecentsView#applyLoadPlan() -> "
|
||||
+ "previousCurrentPage: " + previousCurrentPage
|
||||
+ ", targetPage: " + finalTargetPage
|
||||
|
||||
@@ -827,6 +827,6 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
private boolean hasSeenReconfigurableWidgetEducationTip() {
|
||||
return mLauncher.getSharedPrefs()
|
||||
.getBoolean(KEY_RECONFIGURABLE_WIDGET_EDUCATION_TIP_SEEN, false)
|
||||
|| Utilities.IS_RUNNING_IN_TEST_HARNESS;
|
||||
|| Utilities.isRunningInTestHarness();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,7 +1647,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
Log.d(TestProtocol.PERMANENT_DIAG_TAG, "Launcher.onNewIntent: " + intent);
|
||||
}
|
||||
Object traceToken = TraceHelper.INSTANCE.beginSection(ON_NEW_INTENT_EVT);
|
||||
@@ -3172,7 +3172,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
// Setting the touch point to (-1, -1) will show the options popup in the center of
|
||||
// the screen.
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
Log.d(TestProtocol.PERMANENT_DIAG_TAG, "Opening options popup on key up");
|
||||
}
|
||||
showDefaultOptions(-1, -1);
|
||||
|
||||
@@ -773,7 +773,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
|
||||
if (mScroller.isFinished() && pageScrollChanged) {
|
||||
// TODO(b/246283207): Remove logging once root cause of flake detected.
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS && !(this instanceof Workspace)) {
|
||||
if (Utilities.isRunningInTestHarness() && !(this instanceof Workspace)) {
|
||||
Log.d("b/246283207", this.getClass().getSimpleName() + "#onLayout() -> "
|
||||
+ "if(mScroller.isFinished() && pageScrollChanged) -> getNextPage(): "
|
||||
+ getNextPage() + ", getScrollForPage(getNextPage()): "
|
||||
@@ -1713,7 +1713,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FeatureFlags.IS_STUDIO_BUILD && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (FeatureFlags.IS_STUDIO_BUILD && !Utilities.isRunningInTestHarness()) {
|
||||
duration *= Settings.Global.getFloat(getContext().getContentResolver(),
|
||||
Settings.Global.WINDOW_ANIMATION_SCALE, 1);
|
||||
}
|
||||
|
||||
@@ -150,11 +150,14 @@ public final class Utilities {
|
||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
||||
}
|
||||
|
||||
public static boolean IS_RUNNING_IN_TEST_HARNESS =
|
||||
ActivityManager.isRunningInTestHarness();
|
||||
private static boolean sIsRunningInTestHarness = ActivityManager.isRunningInTestHarness();
|
||||
|
||||
public static boolean isRunningInTestHarness() {
|
||||
return sIsRunningInTestHarness;
|
||||
}
|
||||
|
||||
public static void enableRunningInTestHarnessForTests() {
|
||||
IS_RUNNING_IN_TEST_HARNESS = true;
|
||||
sIsRunningInTestHarness = true;
|
||||
}
|
||||
|
||||
public static boolean isPropertyEnabled(String propertyName) {
|
||||
|
||||
@@ -127,7 +127,7 @@ public class DiscoveryBounce extends AbstractFloatingView {
|
||||
|| onboardingPrefs.getBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN)
|
||||
|| AbstractFloatingView.getTopOpenView(launcher) != null
|
||||
|| launcher.getSystemService(UserManager.class).isDemoUser()
|
||||
|| Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
|| Utilities.isRunningInTestHarness()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public class AccessibilityManagerCompat {
|
||||
*/
|
||||
private static AccessibilityManager getAccessibilityManagerForTest(Context context) {
|
||||
// If not running in a test harness, don't participate in test exchanges.
|
||||
if (!Utilities.IS_RUNNING_IN_TEST_HARNESS) return null;
|
||||
if (!Utilities.isRunningInTestHarness()) return null;
|
||||
|
||||
final AccessibilityManager accessibilityManager = getManager(context);
|
||||
if (!accessibilityManager.isEnabled()) return null;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class SpringLoadedDragController implements OnAlarmListener {
|
||||
|
||||
private long getEnterSpringLoadHoverTime() {
|
||||
// Some TAPL tests are flaky on Cuttlefish with a low waiting time
|
||||
return Utilities.IS_RUNNING_IN_TEST_HARNESS
|
||||
return Utilities.isRunningInTestHarness()
|
||||
? ENTER_SPRING_LOAD_HOVER_TIME_IN_TEST
|
||||
: ENTER_SPRING_LOAD_HOVER_TIME;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TestInformationProvider extends ContentProvider {
|
||||
|
||||
@Override
|
||||
public Bundle call(String method, String arg, Bundle extras) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
TestInformationHandler handler = TestInformationHandler.newInstance(getContext());
|
||||
handler.init(getContext());
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ public final class TestLogging {
|
||||
}
|
||||
|
||||
public static void recordEvent(String sequence, String event) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
recordEventSlow(sequence, event);
|
||||
}
|
||||
}
|
||||
|
||||
public static void recordEvent(String sequence, String message, Object parameter) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
recordEventSlow(sequence, message + ": " + parameter);
|
||||
}
|
||||
}
|
||||
@@ -58,14 +58,14 @@ public final class TestLogging {
|
||||
}
|
||||
|
||||
public static void recordKeyEvent(String sequence, String message, KeyEvent event) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
recordEventSlow(sequence, message + ": " + event);
|
||||
registerEventNotFromTest(event);
|
||||
}
|
||||
}
|
||||
|
||||
public static void recordMotionEvent(String sequence, String message, MotionEvent event) {
|
||||
if (Utilities.IS_RUNNING_IN_TEST_HARNESS && event.getAction() != MotionEvent.ACTION_MOVE) {
|
||||
if (Utilities.isRunningInTestHarness() && event.getAction() != MotionEvent.ACTION_MOVE) {
|
||||
recordEventSlow(sequence, message + ": " + event);
|
||||
registerEventNotFromTest(event);
|
||||
}
|
||||
|
||||
@@ -139,11 +139,11 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
// TODO(b/258604917): When running in test harness, use !sTransientTaskbarStatusForTests
|
||||
// once tests are updated to expect new persistent behavior such as not allowing long press
|
||||
// to stash.
|
||||
if (!Utilities.IS_RUNNING_IN_TEST_HARNESS && FORCE_PERSISTENT_TASKBAR.get()) {
|
||||
if (!Utilities.isRunningInTestHarness() && FORCE_PERSISTENT_TASKBAR.get()) {
|
||||
return false;
|
||||
}
|
||||
return getInfo().navigationMode == NavigationMode.NO_BUTTON
|
||||
&& (Utilities.IS_RUNNING_IN_TEST_HARNESS
|
||||
&& (Utilities.isRunningInTestHarness()
|
||||
? sTransientTaskbarStatusForTests
|
||||
: ENABLE_TRANSIENT_TASKBAR.get());
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
|
||||
/** Returns {@code true} if tip has previously been shown on any of {@link BaseWidgetSheet}. */
|
||||
protected boolean hasSeenEducationTip() {
|
||||
return mActivityContext.getSharedPrefs().getBoolean(KEY_WIDGETS_EDUCATION_TIP_SEEN, false)
|
||||
|| Utilities.IS_RUNNING_IN_TEST_HARNESS;
|
||||
|| Utilities.isRunningInTestHarness();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -939,7 +939,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
protected boolean hasSeenEducationDialog() {
|
||||
return mActivityContext.getSharedPrefs()
|
||||
.getBoolean(KEY_WIDGETS_EDUCATION_DIALOG_SEEN, false)
|
||||
|| Utilities.IS_RUNNING_IN_TEST_HARNESS;
|
||||
|| Utilities.isRunningInTestHarness();
|
||||
}
|
||||
|
||||
private void setUpEducationViewsIfNeeded() {
|
||||
|
||||
Reference in New Issue
Block a user