這篇博客主要介紹的是 Android 主流各種機(jī)型和各種版本的懸浮窗權(quán)限適配,但是由于碎片化的問題恩溅,所以在適配方面也無法做到完全的主流機(jī)型適配,這個(gè)需要大家的一起努力,這個(gè)博客的名字永遠(yuǎn)都是一個(gè)將來時(shí)态坦,感興趣或者找到其他機(jī)型適配方法的請(qǐng)留言告訴我,或者加群544645972一起交流一下棒拂,非常感謝~
相關(guān)權(quán)限請(qǐng)看我的另一篇博客:android permission權(quán)限與安全機(jī)制解析(下)伞梯,或者關(guān)于權(quán)限的案例使用:android WindowManager解析與騙取QQ密碼案例分析,還有錄音和攝像頭權(quán)限的適配:Android 錄音和攝像頭權(quán)限適配帚屉。
轉(zhuǎn)載請(qǐng)注明出處:http://blog.csdn.net/self_study/article/details/52859790谜诫。
源碼會(huì)實(shí)時(shí)更新在 gitHub 上,不會(huì)實(shí)時(shí)更新博客攻旦,所以想要看最新代碼的同學(xué)喻旷,請(qǐng)直接去 github 頁面查看 markdown。
懸浮窗適配#
懸浮窗適配有兩種方法:第一種是按照正規(guī)的流程牢屋,如果系統(tǒng)沒有賦予 APP 彈出懸浮窗的權(quán)限且预,就先跳轉(zhuǎn)到權(quán)限授權(quán)界面,等用戶打開該權(quán)限之后烙无,再去彈出懸浮窗锋谐,比如 QQ 等一些主流應(yīng)用就是這么做得;第二種就是利用系統(tǒng)的漏洞截酷,繞過權(quán)限的申請(qǐng)涮拗,簡(jiǎn)單粗暴,這種方法我不是特別建議迂苛,但是現(xiàn)在貌似有些應(yīng)用就是這樣三热,比如 UC 和有道詞典,這樣適配在大多數(shù)手機(jī)上都是 OK 的三幻,但是在一些特殊的機(jī)型不行康铭,比如某米的 miui8。
正常適配流程##
在 4.4~5.1.1 版本之間赌髓,和 6.0~最新版本之間的適配方法是不一樣的从藤,之前的版本由于 google 并沒有對(duì)這個(gè)權(quán)限進(jìn)行單獨(dú)處理,所以是各家手機(jī)廠商根據(jù)需要定制的锁蠕,所以每個(gè)權(quán)限的授權(quán)界面都各不一樣夷野,適配起來難度較大,6.0 之后適配起來就相對(duì)簡(jiǎn)單很多了荣倾。
Android 4.4 ~ Android 5.1.1###
由于判斷權(quán)限的類 AppOpsManager 是 API19 版本添加悯搔,所以Android 4.4 之前的版本(不包括4.4)就不用去判斷了,直接調(diào)用 WindowManager 的 addView 方法彈出即可舌仍,但是貌似有些特殊的手機(jī)廠商在 API19 版本之前就已經(jīng)自定義了懸浮窗權(quán)限妒貌,如果有發(fā)現(xiàn)的通危,請(qǐng)聯(lián)系我。
眾所周知灌曙,國(guó)產(chǎn)手機(jī)的種類實(shí)在是過于豐富菊碟,而且一個(gè)品牌的不同版本還有不一樣的適配方法,比如某米(嫌棄臉)在刺,所以我在實(shí)際適配的過程中總結(jié)了幾種通用的方法逆害, 大家可以參考一下:<ul><li>直接百度一下,搜索關(guān)鍵詞“小米手機(jī)懸浮窗適配”等蚣驼;</li><li>看看 QQ 或者其他的大公司 APP 是否已經(jīng)適配魄幕,如果已經(jīng)適配,跳轉(zhuǎn)到相關(guān)權(quán)限授權(quán)頁面之后颖杏,或者自己能夠直接在設(shè)置里找到懸浮窗權(quán)限授權(quán)頁面也是一個(gè)道理纯陨,使用 adb shell dumpsys activity
命令,找到相關(guān)的信息留储,如下圖所示
可以清楚看到授權(quán) activity 頁面的包名和 activity 名翼抠,而且可以清楚地知道跳轉(zhuǎn)的 intent 是否帶了 extra,如果沒有 extra 就可以直接跳入欲鹏,如果帶上了 extra映挂,百度一下該 activity 的名字完域,看能否找到有用信息轨帜,比如適配方案或者源碼 APK 之類的转锈;</li><li>依舊利用上面的方法,找到 activity 的名字尤误,然后 root 準(zhǔn)備適配的手機(jī)侠畔,直接在相關(guān)目錄 /system/app 下把源碼 APK 拷貝出來,反編譯损晤,根據(jù) activity 的名字找到相關(guān)代碼软棺,之后的事情就簡(jiǎn)單了;</li><li>還有一個(gè)方法就是發(fā)動(dòng)人力資源去找尤勋,看看已經(jīng)適配該手機(jī)機(jī)型的 app 公司是否有自己認(rèn)識(shí)的人喘落,或者干脆點(diǎn),直接找這個(gè)手機(jī)公司里面是否有自己認(rèn)識(shí)的手機(jī)開發(fā)朋友最冰,直接詢問瘦棋,方便快捷。</li></ul>
常規(guī)手機(jī)####
由于 6.0 之前的版本常規(guī)手機(jī)并沒有把懸浮窗權(quán)限單獨(dú)拿出來暖哨,所以正常情況下是可以直接使用 WindowManager.addView 方法直接彈出懸浮窗赌朋。
如何判斷手機(jī)的機(jī)型,辦法很多,在這里我就不貼代碼了沛慢,一般情況下在 terminal 中執(zhí)行 getprop 命令赡若,然后在打印出來的信息中找到相關(guān)的機(jī)型信息即可,這里貼出國(guó)產(chǎn)幾款常見機(jī)型的判斷:
/**
* 獲取 emui 版本號(hào)
* @return
*/
public static double getEmuiVersion() {
try {
String emuiVersion = getSystemProperty("ro.build.version.emui");
String version = emuiVersion.substring(emuiVersion.indexOf("_") + 1);
return Double.parseDouble(version);
} catch (Exception e) {
e.printStackTrace();
}
return 4.0;
}
/**
* 獲取小米 rom 版本號(hào)团甲,獲取失敗返回 -1
*
* @return miui rom version code, if fail , return -1
*/
public static int getMiuiVersion() {
String version = getSystemProperty("ro.miui.ui.version.name");
if (version != null) {
try {
return Integer.parseInt(version.substring(1));
} catch (Exception e) {
Log.e(TAG, "get miui version code error, version : " + version);
}
}
return -1;
}
public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
} catch (IOException ex) {
Log.e(TAG, "Unable to read sysprop " + propName, ex);
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
Log.e(TAG, "Exception while closing InputStream", e);
}
}
}
return line;
}
public static boolean checkIsHuaweiRom() {
return Build.MANUFACTURER.contains("HUAWEI");
}
/**
* check if is miui ROM
*/
public static boolean checkIsMiuiRom() {
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
}
public static boolean checkIsMeizuRom() {
//return Build.MANUFACTURER.contains("Meizu");
String meizuFlymeOSFlag = getSystemProperty("ro.build.display.id");
if (TextUtils.isEmpty(meizuFlymeOSFlag)){
return false;
}else if (meizuFlymeOSFlag.contains("flyme") || meizuFlymeOSFlag.toLowerCase().contains("flyme")){
return true;
}else {
return false;
}
}
/**
* check if is 360 ROM
*/
public static boolean checkIs360Rom() {
return Build.MANUFACTURER.contains("QiKU");
}
小米####
首先需要適配的就應(yīng)該是小米了逾冬,而且比較麻煩的事情是,miui 的每個(gè)版本適配方法都是不一樣的伐庭,所以只能每個(gè)版本去單獨(dú)適配粉渠,不過還好由于使用的人數(shù)多分冈,網(wǎng)上的資料也比較全圾另。首先第一步當(dāng)然是判斷是否賦予了懸浮窗權(quán)限,這個(gè)時(shí)候就需要使用到 AppOpsManager 這個(gè)類了雕沉,它里面有一個(gè) checkop 方法:
/**
* Do a quick check for whether an application might be able to perform an operation.
* This is <em>not</em> a security check; you must use {@link #noteOp(int, int, String)}
* or {@link #startOp(int, int, String)} for your actual security checks, which also
* ensure that the given uid and package name are consistent. This function can just be
* used for a quick check to see if an operation has been disabled for the application,
* as an early reject of some work. This does not modify the time stamp or other data
* about the operation.
* @param op The operation to check. One of the OP_* constants.
* @param uid The user id of the application attempting to perform the operation.
* @param packageName The name of the application attempting to perform the operation.
* @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or
* {@link #MODE_IGNORED} if it is not allowed and should be silently ignored (without
* causing the app to crash).
* @throws SecurityException If the app has been configured to crash on this op.
* @hide
*/
public int checkOp(int op, int uid, String packageName) {
try {
int mode = mService.checkOperation(op, uid, packageName);
if (mode == MODE_ERRORED) {
throw new SecurityException(buildSecurityExceptionMsg(op, uid, packageName));
}
return mode;
} catch (RemoteException e) {
}
return MODE_IGNORED;
}
找到懸浮窗權(quán)限的 op 值是:
/** @hide */
public static final int OP_SYSTEM_ALERT_WINDOW = 24;
注意到這個(gè)函數(shù)和這個(gè)值其實(shí)都是 hide 的集乔,所以沒辦法,你懂的坡椒,只能用反射:
/**
* 檢測(cè) miui 懸浮窗權(quán)限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
} else {
// if ((context.getApplicationInfo().flags & 1 << 27) == 1) {
// return true;
// } else {
// return false;
// }
return true;
}
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int)method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e(TAG, "Below API 19 cannot invoke!");
}
return false;
}
檢測(cè)完成之后就是跳轉(zhuǎn)到授權(quán)頁面去開啟權(quán)限了扰路,但是由于 miui 不同版本的權(quán)限授權(quán)頁面不一樣,所以需要根據(jù)不同版本進(jìn)行不同處理:
/**
* 獲取小米 rom 版本號(hào)倔叼,獲取失敗返回 -1
*
* @return miui rom version code, if fail , return -1
*/
public static int getMiuiVersion() {
String version = RomUtils.getSystemProperty("ro.miui.ui.version.name");
if (version != null) {
try {
return Integer.parseInt(version.substring(1));
} catch (Exception e) {
Log.e(TAG, "get miui version code error, version : " + version);
Log.e(TAG, Log.getStackTraceString(e));
}
}
return -1;
}
/**
* 小米 ROM 權(quán)限申請(qǐng)
*/
public static void applyMiuiPermission(Context context) {
int versionCode = getMiuiVersion();
if (versionCode == 5) {
goToMiuiPermissionActivity_V5(context);
} else if (versionCode == 6) {
goToMiuiPermissionActivity_V6(context);
} else if (versionCode == 7) {
goToMiuiPermissionActivity_V7(context);
} else if (versionCode == 8) {
goToMiuiPermissionActivity_V8(context);
} else {
Log.e(TAG, "this is a special MIUI rom version, its version code " + versionCode);
}
}
private static boolean isIntentAvailable(Intent intent, Context context) {
if (intent == null) {
return false;
}
return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
}
/**
* 小米 V5 版本 ROM權(quán)限申請(qǐng)
*/
public static void goToMiuiPermissionActivity_V5(Context context) {
Intent intent = null;
String packageName = context.getPackageName();
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package" , packageName, null);
intent.setData(uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "intent is not available!");
}
//設(shè)置頁面在應(yīng)用詳情頁面
// Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
// PackageInfo pInfo = null;
// try {
// pInfo = context.getPackageManager().getPackageInfo
// (HostInterfaceManager.getHostInterface().getApp().getPackageName(), 0);
// } catch (PackageManager.NameNotFoundException e) {
// AVLogUtils.e(TAG, e.getMessage());
// }
// intent.setClassName("com.android.settings", "com.miui.securitycenter.permission.AppPermissionsEditor");
// intent.putExtra("extra_package_uid", pInfo.applicationInfo.uid);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// if (isIntentAvailable(intent, context)) {
// context.startActivity(intent);
// } else {
// AVLogUtils.e(TAG, "Intent is not available!");
// }
}
/**
* 小米 V6 版本 ROM權(quán)限申請(qǐng)
*/
public static void goToMiuiPermissionActivity_V6(Context context) {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
intent.putExtra("extra_pkgname", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "Intent is not available!");
}
}
/**
* 小米 V7 版本 ROM權(quán)限申請(qǐng)
*/
public static void goToMiuiPermissionActivity_V7(Context context) {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
intent.putExtra("extra_pkgname", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "Intent is not available!");
}
}
/**
* 小米 V8 版本 ROM權(quán)限申請(qǐng)
*/
public static void goToMiuiPermissionActivity_V8(Context context) {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity");
intent.putExtra("extra_pkgname", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
Log.e(TAG, "Intent is not available!");
}
}
getSystemProperty 方法是直接調(diào)用 getprop 方法來獲取系統(tǒng)信息:
public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
} catch (IOException ex) {
Log.e(TAG, "Unable to read sysprop " + propName, ex);
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
Log.e(TAG, "Exception while closing InputStream", e);
}
}
}
return line;
}
最新的 V8 版本有些機(jī)型已經(jīng)是 6.0 汗唱,所以就是下面介紹到 6.0 的適配方法了,感謝 @pinocchio2mx 的反饋丈攒,有些機(jī)型的 miui8 版本還是5.1.1哩罪,所以 miui8 依舊需要做適配,非常感謝巡验,希望大家一起多多反饋問題际插,謝謝~~。
魅族####
魅族的適配显设,由于我司魅族的機(jī)器相對(duì)較少框弛,所以只適配了 flyme5.1.1/android 5.1.1 版本 mx4 pro 的系統(tǒng)。和小米一樣捕捂,首先也要通過 API19 版本添加的 AppOpsManager 類判斷是否授予了權(quán)限:
/**
* 檢測(cè) meizu 懸浮窗權(quán)限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
}
return true;
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int)method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e(TAG, "Below API 19 cannot invoke!");
}
return false;
}
然后是跳轉(zhuǎn)去懸浮窗權(quán)限授予界面:
/**
* 去魅族權(quán)限申請(qǐng)頁面
*/
public static void applyPermission(Context context){
Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
intent.setClassName("com.meizu.safe", "com.meizu.safe.security.AppSecActivity");
intent.putExtra("packageName", context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
如果有魅族其他版本的適配方案瑟枫,請(qǐng)聯(lián)系我。
華為####
華為的適配是根據(jù)網(wǎng)上找的方案指攒,外加自己的一些優(yōu)化而成慷妙,但是由于華為手機(jī)的眾多機(jī)型,所以覆蓋的機(jī)型和系統(tǒng)版本還不是那么全面幽七,如果有其他機(jī)型和版本的適配方案景殷,請(qǐng)聯(lián)系我,我更新到 github 上。和小米猿挚,魅族一樣咐旧,首先通過 AppOpsManager 來判斷權(quán)限是否已經(jīng)授權(quán):
/**
* 檢測(cè) Huawei 懸浮窗權(quán)限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
}
return true;
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e(TAG, "Below API 19 cannot invoke!");
}
return false;
}
然后根據(jù)不同的機(jī)型和版本跳轉(zhuǎn)到不同的頁面:
/**
* 去華為權(quán)限申請(qǐng)頁面
*/
public static void applyPermission(Context context) {
try {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// ComponentName comp = new ComponentName("com.huawei.systemmanager","com.huawei.permissionmanager.ui.MainActivity");//華為權(quán)限管理
// ComponentName comp = new ComponentName("com.huawei.systemmanager",
// "com.huawei.permissionmanager.ui.SingleAppActivity");//華為權(quán)限管理,跳轉(zhuǎn)到指定app的權(quán)限管理位置需要華為接口權(quán)限绩蜻,未解決
ComponentName comp = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.addviewmonitor.AddViewMonitorActivity");//懸浮窗管理頁面
intent.setComponent(comp);
if (RomUtils.getEmuiVersion() == 3.1) {
//emui 3.1 的適配
context.startActivity(intent);
} else {
//emui 3.0 的適配
comp = new ComponentName("com.huawei.systemmanager", "com.huawei.notificationmanager.ui.NotificationManagmentActivity");//懸浮窗管理頁面
intent.setComponent(comp);
context.startActivity(intent);
}
} catch (SecurityException e) {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// ComponentName comp = new ComponentName("com.huawei.systemmanager","com.huawei.permissionmanager.ui.MainActivity");//華為權(quán)限管理
ComponentName comp = new ComponentName("com.huawei.systemmanager",
"com.huawei.permissionmanager.ui.MainActivity");//華為權(quán)限管理铣墨,跳轉(zhuǎn)到本app的權(quán)限管理頁面,這個(gè)需要華為接口權(quán)限,未解決
// ComponentName comp = new ComponentName("com.huawei.systemmanager","com.huawei.systemmanager.addviewmonitor.AddViewMonitorActivity");//懸浮窗管理頁面
intent.setComponent(comp);
context.startActivity(intent);
Log.e(TAG, Log.getStackTraceString(e));
} catch (ActivityNotFoundException e) {
/**
* 手機(jī)管家版本較低 HUAWEI SC-UL10
*/
// Toast.makeText(MainActivity.this, "act找不到", Toast.LENGTH_LONG).show();
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName comp = new ComponentName("com.Android.settings", "com.android.settings.permission.TabItem");//權(quán)限管理頁面 android4.4
// ComponentName comp = new ComponentName("com.android.settings","com.android.settings.permission.single_app_activity");//此處可跳轉(zhuǎn)到指定app對(duì)應(yīng)的權(quán)限管理頁面办绝,但是需要相關(guān)權(quán)限伊约,未解決
intent.setComponent(comp);
context.startActivity(intent);
e.printStackTrace();
Log.e(TAG, Log.getStackTraceString(e));
} catch (Exception e) {
//拋出異常時(shí)提示信息
Toast.makeText(context, "進(jìn)入設(shè)置頁面失敗,請(qǐng)手動(dòng)設(shè)置", Toast.LENGTH_LONG).show();
Log.e(TAG, Log.getStackTraceString(e));
}
}
emui4 之后就是 6.0 版本了孕蝉,按照下面介紹的 6.0 適配方案即可屡律。
360####
360手機(jī)的適配方案在網(wǎng)上可以找到的資料很少,唯一可以找到的就是這篇:奇酷360 手機(jī)中怎么跳轉(zhuǎn)安全中心中指定包名App的權(quán)限管理頁面降淮,但是博客中也沒有給出最后的適配方案超埋,不過最后居然直接用最簡(jiǎn)單的辦法就能跳進(jìn)去了,首先是權(quán)限的檢測(cè):
/**
* 檢測(cè) 360 懸浮窗權(quán)限
*/
public static boolean checkFloatWindowPermission(Context context) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
}
return true;
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
final int version = Build.VERSION.SDK_INT;
if (version >= 19) {
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
Class clazz = AppOpsManager.class;
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
return AppOpsManager.MODE_ALLOWED == (int)method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
} else {
Log.e("", "Below API 19 cannot invoke!");
}
return false;
}
如果沒有授予懸浮窗權(quán)限佳鳖,就跳轉(zhuǎn)去權(quán)限授予界面:
public static void applyPermission(Context context) {
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.Settings$OverlaySettingsActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
哈哈哈霍殴,是不是很簡(jiǎn)單,有時(shí)候真相往往一點(diǎn)也不復(fù)雜系吩,OK来庭,適配完成。
Android 6.0 及之后版本###
我在博客android permission權(quán)限與安全機(jī)制解析(下)- SYSTEM_ALERT_WINDOW中已經(jīng)介紹到了適配方案穿挨,懸浮窗權(quán)限在 6.0 之后就被 google 單獨(dú)拿出來管理了月弛,好處就是對(duì)我們來說適配就非常方便了,在所有手機(jī)和 6.0 以及之后的版本上適配的方法都是一樣的絮蒿,首先要在 Manifest 中靜態(tài)申請(qǐng)<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
權(quán)限尊搬,然后在使用時(shí)先判斷該權(quán)限是否已經(jīng)被授權(quán),如果沒有授權(quán)使用下面這段代碼進(jìn)行動(dòng)態(tài)申請(qǐng):
private static final int REQUEST_CODE = 1;
//判斷權(quán)限
private boolean commonROMPermissionCheck(Context context) {
Boolean result = true;
if (Build.VERSION.SDK_INT >= 23) {
try {
Class clazz = Settings.class;
Method canDrawOverlays = clazz.getDeclaredMethod("canDrawOverlays", Context.class);
result = (Boolean) canDrawOverlays.invoke(null, context);
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
}
}
return result;
}
//申請(qǐng)權(quán)限
private void requestAlertWindowPermission() {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
intent.setData(Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, REQUEST_CODE);
}
@Override
//處理回調(diào)
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE) {
if (Settings.canDrawOverlays(this)) {
Log.i(LOGTAG, "onActivityResult granted");
}
}
}
上述代碼需要注意的是:<ul><li>使用Action Settings.ACTION_MANAGE_OVERLAY_PERMISSION 啟動(dòng)隱式Intent土涝;</li><li>使用 “package:” + getPackageName() 攜帶App的包名信息佛寿;</li><li>使用 Settings.canDrawOverlays 方法判斷授權(quán)結(jié)果。</li></ul>在用戶開啟相關(guān)權(quán)限之后才能使用 WindowManager.LayoutParams.TYPE_SYSTEM_ERROR ,要不然是會(huì)直接崩潰的哦但壮。
特殊適配流程##
如何繞過系統(tǒng)的權(quán)限檢查冀泻,直接彈出懸浮窗?android WindowManager解析與騙取QQ密碼案例分析這篇博客中我已經(jīng)指明出來了蜡饵,需要使用mParams.type = WindowManager.LayoutParams.TYPE_TOAST;
來取代 mParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
弹渔,這樣就可以達(dá)到不申請(qǐng)權(quán)限,而直接彈出懸浮窗溯祸,至于原因嘛肢专,我們看看 PhoneWindowManager 源碼的關(guān)鍵處:
@Override
public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) {
....
switch (type) {
case TYPE_TOAST:
// XXX right now the app process has complete control over
// this... should introduce a token to let the system
// monitor/control what they are doing.
outAppOp[0] = AppOpsManager.OP_TOAST_WINDOW;
break;
case TYPE_DREAM:
case TYPE_INPUT_METHOD:
case TYPE_WALLPAPER:
case TYPE_PRIVATE_PRESENTATION:
case TYPE_VOICE_INTERACTION:
case TYPE_ACCESSIBILITY_OVERLAY:
// The window manager will check these.
break;
case TYPE_PHONE:
case TYPE_PRIORITY_PHONE:
case TYPE_SYSTEM_ALERT:
case TYPE_SYSTEM_ERROR:
case TYPE_SYSTEM_OVERLAY:
permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW;
outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
break;
default:
permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
}
if (permission != null) {
if (permission == android.Manifest.permission.SYSTEM_ALERT_WINDOW) {
final int callingUid = Binder.getCallingUid();
// system processes will be automatically allowed privilege to draw
if (callingUid == Process.SYSTEM_UID) {
return WindowManagerGlobal.ADD_OKAY;
}
// check if user has enabled this operation. SecurityException will be thrown if
// this app has not been allowed by the user
final int mode = mAppOpsManager.checkOp(outAppOp[0], callingUid,
attrs.packageName);
switch (mode) {
case AppOpsManager.MODE_ALLOWED:
case AppOpsManager.MODE_IGNORED:
// although we return ADD_OKAY for MODE_IGNORED, the added window will
// actually be hidden in WindowManagerService
return WindowManagerGlobal.ADD_OKAY;
case AppOpsManager.MODE_ERRORED:
return WindowManagerGlobal.ADD_PERMISSION_DENIED;
default:
// in the default mode, we will make a decision here based on
// checkCallingPermission()
if (mContext.checkCallingPermission(permission) !=
PackageManager.PERMISSION_GRANTED) {
return WindowManagerGlobal.ADD_PERMISSION_DENIED;
} else {
return WindowManagerGlobal.ADD_OKAY;
}
}
}
if (mContext.checkCallingOrSelfPermission(permission)
!= PackageManager.PERMISSION_GRANTED) {
return WindowManagerGlobal.ADD_PERMISSION_DENIED;
}
}
return WindowManagerGlobal.ADD_OKAY;
}
從源碼中可以看到舞肆,其實(shí) TYPE_TOAST 沒有做權(quán)限檢查,直接返回了 WindowManagerGlobal.ADD_OKAY博杖,所以呢椿胯,這就是為什么可以繞過權(quán)限的原因。還有需要注意的一點(diǎn)是 addView 方法中會(huì)調(diào)用到 mPolicy.adjustWindowParamsLw(win.mAttrs);
剃根,這個(gè)方法在不同的版本有不同的實(shí)現(xiàn):
//Android 2.0 - 2.3.7 PhoneWindowManager
public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) {
switch (attrs.type) {
case TYPE_SYSTEM_OVERLAY:
case TYPE_SECURE_SYSTEM_OVERLAY:
case TYPE_TOAST:
// These types of windows can't receive input events.
attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
break;
}
}
//Android 4.0.1 - 4.3.1 PhoneWindowManager
public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) {
switch (attrs.type) {
case TYPE_SYSTEM_OVERLAY:
case TYPE_SECURE_SYSTEM_OVERLAY:
case TYPE_TOAST:
// These types of windows can't receive input events.
attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
break;
}
}
//Android 4.4 PhoneWindowManager
@Override
public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) {
switch (attrs.type) {
case TYPE_SYSTEM_OVERLAY:
case TYPE_SECURE_SYSTEM_OVERLAY:
// These types of windows can't receive input events.
attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
break;
}
}
可以看到哩盲,在4.0.1以前, 當(dāng)我們使用 TYPE_TOAST狈醉, Android 會(huì)偷偷給我們加上 FLAG_NOT_FOCUSABLE 和 FLAG_NOT_TOUCHABLE廉油,4.0.1 開始,會(huì)額外再去掉FLAG_WATCH_OUTSIDE_TOUCH苗傅,這樣真的是什么事件都沒了抒线。而 4.4 開始,TYPE_TOAST 被移除了, 所以從 4.4 開始金吗,使用 TYPE_TOAST 的同時(shí)還可以接收觸摸事件和按鍵事件了十兢,而4.4以前只能顯示出來趣竣,不能交互摇庙,所以 API18 及以下使用 TYPE_TOAST 是無法接收觸摸事件的,但是幸運(yùn)的是除了 miui 之外遥缕,這些版本可以直接在 Manifest 文件中聲明 android.permission.SYSTEM_ALERT_WINDOW
權(quán)限卫袒,然后直接使用 WindowManager.LayoutParams.TYPE_PHONE
或者 WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
都是可以直接彈出懸浮窗的。
還有一個(gè)需要提到的是 TYPE_APPLICATION
单匣,這個(gè) type 是配合 Activity 在當(dāng)前 APP 內(nèi)部使用的夕凝,也就是說,回到 Launcher 界面户秤,這個(gè)懸浮窗是會(huì)消失的码秉。
雖然這種方法確確實(shí)實(shí)可以繞過權(quán)限,至于適配的坑呢鸡号,有人遇到之后可以聯(lián)系我转砖,我會(huì)持續(xù)完善。不過由于這樣可以不申請(qǐng)權(quán)限就彈出懸浮窗鲸伴,而且在最新的 6.0+ 系統(tǒng)上也沒有修復(fù)府蔗,所以如果這個(gè)漏洞被濫用,就會(huì)造成一些意想不到的后果汞窗,因此我個(gè)人傾向于使用 QQ 的適配方案姓赤,也就是上面的正常適配流程去處理這個(gè)權(quán)限。
更新:7.1.1之后版本
最新發(fā)現(xiàn)在 7.1.1 版本之后使用 type_toast 重復(fù)添加兩次懸浮窗仲吏,第二次會(huì)崩潰不铆,跑出來下面的錯(cuò)誤:
E/AndroidRuntime: FATAL EXCEPTION: main
android.view.WindowManager$BadTokenException: Unable to add window -- window android.view.ViewRootImpl$W@d7a4e96 has already been added
at android.view.ViewRootImpl.setView(ViewRootImpl.java:691)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at com.tencent.ysdk.module.icon.impl.a.g(Unknown Source)
at com.tencent.ysdk.module.icon.impl.floatingviews.q.onAnimationEnd(Unknown Source)
at android.view.animation.Animation$3.run(Animation.java:381)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
去追溯源碼蝌焚,發(fā)現(xiàn)是這里拋出來的錯(cuò)誤:
try {
mOrigWindowType = mWindowAttributes.type;
mAttachInfo.mRecomputeGlobalAttributes = true;
collectViewAttributes();
res = mWindowSession.addToDisplay(mWindow, mSeq, mWindowAttributes,
getHostVisibility(), mDisplay.getDisplayId(),
mAttachInfo.mContentInsets, mAttachInfo.mStableInsets,
mAttachInfo.mOutsets, mInputChannel);
} catch (RemoteException e) {
.....
} finally {
if (restore) {
attrs.restore();
}
}
.....
if (res < WindowManagerGlobal.ADD_OKAY) {
.....
switch (res) {
....
case WindowManagerGlobal.ADD_DUPLICATE_ADD:
throw new WindowManager.BadTokenException(
"Unable to add window -- window " + mWindow
+ " has already been added");
}
}
然后去查看拋出這個(gè)異常處的代碼:
if (mWindowMap.containsKey(client.asBinder())) {
Slog.w(TAG_WM, "Window " + client + " is already added");
return WindowManagerGlobal.ADD_DUPLICATE_ADD;
}
然后我們從 mWindowMap 這個(gè)變量出發(fā)去分析,但是最后發(fā)現(xiàn)誓斥,根本不行综看,這些代碼從 5.X 版本就存在了,而且每次調(diào)用 addview 方法去添加一個(gè) view 的時(shí)候岖食,都是一個(gè)新的 client 對(duì)象红碑,所以 mWindowMap.containsKey(client.asBinder())
一直是不成立的,所以無法從這里去分析泡垃,于是繼續(xù)分析在 7.0 版本是沒有問題的析珊,但是在 7.1.1 版本就出現(xiàn)問題了,所以我們?nèi)ゲ榭?7.1.1 版本代碼的變更:https://android.googlesource.com/platform/frameworks/base/+log/master/services/core/java/com/android/server/wm/WindowManagerService.java?s=28f0e5bf48e2d02e1f063670e435b1232f07ba03
我們從里面尋找關(guān)于 type_toast 的相關(guān)變更:
最終定位到了 aa07653 那個(gè)提交蔑穴,我們看看這次提交修改的內(nèi)容:
然后點(diǎn)開 WMS 的修改:
去到 canAddToastWindowForUid:
我們于是定位到了關(guān)鍵 7.1.1 上面不能重復(fù)添加 type_toast 類型 window 的原因V已啊!
另外還有一點(diǎn)需要注意的是存和,在 7.1.1 上面還增加了如下的代碼:
可以看到在 25 版本之后奕剃,注意是之后,也就是 8.0捐腿,系統(tǒng)將會(huì)限制 type_toast 的使用纵朋,會(huì)直接拋出異常,這也是需要注意的地方茄袖。
最新適配結(jié)果#
非常感謝ruanqin0706同學(xué)的大力幫忙操软,通過優(yōu)測(cè)網(wǎng)的機(jī)型的測(cè)試適配,現(xiàn)在統(tǒng)計(jì)結(jié)果如下所示:
6.0/6.0+##
更新宪祥,6.0魅族的適配方案不能使用google API聂薪,依舊要使用 6.0 之前的適配方法,已經(jīng)適配完成~
6.0 上絕大部分的機(jī)型都是可以的蝗羊,除了魅族這種奇葩機(jī)型:
機(jī)型 | 版本 | 詳細(xì)信息 | 適配完成 | 具體表現(xiàn) |
---|---|---|---|---|
魅族 PRO6 | 6.0 | 型號(hào):PRO6藏澳;版本:6.0;分辨率:1920*1080 | 否 | 檢測(cè)權(quán)限結(jié)果有誤耀找,微信可正诚栌疲縮小放大,而我方檢測(cè)為未開啟權(quán)限涯呻,為跳轉(zhuǎn)至開啟權(quán)限頁 |
魅族 U20 | 6.0 | 型號(hào):U20凉驻;版本:6.0;分辨率:1920*1080 | 否 | 檢測(cè)權(quán)限結(jié)果有誤复罐,微信可正忱缘牵縮小放大,而我方檢測(cè)為未開啟權(quán)限效诅,為跳轉(zhuǎn)至開啟權(quán)限頁 |
結(jié)論:
匯總結(jié)果 |
---|
Android6.0 及以上機(jī)型覆蓋:58款胀滚,其中: |
三星:10款趟济,均正常 |
華為:21款,均正常 |
小米:5款咽笼,均正常 |
魅族:2款顷编,異常(1.檢測(cè)權(quán)限未開啟,點(diǎn)擊 Android 6.0 及以上跳轉(zhuǎn)剑刑,無法跳轉(zhuǎn)媳纬,卻可以選擇魅族手機(jī)設(shè)置,設(shè)置后施掏,懸浮窗打開縮小正常钮惠;2.在魅族上,及時(shí)設(shè)置懸浮窗關(guān)閉七芭,微信也可正乘赝欤縮小,但是我們檢測(cè)的懸浮窗是否開發(fā)結(jié)果狸驳,和實(shí)際系統(tǒng)的設(shè)置是匹配的预明。) |
其他:20款,均正常 |
已適配完成耙箍,針對(duì)魅族的手機(jī)撰糠,在 6.0 之后仍然使用老的跳轉(zhuǎn)方式,而不是使用新版本的 Google API 進(jìn)行跳轉(zhuǎn)究西。</br>
huawei##
這里是華為手機(jī)的測(cè)試結(jié)果:
機(jī)型 | 版本 | 適配完成 | 具體表現(xiàn) | 默認(rèn)設(shè)置 |
---|---|---|---|---|
華為榮耀x2 | 5.0 | 否 | 跳轉(zhuǎn)至通知中心頁面窗慎,而非懸浮窗管理處 | 默認(rèn)關(guān)閉 |
華為暢玩4x(電信版) | 4.4.4 | 可以優(yōu)化 | 跳轉(zhuǎn)至通知中心標(biāo)簽頁面,用戶需切換標(biāo)簽頁(通知中心卤材、懸浮窗為兩個(gè)不同標(biāo)簽頁) | 默認(rèn)關(guān)閉 |
華為 p8 lite | 4.4.4 | 可以優(yōu)化 | 跳轉(zhuǎn)至通知中心標(biāo)簽頁面,用戶需切換標(biāo)簽頁(通知中心峦失、懸浮窗為兩個(gè)不同標(biāo)簽頁) | 默認(rèn)關(guān)閉 |
華為榮耀 6 移動(dòng)版 | 4.4.2 | 可以優(yōu)化 | 跳轉(zhuǎn)至通知中心標(biāo)簽頁面扇丛,用戶需切換標(biāo)簽頁(通知中心、懸浮窗為兩個(gè)不同標(biāo)簽頁) | 默認(rèn)關(guān)閉 |
華為榮耀 3c 電信版 | 4.3 | 是 | 跳轉(zhuǎn)至通知中心尉辑,但默認(rèn)是開啟懸浮窗的 | 默認(rèn)關(guān)閉 |
華為 G520 | 4.1.2 | 否 | 直接點(diǎn)擊華為跳轉(zhuǎn)設(shè)置頁按鈕帆精,閃退 | 默認(rèn)開啟 |
結(jié)論:
匯總結(jié)果 | 完全兼容機(jī)型數(shù)量 | 次兼容機(jī)型數(shù)量 | 總測(cè)試機(jī)型數(shù) | 兼容成功率 |
---|---|---|---|---|
華為6.0以下機(jī)型覆蓋:18款,其中: 5.0.1以上:11款隧魄,均默認(rèn)開啟卓练,且跳轉(zhuǎn)設(shè)置頁面正確;5.0:1款购啄,處理異常 (默認(rèn)未開啟懸浮窗權(quán)限襟企,且點(diǎn)擊跳轉(zhuǎn)至通知欄,非懸浮窗設(shè)置入口) 4.4.4狮含、4.4.2:3款顽悼,處理可接受 (默認(rèn)未開啟懸浮窗權(quán)限曼振,點(diǎn)擊跳轉(zhuǎn)至通知中心的“通知欄”標(biāo)簽頁,可手動(dòng)切換至“懸浮窗”標(biāo)簽頁設(shè)置) 4.3:1款蔚龙,處理可接受 (默認(rèn)開啟冰评,但點(diǎn)擊華為跳轉(zhuǎn)設(shè)置頁,跳轉(zhuǎn)至通知中心木羹,無懸浮窗設(shè)置處) 4.2.2:1款甲雅,默認(rèn)開啟,處理正常 4.1.2:1款坑填,處理有瑕疵 (默認(rèn)開啟务荆,但若直接點(diǎn)擊華為跳轉(zhuǎn)按鈕,出現(xiàn)閃退) |
12 | 5 | 18 | 94.44% |
正在適配中...</br>
xiaomi##
大部分的小米機(jī)型都是可以成功適配穷遂,除了某些奇怪的機(jī)型:
機(jī)型 | 版本 | 適配完成 | 具體表現(xiàn) |
---|---|---|---|
小米 MI 4S | 5.1.1 | 否 | 無懸浮窗權(quán)限函匕,點(diǎn)擊小米手機(jī)授權(quán)頁跳轉(zhuǎn)按鈕,無反應(yīng) |
小米 紅米NOTE 1S | 4.4.4 | 未執(zhí)行 | 未修改開啟懸浮窗成功蚪黑,真機(jī)平臺(tái)不支持(為權(quán)限與之前系統(tǒng)有別) |
小米 紅米1(聯(lián)通版) | 4.2.2 | 未執(zhí)行 | 未安裝成功 |
</br>
結(jié)論:
匯總結(jié)果 | 完全兼容機(jī)型數(shù)量 | 次兼容機(jī)型數(shù)量 | 總測(cè)試機(jī)型數(shù) | 兼容成功率 |
---|---|---|---|---|
小米6.0以下機(jī)型覆蓋:10款盅惜,其中: 5.1.1 小米 MI 4S:1款,兼容失敗 (默認(rèn)未開啟忌穿,點(diǎn)擊小米手機(jī)授權(quán)按鈕抒寂,無跳轉(zhuǎn)) 其他:9款,均成功 |
9 | 0 | 10 | 90% |
samsung##
幾乎 100% 的機(jī)型都是配完美掠剑,結(jié)論:
匯總結(jié)果 | 完全兼容機(jī)型數(shù)量 | 次兼容機(jī)型數(shù)量 | 總測(cè)試機(jī)型數(shù) | 兼容成功率 |
---|---|---|---|---|
三星6.0以下機(jī)型覆蓋:28款屈芜,全部檢測(cè)處理成功 (默認(rèn)均開啟懸浮窗權(quán)限) |
28 | 0 | 28 | 100% |
oppo&&vivo##
藍(lán)綠大廠的機(jī)器,只測(cè)試了幾款機(jī)型朴译,都是OK的:
機(jī)型 | 版本 | 適配完成 | 是否默認(rèn)開啟 |
---|---|---|---|
OPPO R7sm | 5.1.1 | 是 | 默認(rèn)開啟 |
OPPO R7 Plus | 5.0 | 是 | 默認(rèn)開啟 |
OPPO R7 Plus(全網(wǎng)通) | 5.1.1 | 是 | 默認(rèn)開啟 |
OPPO A37m | 5.1 | 未執(zhí)行 | 默認(rèn)未開啟井佑,且無法設(shè)置開啟(平臺(tái)真機(jī)限制修改權(quán)限導(dǎo)致) |
OPPO A59m | 5.1.1 | 是 | 默認(rèn)開啟 |
結(jié)論:</br>
匯總結(jié)果 |
---|
抽查3款,2個(gè)系統(tǒng)版本眠寿,均兼容躬翁,100% |
</br>
others##
其他的機(jī)型,HTC 和 Sony 大法之類的機(jī)器盯拱,隨機(jī)抽取了幾款盒发,也都是 OK 的:
機(jī)型 | 是否正常 |
---|---|
藍(lán)魔 R3 | 是 |
HTC A9 | 是 |
摩托羅拉 Nexus 6 | 是 |
VIVO V3Max A | 是 |
金立 M5 | 是 |
HTC One E8 | 是 |
努比亞 Z11 Max | 是 |
Sony Xperia Z3+ Dual | 是 |
酷派 大神Note3 | 是 |
三星 GALAXY J3 Pro(雙4G) | 是 |
三星 Note 5 | 是 |
中興 威武3 | 是 |
中興 Axon Mini | 是 |
結(jié)論</br>
匯總結(jié)果 |
---|
隨機(jī)抽查看13款,全部測(cè)試正常狡逢,100% |
源碼下載#
https://github.com/zhaozepeng/FloatWindowPermission
引用#
http://www.reibang.com/p/167fd5f47d5c
http://www.liaohuqiu.net/cn/posts/android-windows-manager/
http://blog.csdn.net/mzm489321926/article/details/50542065
http://www.reibang.com/p/634cd056b90c