Understanding Special Permission Compatibility
masterSettingsCompat handles the fragmentation of special permissions across different Android versions and manufacturer ROMs:
Detection Logic
- API 23+ (Android 6.0/M): Uses
Settings.canDrawOverlaysandSettings.System.canWrite. - API 18+ (Android 4.3/JellyBean MR2): Uses reflection to access
AppOpsManager.checkOp. - API < 18: Permissions are enabled by default; always returns
true.
Authorization Logic
- API 23+: Redirects to system settings via
Settings.ACTION_MANAGE_OVERLAY_PERMISSIONorSettings.ACTION_MANAGE_WRITE_SETTINGS. - API 18+: Permissions are enabled by default.
- API < 18: No action required.
ROM-Specific Behavior
Some manufacturers (e.g., Huawei, Xiaomi, Meizu, Vivo) use custom permission management systems instead of standard Android settings. In these cases, the library attempts to detect the ROM type and redirect the user to the specific security center or app details page relevant to that manufacturer.