android筆記整理

android筆記整理

------

強制設置橫屏

PackageParser.java

 private Activity parseActivity(Package owner, Resources res,
            XmlPullParser parser, AttributeSet attrs, int flags, String[] outError,
            boolean receiver, boolean hardwareAccelerated)
            throws XmlPullParserException, IOException {

....

  a.info.launchMode = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_launchMode,
                    ActivityInfo.LAUNCH_MULTIPLE);
            // add force landscape
            String force_landscape;
            force_landscape = SystemProperties.get("sys.forcelandscape",null);
            if (force_landscape.equals("1")) {
                a.info.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            } else {
                a.info.screenOrientation = sa.getInt(
                        com.android.internal.R.styleable.AndroidManifestActivity_screenOrientation,
                        ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
            }
            // add force landscape end
            a.info.configChanges = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_configChanges,
                    0);

 

WindowManager.java

 /**
         * Name of the package owning this window.
         */
        public String packageName = null;
       
        /**
         * Specific orientation value for a window.
         * May be any of the same values allowed
         * for {@link android.content.pm.ActivityInfo#screenOrientation}.
         * If not set, a default value of
         * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
         * will be used.
         */
         // add force landscape
         public int screenOrientation = SystemProperties.get("sys.forcelandscape",null).equals("1")?ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
         // add force landscape end


        /**
         * Control the visibility of the status bar.
         *
         * @see View#STATUS_BAR_VISIBLE
         * @see View#STATUS_BAR_HIDDEN
         */
        public int systemUiVisibility;

 

WindowManagerService.java

   int mLastWindowForcedOrientation = SystemProperties.get("sys.forcelandscape").equals("1") ?
            ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
 

 if (win.mAppToken != null) {
                // We hit an application window. so the orientation will be determined by the
                // app window. No point in continuing further.
                // MStar Android Patch Begin
                return mLastWindowForcedOrientation = SystemProperties.get("sys.forcelandscape").equals("1") ?
                        ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
                // MStar Android Patch End
 }

int lastOrientation = SystemProperties.get("sys.forcelandscape").equals("1") ?
                ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

即在有mLastWindowForcedOrientation和lastOrientation的地方,強制設置橫屏。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章