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