File tree Expand file tree Collapse file tree 5 files changed +41
-6
lines changed
facebook/react/devsupport Expand file tree Collapse file tree 5 files changed +41
-6
lines changed Original file line number Diff line number Diff line change 11
11
12
12
import android .content .Context ;
13
13
import android .graphics .PixelFormat ;
14
+ import android .os .Build ;
14
15
import android .support .annotation .Nullable ;
15
16
import android .view .Gravity ;
16
17
import android .view .WindowManager ;
@@ -43,7 +44,11 @@ public void setFpsDebugViewVisible() {
43
44
params .width = WindowManager .LayoutParams .WRAP_CONTENT ;
44
45
params .height = WindowManager .LayoutParams .WRAP_CONTENT ;
45
46
params .gravity = Gravity .RIGHT | Gravity .TOP ;
46
- params .type = WindowManager .LayoutParams .TYPE_PHONE ;
47
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
48
+ params .type = WindowManager .LayoutParams .TYPE_APPLICATION_OVERLAY ;
49
+ } else {
50
+ params .type = WindowManager .LayoutParams .TYPE_PHONE ;
51
+ }
47
52
params .format = PixelFormat .RGBA_8888 ;
48
53
params .flags = WindowManager .LayoutParams .FLAG_NOT_TOUCH_MODAL
49
54
| WindowManager .LayoutParams .FLAG_NOT_FOCUSABLE ;
Original file line number Diff line number Diff line change 2
2
3
3
import android .content .Context ;
4
4
import android .graphics .PixelFormat ;
5
+ import android .os .Build ;
5
6
import android .view .Gravity ;
6
7
import android .view .View ;
7
8
import android .view .WindowManager ;
@@ -25,7 +26,13 @@ public TrackerWindowManager(Context context) {
25
26
params .width = WindowManager .LayoutParams .WRAP_CONTENT ;
26
27
params .height = WindowManager .LayoutParams .WRAP_CONTENT ;
27
28
params .gravity = Gravity .LEFT | Gravity .TOP ;
28
- params .type = WindowManager .LayoutParams .TYPE_PHONE ;
29
+
30
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
31
+ params .type = WindowManager .LayoutParams .TYPE_APPLICATION_OVERLAY ;
32
+ } else {
33
+ params .type = WindowManager .LayoutParams .TYPE_PHONE ;
34
+ }
35
+
29
36
params .format = PixelFormat .RGBA_8888 ;
30
37
params .flags = WindowManager .LayoutParams .FLAG_NOT_TOUCH_MODAL | WindowManager .LayoutParams .FLAG_NOT_FOCUSABLE ;
31
38
Original file line number Diff line number Diff line change 4
4
import android .content .Context ;
5
5
import android .content .Intent ;
6
6
import android .graphics .PixelFormat ;
7
+ import android .os .Build ;
7
8
import android .os .IBinder ;
8
9
import android .support .annotation .Nullable ;
9
10
import android .util .Log ;
@@ -52,7 +53,11 @@ public class CPUService extends Service {
52
53
params .width = WindowManager .LayoutParams .WRAP_CONTENT ;
53
54
params .height = WindowManager .LayoutParams .WRAP_CONTENT ;
54
55
params .gravity = Gravity .CENTER | Gravity .TOP ;
55
- params .type = WindowManager .LayoutParams .TYPE_PHONE ;
56
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
57
+ params .type = WindowManager .LayoutParams .TYPE_APPLICATION_OVERLAY ;
58
+ } else {
59
+ params .type = WindowManager .LayoutParams .TYPE_PHONE ;
60
+ }
56
61
params .format = PixelFormat .RGBA_8888 ;
57
62
params .flags = WindowManager .LayoutParams .FLAG_NOT_TOUCH_MODAL | WindowManager .LayoutParams .FLAG_NOT_FOCUSABLE ;
58
63
Original file line number Diff line number Diff line change 1
1
package com .han .devtool ;
2
2
3
3
import android .content .Intent ;
4
+ import android .net .Uri ;
5
+ import android .os .Build ;
4
6
import android .os .Bundle ;
7
+ import android .provider .Settings ;
5
8
import android .support .v7 .app .AppCompatActivity ;
6
9
import android .text .method .ScrollingMovementMethod ;
7
10
import android .view .View ;
@@ -63,15 +66,25 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
63
66
}
64
67
65
68
case R .id .manage :
66
- SettingsCompat .manageDrawOverlays (this );
69
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
70
+ if (!Settings .canDrawOverlays (getApplicationContext ())) {
71
+ //启动Activity让用户授权
72
+ Intent intent = new Intent (Settings .ACTION_MANAGE_OVERLAY_PERMISSION );
73
+ intent .setData (Uri .parse ("package:" + getPackageName ()));
74
+ startActivityForResult (intent ,100 );
75
+ }
76
+ } else {
77
+ SettingsCompat .manageDrawOverlays (this );
78
+ }
79
+
67
80
break ;
68
81
case R .id .toggle :
69
82
boolean granted1 = SettingsCompat .canDrawOverlays (this );
70
83
SettingsCompat .setDrawOverlays (this , !granted1 );
71
84
boolean granted2 = SettingsCompat .canDrawOverlays (this );
72
85
Toast .makeText (this ,RomUtil .getVersion () + "\n " +RomUtil .getName () + "\n granted: " + granted2 ,Toast .LENGTH_LONG ).show ();
73
86
break ;
74
-
87
+
75
88
}
76
89
}
77
90
Original file line number Diff line number Diff line change 7
7
import android .database .sqlite .SQLiteDatabase ;
8
8
import android .graphics .PixelFormat ;
9
9
import android .os .AsyncTask ;
10
+ import android .os .Build ;
10
11
import android .os .IBinder ;
11
12
import android .support .annotation .Nullable ;
12
13
import android .support .v4 .widget .CursorAdapter ;
@@ -94,7 +95,11 @@ public LogdEvent(LogLine logLine) {
94
95
params .width = WindowManager .LayoutParams .WRAP_CONTENT ;
95
96
params .height = WindowManager .LayoutParams .WRAP_CONTENT ;
96
97
params .gravity = Gravity .CENTER | Gravity .TOP ;
97
- params .type = WindowManager .LayoutParams .TYPE_PHONE ;
98
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
99
+ params .type = WindowManager .LayoutParams .TYPE_APPLICATION_OVERLAY ;
100
+ } else {
101
+ params .type = WindowManager .LayoutParams .TYPE_PHONE ;
102
+ }
98
103
params .format = PixelFormat .RGBA_8888 ;
99
104
params .flags = WindowManager .LayoutParams .FLAG_NOT_TOUCH_MODAL | WindowManager .LayoutParams .FLAG_NOT_FOCUSABLE ;
100
105
You can’t perform that action at this time.
0 commit comments