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 1
1
package com .programminghoch10 .RotationControl ;
2
2
3
3
import android .app .Activity ;
4
+ import android .content .Context ;
5
+ import android .content .ContextWrapper ;
4
6
import android .content .pm .ActivityInfo ;
5
7
import android .view .Window ;
6
8
@@ -24,7 +26,15 @@ protected void beforeHookedMethod(MethodHookParam param) {
24
26
"generateLayout" , "com.android.internal.policy.DecorView" , new XC_MethodHook () {
25
27
@ Override
26
28
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
+ }
28
38
}
29
39
}
30
40
);
You can’t perform that action at this time.
0 commit comments