RK3568开发平台Android 11强制所有应用横屏展示

电子说

1.3w人已加入

描述

Android 11强制所有应用横屏展示

1、打开

frameworks/base/core/java/android/content/pm/parsing/component/ParsedActivityUtils.java

文件,定位到

parseActivityOrReceiver

方法的

int screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);

这一行,注释掉该行并添加如下代码:// int screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);            

// Edit by jgduan            

int screenOrientation;            

if(pkg.getSharedUserId() == null){            

    screenOrientation = 0;            

} else {            

    screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, SCREEN_ORIENTATION_UNSPECIFIED);            

}            

// End            

2、

打开

frameworks/base/core/java/android/app/Activity.java

文件,对

setRequestedOrientation

方法进行如下修改:

    /**            

     * Change the desired orientation of this activity.  If the activity            

     * is currently in the foreground or otherwise impacting the screen            

     * orientation, the screen will immediately be changed (possibly causing            

     * the activity to be restarted). Otherwise, this will be used the next            

     * time the activity is visible.            

     *            

     * @param requestedOrientation An orientation constant as used in            

     * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}.            

     */            

    public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) {            

        if (mParent == null) {            

            try {            

                // Edit by jgduan            

                //ActivityTaskManager.getService().setRequestedOrientation(            

                //        mToken, requestedOrientation);            

                if(mApplication != null && mApplication.getApplicationInfo() != null            

                    && mApplication.getApplicationInfo().uid > 10000){            

                    ActivityTaskManager.getService().setRequestedOrientation(            

                            mToken, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);            

                } else {            

                    ActivityTaskManager.getService().setRequestedOrientation(            

                            mToken, requestedOrientation);            

                }            

                // End            

            } catch (RemoteException e) {            

                // Empty            

            }            

        } else {            

            // Edit by jgduan            

            // mParent.setRequestedOrientation(requestedOrientation);            

            if(mApplication != null && mApplication.getApplicationInfo() != null            

                    && mApplication.getApplicationInfo().uid > 10000){            

                mParent.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);            

            }else{            

                mParent.setRequestedOrientation(requestedOrientation);            

            }            

            // End            

        }            

    }            

    
审核编辑 黄宇

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分