Android ActivityManagerService禁用应用转屏

--- a/frameworks/base/core/java/android/content/pm/PackageParser.java
+++ b/frameworks/base/core/java/android/content/pm/PackageParser.java
@@ -3594,9 +3594,18 @@ public class PackageParser {
                 a.info.flags |= ActivityInfo.FLAG_RESUME_WHILE_PAUSING;
             }
+                       /*
             a.info.screenOrientation = sa.getInt(
                     R.styleable.AndroidManifestActivity_screenOrientation,
                     SCREEN_ORIENTATION_UNSPECIFIED);
+                       */
+            int myOrientation = sa.getInt(com.android.internal.R.styleable.AndroidManifestActivity_screenOrientation,
+                               ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+            if (myOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
+                               myOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
+            a.info.screenOrientation = myOrientation;
+            a.info.configChanges = sa.getInt(com.android.internal.R.styleable.AndroidManifestActivity_configChanges,
+                     0);
             a.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
             final boolean appDefault = (owner.applicationInfo.privateFlags



--- a/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -4998,6 +4998,8 @@ public final class ActivityManagerService extends ActivityManagerNative
     @Override
     public void setRequestedOrientation(IBinder token, int requestedOrientation) {
+               android.util.Log.i("AZ", "setRequestedOrientation:" + requestedOrientation);
+               requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
         synchronized (this) {
             ActivityRecord r = ActivityRecord.isInStackLocked(token);
             if (r == null) {
发布了234 篇原创文章 · 获赞 64 · 访问量 95万+

猜你喜欢

转载自blog.csdn.net/zhoumushui/article/details/102892996