Android竖屏转横屏

高通7.1竖屏转横屏

 

竖屏转横屏的patch:

diff --git a/frameworks/base/cmds/bootanimation/BootAnimation.cpp b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
old mode 100644
new mode 100755
index d4a9326..06375a5
--- a/frameworks/base/cmds/bootanimation/BootAnimation.cpp
+++ b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
@@ -286,6 +286,18 @@ status_t BootAnimation::readyToRun() {
     status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
     if (status)
         return -1;
+    char value[PROPERTY_VALUE_MAX];
+    property_get("persist.panel.orientation", value, "0");
+    int orient = atoi(value) / 90;
+
+    if(orient == eOrientation90 || orient == eOrientation270) {
+        int temp = dinfo.h;
+        dinfo.h = dinfo.w;
+        dinfo.w = temp;
+    }
+
+    Rect destRect(dinfo.w, dinfo.h);
+    mSession->setDisplayProjection(dtoken, orient, destRect, destRect);
 
     // create the native surface
     sp control = session()->createSurface(String8("BootAnimation"),
diff --git a/frameworks/base/cmds/bootanimation/BootAnimation.h b/frameworks/base/cmds/bootanimation/BootAnimation.h
old mode 100644
new mode 100755
index c0ae6b6..e357365
--- a/frameworks/base/cmds/bootanimation/BootAnimation.h
+++ b/frameworks/base/cmds/bootanimation/BootAnimation.h
@@ -39,6 +39,12 @@ class SurfaceControl;
 class BootAnimation : public Thread, public IBinder::DeathRecipient
 {
 public:
+    enum {
+        eOrientationDefault     = 0,
+        eOrientation90          = 1,
+        eOrientation180         = 2,
+        eOrientation270         = 3,
+    };
                 BootAnimation();
     virtual     ~BootAnimation();
 
diff --git a/frameworks/base/core/java/com/android/internal/view/RotationPolicy.java b/frameworks/base/core/java/com/android/internal/view/RotationPolicy.java
index b479cb1..a615298 100644
--- a/frameworks/base/core/java/com/android/internal/view/RotationPolicy.java
+++ b/frameworks/base/core/java/com/android/internal/view/RotationPolicy.java
@@ -25,6 +25,7 @@ import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Handler;
 import android.os.RemoteException;
+import android.os.SystemProperties;
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.util.Log;
@@ -140,7 +141,9 @@ public final class RotationPolicy {
                 try {
                     IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
                     if (enabled) {
-                        wm.freezeRotation(rotation);
+                        //wm.freezeRotation(rotation);
+                        wm.freezeRotation(SystemProperties.getInt(
+                                "persist.panel.orientation", 0)/90);
                     } else {
                         wm.thawRotation();
                     }
@@ -194,4 +197,4 @@ public final class RotationPolicy {
 
         public abstract void onChange();
     }
-}
\ No newline at end of file
+}
diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index d9515e9..6e7559e 100755
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -147,7 +147,7 @@
     true
 
     
-    1
+    0
 
     
     -1
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
old mode 100644
new mode 100755
index a7a792b..455a575
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -127,11 +127,14 @@ public class StatusBarWindowManager implements RemoteInputController.Callback {
         if (state.isKeyguardShowingAndNotOccluded()) {
             if (mKeyguardScreenRotation) {
                 mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
+				Log.i(TAG,"Tim orientation SCREEN_ORIENTATION_USER");
             } else {
-                mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
+                mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
+				Log.i(TAG,"Tim orientation SCREEN_ORIENTATION_NOSENSOR");
             }
         } else {
             mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+			Log.i(TAG,"Tim orientation SCREEN_ORIENTATION_UNSPECIFIED");
         }
     }
 
diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
old mode 100644
new mode 100755
index 8432af2..a22c75d
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -676,6 +676,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     int mOverscanRight = 0;
     int mOverscanBottom = 0;
 
+    int mPanelOrientation = Surface.ROTATION_0;
+
     // What we do when the user long presses on home
     private int mLongPressOnHomeBehavior;
 
@@ -1857,6 +1859,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
             return;
         }
         mDisplay = display;
+		mPanelOrientation =SystemProperties.getInt("persist.panel.orientation", 0) / 90;
 
         final Resources res = mContext.getResources();
         int shortSize, longSize;
@@ -6801,7 +6804,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                     mAllowAllRotations = mContext.getResources().getBoolean(
                             com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0;
                 }
-                if (sensorRotation != Surface.ROTATION_180
+                if (sensorRotation != mUpsideDownRotation
                         || mAllowAllRotations == 1
                         || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
                         || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) {
@@ -6879,7 +6882,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                     if (preferredRotation >= 0) {
                         return preferredRotation;
                     }
-                    return Surface.ROTATION_0;
+                    return mPanelOrientation;
             }
         }
     }
diff --git a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
old mode 100644
new mode 100755
index 149d1dc..64d23bb
--- a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -558,7 +558,7 @@ public class WindowManagerService extends IWindowManager.Stub
     /** All DisplayContents in the world, kept here */
     SparseArray mDisplayContents = new SparseArray<>(2);
 
-    int mRotation = 0;
+    int mRotation = SystemProperties.getInt("persist.panel.orientation", 0) / 90;
     int mLastOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
     boolean mAltOrientation = false;
 
diff --git a/frameworks/native/services/surfaceflinger/DisplayDevice.cpp b/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
old mode 100644
new mode 100755
index f1450cf..c66dce7
--- a/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
+++ b/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-// #define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
 #undef LOG_TAG
 #define LOG_TAG "DisplayDevice"
 
@@ -168,8 +168,16 @@ DisplayDevice::DisplayDevice(
     property_get("ro.panel.mountflip", property, "0");
     mPanelMountFlip = atoi(property);
 
+	int panelOrientation = DisplayState::eOrientationDefault;
+    // Set the panel orientation from the property.
+    property_get("persist.panel.orientation", property, "0");
+    panelOrientation = atoi(property) / 90;
+
     // initialize the display orientation transform.
-    setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
+    setProjection(panelOrientation, mViewport, mFrame);
+
+	// initialize the display orientation transform.
+    //setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
 
 #ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS
     surface->allocateBuffers();
diff --git a/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp b/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
old mode 100644
new mode 100755
index 6cdc80d..f066ebc
--- a/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-// #define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
 
 #include 
@@ -1556,8 +1556,45 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                                 || (state.viewport != draw[i].viewport)
                                 || (state.frame != draw[i].frame))
                         {
-                            disp->setProjection(state.orientation,
-                                    state.viewport, state.frame);
+                        	
+
+
+#ifdef 1
+														int orient = state.orientation;
+														// Honor the orientation change after boot
+														// animation completes and make sure boot
+														// animation is shown in panel orientation always.
+														if(mBootFinished){
+															disp->setProjection(state.orientation,
+																	state.viewport, state.frame);
+															orient = state.orientation;
+														}
+														else{
+															char property[PROPERTY_VALUE_MAX];
+															int panelOrientation =
+																	DisplayState::eOrientationDefault;
+															if(property_get("persist.panel.orientation",
+																		property, "0") > 0){
+																panelOrientation = atoi(property) / 90;
+															}
+															disp->setProjection(panelOrientation,
+																	state.viewport, state.frame);
+															orient = panelOrientation;
+														}
+														// Set the view frame of each display only of its
+														// default orientation.
+														if(orient == DisplayState::eOrientationDefault and
+																state.frame.isValid()) {
+															qdutils::setViewFrame(disp->getHwcDisplayId(),
+																state.frame.left, state.frame.top,
+																state.frame.right, state.frame.bottom);
+														}
+#else
+														disp->setProjection(state.orientation,
+															state.viewport, state.frame);
+#endif
+
+				//end
                         }
                         if (state.width != draw[i].width || state.height != draw[i].height) {
                             disp->setDisplaySize(state.width, state.height);


diff --git a/device/qcom/msm8952_64/system.prop b/device/qcom/msm8952_64/system.prop
index ccb4468..4ecae2c 100755
--- a/device/qcom/msm8952_64/system.prop
+++ b/device/qcom/msm8952_64/system.prop
@@ -227,3 +227,13 @@ sched.colocate.enable=1
 persist.radio.lw_enabled=true
 
 persist.sys.usb.config=diag,serial_smd,rmnet_ipa,adb

+persist.panel.orientation=90

1.以上补丁请谨慎运用,修改之后开机动画还是会有问题(会出现黑屏),其它的recovery可能还是会有影响。

2.RotationPolicy的修改会使其只能固定到横屏的方向,若是固定其它方向,会出现半边黑屏的问题

3.recovery的方向还未修改

./device/qcom/msm8916_64/chinachip/C10/system.prop:35:persist.panel.orientation=90
./device/qcom/msm8916_64/system.prop:173:#persist.panel.orientation=270
./frameworks/native/services/surfaceflinger/DisplayDevice.cpp:134:    property_get("persist.panel.orientation", property, "0");
./frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp:1562:                                if(property_get("persist.panel.orientation",
./frameworks/base/core/java/com/android/internal/view/RotationPolicy.java:147:                                "persist.panel.orientation", 0)/90);
./frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java:1666:            SystemProperties.getInt("persist.panel.orientation", 0) / 90;
./frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java:489:    int mRotation = SystemProperties.getInt("persist.panel.orientation", 0) / 90;
./frameworks/base/cmds/bootanimation/BootAnimation.cpp:335:    property_get("persist.panel.orientation", value, "0");
 

 

调试过程中遇到的问题:

1.第一次刷机开机后还是竖屏显示,第二次开机正常

高通的代码中有一个apk:Setup_Wizard,这个应用会覆盖Provision。并且它的主activity被写成了竖屏。

diff --git a/vendor/qcom/proprietary/qrdplus/Extension/apps/SetupWizard/AndroidManifest.xml b/vendor/qcom/proprietary/qrdplus/Extension/apps/SetupWizard/AndroidManifest.xml
index 421f846..b323654 100755
--- a/vendor/qcom/proprietary/qrdplus/Extension/apps/SetupWizard/AndroidManifest.xml
+++ b/vendor/qcom/proprietary/qrdplus/Extension/apps/SetupWizard/AndroidManifest.xml
@@ -28,7 +28,7 @@
             android:name=".SetupWelcomeActivity"
             android:excludeFromRecents="true"
             android:launchMode="singleTask"
-            android:screenOrientation="portrait" >
+           android:screenOrientation="nosensor" >
             
                 
                 
@@ -49,4 +49,4 @@
         
     
 
-
\ No newline at end of file
+
 

2.刷机第一次开机黑屏

原因:高通的代码中有一个apk:Setup_Wizard,这个应用会覆盖Provision,这个应用显示的是黑屏

解决方法:

diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index d9515e9..41001be 100755
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -82,7 +82,7 @@
     /system/media/audio/ui/WirelessChargingStarted.ogg
 
     false
-    false
+    true
     1
 
     
@@ -176,7 +176,7 @@
     9
 
     
-    false
+    true
 
     

你可能感兴趣的:(Andoid系统常用修改)