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

相关推荐
Aileen_0v05 小时前
【Gemini3.0的国内use教程】
android·人工智能·算法·开源·mariadb
浩浩的代码花园6 小时前
自研端侧推理模型实测效果展示
android·深度学习·计算机视觉·端智能
踢球的打工仔12 小时前
PHP面向对象(7)
android·开发语言·php
安卓理事人12 小时前
安卓socket
android
安卓理事人18 小时前
安卓LinkedBlockingQueue消息队列
android
万能的小裴同学19 小时前
Android M3U8视频播放器
android·音视频
q***577420 小时前
MySql的慢查询(慢日志)
android·mysql·adb
JavaNoober20 小时前
Android 前台服务 "Bad Notification" 崩溃机制分析文档
android
城东米粉儿21 小时前
关于ObjectAnimator
android
zhangphil1 天前
Android渲染线程Render Thread的RenderNode与DisplayList,引用Bitmap及Open GL纹理上传GPU
android