我是靠谱客的博主 沉静小懒虫,这篇文章主要介绍android 10 系统源码 framework 默认所有强制竖屏应用(SCREEN_ORIENTATION_PORTRAIT)横屏显示,现在分享给大家,希望可以做个参考。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54frameworks/base/core/java/android/content/pm/PackageParser.java @@ -169,6 +169,8 @@ public class PackageParser { private static final boolean MULTI_PACKAGE_APK_ENABLED = Build.IS_DEBUGGABLE && SystemProperties.getBoolean(PROPERTY_CHILD_PACKAGES_ENABLED, false); + private static final boolean FORCE_LANDSCAPE_ENABLED = SystemProperties.getBoolean("persist.sys.force.landscape", true); + private static final float DEFAULT_PRE_O_MAX_ASPECT_RATIO = 1.86f; private static final float DEFAULT_PRE_Q_MIN_ASPECT_RATIO = 1.333f; private static final float DEFAULT_PRE_Q_MIN_ASPECT_RATIO_WATCH = 1f; @@ -4478,9 +4480,12 @@ public class PackageParser { a.info.flags |= ActivityInfo.FLAG_RESUME_WHILE_PAUSING; } - a.info.screenOrientation = sa.getInt( - R.styleable.AndroidManifestActivity_screenOrientation, - SCREEN_ORIENTATION_UNSPECIFIED); + int screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED); + a.info.screenOrientation = screenOrientation; + if (FORCE_LANDSCAPE_ENABLED && !("org.codeaurora.snapcam".equals(owner.packageName)) + && (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)) { //根据包名过滤某个应用 + a.info.screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; + } setActivityResizeMode(a.info, sa, owner); frameworks/base/services/core/java/com/android/server/wm/DisplayRotation.java int rotationForOrientation(int orientation, int lastRotation) { ... String pkgName = mDisplayPolicy.getAppPackageName(); boolean isSnapCamera = "org.codeaurora.snapcam".equals(pkgName); //根据包名过滤某个应用 switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: + if (isSnapCamera) { + return Surface.ROTATION_0; + } // Return portrait unless overridden. if (isAnyPortrait(preferredRotation)) { return preferredRotation; } - return mPortraitRotation; + return preferredRotation; ... default: // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, // just return the preferred orientation we already calculated. if (preferredRotation >= 0) { return preferredRotation; } return Surface.ROTATION_90; } }
最后
以上就是沉静小懒虫最近收集整理的关于android 10 系统源码 framework 默认所有强制竖屏应用(SCREEN_ORIENTATION_PORTRAIT)横屏显示的全部内容,更多相关android内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复