Locking orientation on phones (issue 4967793)

Change-Id: I6b5fe63547f43c408feea75f35dc0a08d06c258c
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 6640f04..b208e88 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -524,7 +524,7 @@
         }
 
         // Start the drag
-        mLauncher.lockScreenOrientation();
+        mLauncher.lockScreenOrientationOnLargeUI();
         mLauncher.getWorkspace().onDragStartedWithItemSpans(createItemInfo.spanX,
                 createItemInfo.spanY, b);
         mDragController.startDrag(image, b, this, createItemInfo,
@@ -553,7 +553,7 @@
             // drop in Workspace
             mLauncher.exitSpringLoadedDragMode();
         }
-        mLauncher.unlockScreenOrientation();
+        mLauncher.unlockScreenOrientationOnLargeUI();
 
     }
 
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 28fdb90..c3edb99 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -321,6 +321,11 @@
         if (sAppMarketIcon[coi] != null) {
             updateAppMarketIcon(sAppMarketIcon[coi]);
         }
+
+        // On large interfaces, we want the screen to auto-rotate based on the current orientation
+        if (LauncherApplication.isScreenLarge()) {
+            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+        }
     }
 
     private void checkForLocaleChange() {
@@ -3040,16 +3045,21 @@
         }
         return oriMap[(d.getRotation() + indexOffset) % 4];
     }
-    public void lockScreenOrientation() {
-        setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources()
-                .getConfiguration().orientation));
+
+    public void lockScreenOrientationOnLargeUI() {
+        if (LauncherApplication.isScreenLarge()) {
+            setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources()
+                    .getConfiguration().orientation));
+        }
     }
-    public void unlockScreenOrientation() {
-        mHandler.postDelayed(new Runnable() {
-            public void run() {
-                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
-            }
-        }, mRestoreScreenOrientationDelay);
+    public void unlockScreenOrientationOnLargeUI() {
+        if (LauncherApplication.isScreenLarge()) {
+            mHandler.postDelayed(new Runnable() {
+                public void run() {
+                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+                }
+            }, mRestoreScreenOrientationDelay);
+        }
     }
 
     /* Cling related */
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 156d57e..f61f7e7 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -315,13 +315,13 @@
     public void onDragStart(DragSource source, Object info, int dragAction) {
         mIsDragOccuring = true;
         updateChildrenLayersEnabled();
-        mLauncher.lockScreenOrientation();
+        mLauncher.lockScreenOrientationOnLargeUI();
     }
 
     public void onDragEnd() {
         mIsDragOccuring = false;
         updateChildrenLayersEnabled();
-        mLauncher.unlockScreenOrientation();
+        mLauncher.unlockScreenOrientationOnLargeUI();
     }
 
     /**