RK3568开发平台Android 11强制所有应用横屏展示
  1i0l01KBCSs3 2023年12月23日 15 0

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

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            
        }            
    }            
    



-END-

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年12月23日 0

暂无评论

推荐阅读
1i0l01KBCSs3