Android 6.0’s Special Permissions are included

  • Hover window permissions (SYSTEM_ALERT_WINDOW)
  • System Settings Change permission (WRITE_SETTINGS)

In Android 6.0+, you need to apply for permissions in the manifest and send an Intent for the user to check in the Settings interface

adapter

detection

  • API 23+(Android 6.0+/M) useSettings.canDrawOverlays.Settings.System.canWrite
  • API 18+(Android 4.3+/JellyBean MR2) is used through reflectionAppOpsManager.checkOp
  • API < 18 always returns true when default permission is enabled

authorization

  • API 23+(Android 6.0+/M) go to the system Settings panel
    new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
    new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)Copy the code
  • API 18+(Android 4.3+/JellyBean MR2) is enabled by default
  • API < 18 Default permission enabled, do not do any processing

Changing authorization Status

Appopsmanager. setMode can be used to modify authorization status on Android 4.3/4.4

18 add AppOpsManager API (hidden, publicly in Android 4.4) API need signature verification authority after 21 Android. The Manifest. Permission. UPDATE_APP_OPS_STATS, third-party applications may not be able to use.

ROM

API 18+ Some ROMs disable permissions by default, and usually have their own permissions management. In this case, you need to check the Rom type and go to the corresponding Settings page

API 23+ should have gone to the system Settings panel, but some ROMs will use their own permission management instead of the system Settings panel, in this case, you still need to check the Rom type and then jump to the corresponding Settings page

In fact, it jumps to the corresponding permission setting page in the security center on the mobile phone. When the security center version is different, the corresponding permission setting page may also be different

There are some ROM application details page can be set permissions

test

Basically, the suspension window clearance was tested

equipment System version ROM version The default jump
Huawei Honor 7I The 6.0.1 4.0 disable ok
Huawei Honor Free play 5X 5.1.1 4.0.1 disable ok
Huawei Ascend P7 5.1.1 3.1 disable ok
Huawei Honor 6 5.1.1 3.1 disable ok
Huawei enjoys the 5S 5.1 3.0 disable ok
Huawei P8 5.0.1 3.1 available Ok, noSecurity center
Millet MI 5 6.0 V7 disable ok
Millet Note Pro 5.1.1 V8 disable ok
Xiaomi Redmi Pro 6.0 V8 disable ok
Millet Red Rice 1S 4.4.2 V7 disable ok
Meizu Pro5 5.1 5.1.11 disable ok
Meizu MX4 5.1 5.1.5 disable ok
Meizu Magic Blue Note2 5.1 5.1.5 disable ok
Meizu M1 4.4.4 2 available ok

Suspension Windows cannot be overlaid on other applications

Details page has hover window permission Settings

After being disabled, there is no impact
The hammer nuts 5.1.1 2.5.3 disable fail

Reaches the hover window management page, but then crashes
The hammer nuts 4.4.4 2.1.2 disable ok
OPPO A53 5.1.1 2.1 available ok
OPPO R7s 4.4.4 2.1 available ok
VIVO X6S Plus 5.1.1 2.5 available arriveI housekeeperThe home page

Not to hover window management page
VIVO X6 5.1 2.5 available arriveI housekeeperThe home page

Not to hover window management page
VIVO X5 5.0 2.5 available arriveI housekeeperThe home page

Not to hover window management page
VIVO X5M 5.0.2 2.0 available ok

I housekeeperNo floating window management
VIVO Y23L 4.4.4 1.5 available ok

I housekeeperNo floating window management
The samsung Galaxy S6 The 6.0.1 / available ok
The samsung Galaxy Note4 The 6.0.1 / available ok
MOTOROLA X Style 5.1.1 / available ok
Lenovo Lemoon 3 5.1.1 / available ok
Coolpad Fengshang Pro 4.4.4 / available ok
Gionee F103 5.0 / available ok
Letv Max The 6.0.1 / available ok

Baidu cloud machine mtc.baidu.com/tinypace/ma…

Tencent optimal measuring machine remote.utest.qq.com/deviceSearc…

Compatible with the library

Github.com/czy1121/set…

Welcome to star, fork, issue





screenshot.png

API

// Check whether authorization is granted
SettingsCompat.canDrawOverlays(Context)
SettingsCompat.canWriteSettings(Context)

// Set the authorization status, available only on Android 4.3/4.4 without deep customization
SettingsCompat.setDrawOverlays(Context, boolean)
SettingsCompat.setWriteSettings(Context, boolean)

// Go to the hover window permission Settings page
SettingsCompat.manageDrawOverlays(Context)
// Jump to the system Settings change permission setting page, temporarily only support Android 6.0+
SettingsCompat.manageWriteSettings(Context)Copy the code

reference

Android suspension window permission for each model of each system adaptation blog.csdn.net/self_study/… Github.com/zhaozepeng/…

Android M Permissions Best Practices Chen-Wei. me/2016/11/10/…

Android Permissions Management — AppOps 3dobe.com/archives/51…

Android App Ops analysis mssun. Me /blog/androi…

Androidxref.com/4.3_r2.1/xr…