RK3568 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 } }
-
开发板
+关注
关注
26文章
6433浏览量
121052 -
安卓
+关注
关注
5文章
2187浏览量
60546 -
RK3568
+关注
关注
5文章
655浏览量
8125
发布评论请先 登录
RK3568开发板教程:以iTOP-RK3568开发板为例 Android13通过CIFS协议挂载Windows共享目录
【北京迅为】itop-rk3568开发板官方Android11移植教程
iTOP-RK3568开发板Android11设置语言和默认时区
toybrick_RK3568X开发板:跑通 android 开发流程
【ROC-RK3568-PC开发板试用体验】Firefly ROC-RK3568-PC开发板初探
迅为iTOP-RK3568开发板Android11移植之源码结构简介
【迅为工业RK3568稳定可靠】itop-3568开发板Linux驱动开发实战:RK3568内核模块符号导出详解
如何基于开发板RK3568 Android 11强制所有应用横屏展示
评论