Merge "Removing additional rpc due to icon cache update" into ub-launcher3-master
diff --git a/res/values-ta/strings.xml b/res/values-ta/strings.xml
index 253e3af..ed0f09d 100644
--- a/res/values-ta/strings.xml
+++ b/res/values-ta/strings.xml
@@ -114,8 +114,7 @@
     <string name="action_move_here" msgid="2170188780612570250">"இங்கு நகர்த்து"</string>
     <string name="item_added_to_workspace" msgid="4211073925752213539">"முகப்புத் திரையில் சேர்க்கப்பட்டது"</string>
     <string name="item_removed" msgid="851119963877842327">"அகற்றப்பட்டது"</string>
-    <!-- no translation found for undo (4151576204245173321) -->
-    <skip />
+    <string name="undo" msgid="4151576204245173321">"செயல்தவிர்"</string>
     <string name="action_move" msgid="4339390619886385032">"நகர்த்து"</string>
     <string name="move_to_empty_cell" msgid="2833711483015685619">"<xliff:g id="NUMBER_0">%1$s</xliff:g> வரிசை, <xliff:g id="NUMBER_1">%2$s</xliff:g> நெடுவரிசைக்கு நகர்த்து"</string>
     <string name="move_to_position" msgid="6750008980455459790">"நிலை <xliff:g id="NUMBER">%1$s</xliff:g>க்கு நகர்த்து"</string>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index b5bbb9c..bbe5b78 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -868,17 +868,6 @@
         }
     }
 
-    public boolean hasSettings() {
-        if (mLauncherCallbacks != null) {
-            return mLauncherCallbacks.hasSettings();
-        } else {
-            // On O and above we there is always some setting present settings (add icon to
-            // home screen or icon badging). On earlier APIs we will have the allow rotation
-            // setting, on devices with a locked orientation,
-            return Utilities.ATLEAST_OREO || !getResources().getBoolean(R.bool.allow_rotation);
-        }
-    }
-
     public boolean isInState(LauncherState state) {
         return mStateManager.getState() == state;
     }
diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java
index e866445..9c4a4ea 100644
--- a/src/com/android/launcher3/states/RotationHelper.java
+++ b/src/com/android/launcher3/states/RotationHelper.java
@@ -56,7 +56,7 @@
     private final Activity mActivity;
     private final SharedPreferences mPrefs;
 
-    private final boolean mIgnoreAutoRotateSettings;
+    private boolean mIgnoreAutoRotateSettings;
     private boolean mAutoRotateEnabled;
 
     /**
@@ -110,6 +110,13 @@
         }
     }
 
+    // Used by tests only.
+    public void forceAllowRotationForTesting(boolean allowRotation) {
+        mIgnoreAutoRotateSettings =
+                allowRotation || mActivity.getResources().getBoolean(R.bool.allow_rotation);
+        notifyChange();
+    }
+
     public void initialize() {
         if (!mInitialized) {
             mInitialized = true;
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 5a3d36d..ba7d9c5 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -52,7 +52,6 @@
 import com.android.launcher3.tapl.LauncherInstrumentation;
 import com.android.launcher3.testcomponent.AppWidgetNoConfig;
 import com.android.launcher3.testcomponent.AppWidgetWithConfig;
-import com.android.launcher3.util.Condition;
 import com.android.launcher3.util.Wait;
 import com.android.launcher3.util.rule.LauncherActivityRule;
 
@@ -79,20 +78,23 @@
     public static final long DEFAULT_WORKER_TIMEOUT_SECS = 5;
 
     protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
-    protected UiDevice mDevice;
-    protected LauncherInstrumentation mLauncher;
+    protected final UiDevice mDevice;
+    protected final LauncherInstrumentation mLauncher;
     protected Context mTargetContext;
     protected String mTargetPackage;
 
     private static final String TAG = "AbstractLauncherUiTest";
 
+    protected AbstractLauncherUiTest() {
+        mDevice = UiDevice.getInstance(getInstrumentation());
+        mLauncher = new LauncherInstrumentation(getInstrumentation());
+    }
+
     @Rule
     public LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
 
     @Before
     public void setUp() throws Exception {
-        mDevice = UiDevice.getInstance(getInstrumentation());
-        mLauncher = new LauncherInstrumentation(getInstrumentation());
         mTargetContext = InstrumentationRegistry.getTargetContext();
         mTargetPackage = mTargetContext.getPackageName();
         mDevice.executeShellCommand("settings put global heads_up_notifications_enabled 0");
@@ -285,12 +287,7 @@
     // flakiness.
     protected boolean waitForLauncherCondition(
             Function<Launcher, Boolean> condition, long timeout) {
-        return Wait.atMost(new Condition() {
-            @Override
-            public boolean isTrue() {
-                return getFromLauncher(condition);
-            }
-        }, timeout);
+        return Wait.atMost(() -> getFromLauncher(condition), timeout);
     }
 
     /**
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 9e4a615..7885e3c 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -25,6 +25,7 @@
 import android.os.Parcelable;
 import android.provider.Settings;
 import android.util.Log;
+import android.view.Surface;
 import android.view.accessibility.AccessibilityEvent;
 
 import androidx.annotation.NonNull;
@@ -92,6 +93,7 @@
     private final boolean mSwipeUpEnabled;
     private Boolean mSwipeUpEnabledOverride = null;
     private final Instrumentation mInstrumentation;
+    private int mExpectedRotation = Surface.ROTATION_0;
 
     /**
      * Constructs the root of TAPL hierarchy. You get all other objects from it.
@@ -109,7 +111,7 @@
         assertTrue("Device must run in a test harness", ActivityManager.isRunningInTestHarness());
     }
 
-    // Used only by tests.
+    // Used only by TaplTests.
     public void overrideSwipeUpEnabled(Boolean swipeUpEnabledOverride) {
         mSwipeUpEnabledOverride = swipeUpEnabledOverride;
     }
@@ -144,14 +146,30 @@
         fail(message + ". " + "Actual: " + actual);
     }
 
+    static public void assertEquals(String message, int expected, int actual) {
+        if (expected != actual) {
+            fail(message + " expected: " + expected + " but was: " + actual);
+        }
+    }
+
     static void assertNotEquals(String message, int unexpected, int actual) {
         if (unexpected == actual) {
             failEquals(message, actual);
         }
     }
 
+    public void setExpectedRotation(int expectedRotation) {
+        mExpectedRotation = expectedRotation;
+    }
+
     private UiObject2 verifyContainerType(ContainerType containerType) {
+        assertEquals("Unexpected display rotation",
+                mExpectedRotation, mDevice.getDisplayRotation());
+        assertTrue("Presence of recents button doesn't match isSwipeUpEnabled()",
+                isSwipeUpEnabled() ==
+                        (mDevice.findObject(By.res(SYSTEMUI_PACKAGE, "recent_apps")) == null));
         log("verifyContainerType: " + containerType);
+
         switch (containerType) {
             case WORKSPACE: {
                 waitUntilGone(APPS_RES_ID);
@@ -172,7 +190,11 @@
                 return waitForLauncherObject(APPS_RES_ID);
             }
             case OVERVIEW: {
-                waitForLauncherObject(APPS_RES_ID);
+                if (mDevice.isNaturalOrientation()) {
+                    waitForLauncherObject(APPS_RES_ID);
+                } else {
+                    waitUntilGone(APPS_RES_ID);
+                }
                 waitUntilGone(WORKSPACE_RES_ID);
                 waitUntilGone(WIDGETS_RES_ID);
                 return waitForLauncherObject(OVERVIEW_RES_ID);