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文章
6161瀏覽量
114177 -
安卓
+關注
關注
5文章
2179瀏覽量
59927 -
RK3568
+關注
關注
5文章
628瀏覽量
7610
發布評論請先 登錄
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強制所有應用橫屏展示
評論