File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
RotationControl/src/main/java/com/programminghoch10/RotationControl Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11package com .programminghoch10 .RotationControl ;
22
33import android .app .Activity ;
4+ import android .content .Context ;
5+ import android .content .ContextWrapper ;
46import android .content .pm .ActivityInfo ;
57import android .view .Window ;
68
@@ -24,7 +26,15 @@ protected void beforeHookedMethod(MethodHookParam param) {
2426 "generateLayout" , "com.android.internal.policy.DecorView" , new XC_MethodHook () {
2527 @ Override
2628 protected void beforeHookedMethod (MethodHookParam param ) {
27- ((Activity ) ((Window ) param .thisObject ).getContext ()).setRequestedOrientation (ActivityInfo .SCREEN_ORIENTATION_FULL_SENSOR );
29+ Context context = ((Window ) param .thisObject ).getContext ();
30+
31+ while (context instanceof ContextWrapper ) {
32+ if (context instanceof Activity activity ) {
33+ activity .setRequestedOrientation (ActivityInfo .SCREEN_ORIENTATION_FULL_SENSOR );
34+ return ;
35+ }
36+ context = ((ContextWrapper ) context ).getBaseContext ();
37+ }
2838 }
2939 }
3040 );
You can’t perform that action at this time.
0 commit comments