高通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方向(通过配置横竖屏二套布局文件或者在清单文件中默认配置。)

相关推荐
张风捷特烈12 小时前
Flutter 伪3D绘制#03 | 轴测投影原理分析
android·flutter·canvas
omegayy15 小时前
Unity 2022.3.x部分Android设备播放视频黑屏问题
android·unity·视频播放·黑屏
mingqian_chu16 小时前
ubuntu中使用安卓模拟器
android·linux·ubuntu
自动花钱机16 小时前
Kotlin问题汇总
android·开发语言·kotlin
行墨18 小时前
Kotlin 主构造函数
android
前行的小黑炭18 小时前
Android从传统的XML转到Compose的变化:mutableStateOf、MutableStateFlow;有的使用by有的使用by remember
android·kotlin
_一条咸鱼_18 小时前
Android Compose 框架尺寸与密度深入剖析(五十五)
android
在狂风暴雨中奔跑19 小时前
使用AI开发Android界面
android·人工智能
行墨19 小时前
Kotlin 定义类与field关键
android
信徒_20 小时前
Mysql 在什么样的情况下会产生死锁?
android·数据库·mysql