高通Android 12/13 Launcher3修改RecentView与屏幕方向保持一致

1、背景:

最近同事遇到一个需求说,recentview应用预览与屏幕方向不一致问题,于是加了一些系统日志,实现此需求。简单记录下哈。

源码修改路径汇总如下

 packages/apps/Launcher3/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
	修改:         packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
	修改:         packages/apps/Launcher3/src/com/android/launcher3/settings/SettingsActivity.java
	修改:         packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java

2、源码修改diff如下所示

diff --git a/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/QSSI12/packages/app
index 8ccab71..e39c261 100644
--- a/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -69,7 +69,7 @@ public class RecentsOrientedState implements
         SharedPreferences.OnSharedPreferenceChangeListener {
 
     private static final String TAG = "RecentsOrientedState";
-    private static final boolean DEBUG = false;
+    private static final boolean DEBUG = true;
 
     @Retention(SOURCE)
     @IntDef({ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270})
@@ -288,7 +288,8 @@ public class RecentsOrientedState implements
     }
 
     private void updateHomeRotationSetting() {
-        boolean homeRotationEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, false);
+       // boolean homeRotationEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, false);
+               boolean homeRotationEnabled = true;
         setFlag(FLAG_HOME_ROTATION_ALLOWED_IN_PREFS, homeRotationEnabled);
         SystemUiProxy.INSTANCE.get(mContext).setHomeRotationEnabled(homeRotationEnabled);
     }
diff --git a/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/QSSI12/packages/apps/
index d833877..801bfd8 100644
--- a/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -440,6 +440,7 @@ public class TaskThumbnailView extends View {
 
             int thumbnailRotation = thumbnailData.rotation;
             int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
+                       android.util.Log.d("ZM","currentRotation:"+currentRotation+"thumbnailRotation:"+thumbnailRotation+"deltaRot
             RectF thumbnailClipHint = new RectF();
             if (TaskView.clipLeft(dp)) {
                 thumbnailClipHint.left = thumbnailData.insets.left;
+               boolean homeRotationEnabled = true;
         setFlag(FLAG_HOME_ROTATION_ALLOWED_IN_PREFS, homeRotationEnabled);
         SystemUiProxy.INSTANCE.get(mContext).setHomeRotationEnabled(homeRotationEnabled);
     }
diff --git a/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/QSSI12/packages/apps/
index d833877..801bfd8 100644
--- a/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/QSSI12/packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -440,6 +440,7 @@ public class TaskThumbnailView extends View {
 
             int thumbnailRotation = thumbnailData.rotation;
             int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
+                       android.util.Log.d("ZM","currentRotation:"+currentRotation+"thumbnailRotation:"+thumbnailRotation+"deltaRot
             RectF thumbnailClipHint = new RectF();
             if (TaskView.clipLeft(dp)) {
                 thumbnailClipHint.left = thumbnailData.insets.left;
@@ -568,7 +569,7 @@ public class TaskThumbnailView extends View {
             }
 
             Rect splitScreenInsets = dp.getInsets();
-            if (!isRotated) {
+            if (!isRotated || deltaRotate == 2) {
                 // No Rotation
                 if (dp.isMultiWindowMode) {
                     mClippedInsets.offsetTo(splitScreenInsets.left * scale,
diff --git a/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/settings/SettingsActivity.java b/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/settings/SettingsActivity.java 
index 0c39632..dece103 100644
--- a/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/settings/SettingsActivity.java
@@ -254,7 +254,7 @@ public class SettingsActivity extends FragmentActivity
                 case ALLOW_ROTATION_PREFERENCE_KEY:
                     DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.get(
                             getContext()).getDeviceProfile(getContext());
-                    if (deviceProfile.isTablet) {
+                    if (true) {
diff --git a/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java b/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java 
index 867fd99..f5926ec 100644
--- a/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
+++ b/QSSI12/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
@@ -91,7 +91,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener,
 
     private void setIgnoreAutoRotateSettings(boolean ignoreAutoRotateSettings) {
         // On large devices we do not handle auto-rotate differently.
-        mIgnoreAutoRotateSettings = ignoreAutoRotateSettings;
+        mIgnoreAutoRotateSettings = true;
         if (!mIgnoreAutoRotateSettings) {
             if (mSharedPrefs == null) {
                 mSharedPrefs = Utilities.getPrefs(mActivity);

3、最后展示RecentView与屏幕方向保持一致。转载请注明出处高通Android 12/13 Launcher3修改RecentView与屏幕方向保持一致-CSDN博客,谢谢!

注意事项:

1、修改完之后记得make clean全编,不然可能没生效哈!

2、app应用强制设置竖屏这里暂时不考虑哈!需要可以自行修改app方向(通过配置横竖屏二套布局文件或者在清单文件中默认配置。)

相关推荐
水瓶丫头站住4 小时前
安卓APP如何适配不同的手机分辨率
android·智能手机
xvch4 小时前
Kotlin 2.1.0 入门教程(五)
android·kotlin
xvch8 小时前
Kotlin 2.1.0 入门教程(七)
android·kotlin
望风的懒蜗牛8 小时前
编译Android平台使用的FFmpeg库
android
浩宇软件开发9 小时前
Android开发,待办事项提醒App的设计与实现(个人中心页)
android·android studio·android开发
ac-er88889 小时前
Yii框架中的多语言支持:如何实现国际化
android·开发语言·php
苏金标10 小时前
The maximum compatible Gradle JVM version is 17.
android
zhangphil10 小时前
Android BitmapShader简洁实现马赛克,Kotlin(一)
android·kotlin
iofomo15 小时前
Android平台从上到下,无需ROOT/解锁/刷机,应用级拦截框架的最后一环,SVC系统调用拦截。
android
我叫特踏实16 小时前
SensorManager开发参考
android·sensormanager