Skip to content

Commit bb5fd77

Browse files
committed
增加qq版本判断
1 parent 03ae0a7 commit bb5fd77

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

app/src/main/java/com/yyxx/wechatfp/Lang.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public class Lang {
9090
public static final int TOAST_GOTO_DONATE_PAGE_FAIL_ALIPAY = 0x01000014;
9191
public static final int TOAST_GOTO_DONATE_PAGE_FAIL_WECHAT = 0x01000015;
9292
public static final int TOAST_GOTO_DONATE_PAGE_FAIL_QQ = 0x01000016;
93+
public static final int TOAST_NEED_QQ_7_2_5 = 0x01000017;
9394

9495
private static final int TEMPLATE = 0xFFFFFFFF;
9596

@@ -218,6 +219,8 @@ public static String getString(int res) {
218219
return tr("调用微信捐赠页失败, 您可以手动转账捐赠哦, 帐号: " + Constant.AUTHOR_WECHAT, "調用微信捐贈頁失敗, 您可以手動轉賬捐贈哦, 帳號: " + Constant.AUTHOR_WECHAT, "Can't jump to WeChat donate page, You can do it manually by transfer to account: " + Constant.AUTHOR_WECHAT);
219220
case TOAST_GOTO_DONATE_PAGE_FAIL_QQ:
220221
return tr("调用QQ捐赠页失败, 您可以手动转账捐赠哦, 帐号: " + Constant.AUTHOR_QQ, "調用QQ捐贈頁失敗, 您可以手動轉賬捐贈哦, 帳號: " + Constant.AUTHOR_QQ, "Can't jump to QQ donate page, You can do it manually by transfer to account: " + Constant.AUTHOR_QQ);
222+
case TOAST_NEED_QQ_7_2_5:
223+
return tr("您的QQ版本过低, 不支持指纹功能, 请升级至7.2.5以上的版本", "您的QQ版本過低, 不支持指紋功能, 請升級至7.2.5以上的版本", "Your QQ version is too low, does not support the fingerprint function, please upgrade to version 7.2.5 and above");
221224
case TEMPLATE:
222225
return tr("", "", "");
223226
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.yyxx.wechatfp.util;
2+
3+
import android.content.Context;
4+
import android.content.pm.PackageManager;
5+
import android.os.Build;
6+
import android.os.Process;
7+
import android.support.v4.app.AppOpsManagerCompat;
8+
9+
import static android.support.v4.content.PermissionChecker.checkSelfPermission;
10+
11+
/**
12+
* Created by Jason on 2017/11/12.
13+
*/
14+
15+
public class PermissionUtils {
16+
17+
public static boolean hasFingerprintPermission(Context context) {
18+
return hasSelfPermission(context, "android.permission.USE_FINGERPRINT")
19+
|| hasSelfPermission(context, "com.fingerprints.service.ACCESS_FINGERPRINT_MANAGER")
20+
|| hasSelfPermission(context, "com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY")
21+
;
22+
}
23+
24+
/**
25+
* Returns true if the Activity or Fragment has access to all given permissions.
26+
*
27+
* @param context context
28+
* @param permissions permission list
29+
* @return returns true if the Activity or Fragment has access to all given permissions.
30+
*/
31+
public static boolean hasSelfPermissions(Context context, String... permissions) {
32+
for (String permission : permissions) {
33+
if (!hasSelfPermission(context, permission)) {
34+
return false;
35+
}
36+
}
37+
return true;
38+
}
39+
40+
/**
41+
* Determine context has access to the given permission.
42+
* <p>
43+
* This is a workaround for RuntimeException of Parcel#readException.
44+
* For more detail, check this issue https://github.com/hotchemi/PermissionsDispatcher/issues/107
45+
*
46+
* @param context context
47+
* @param permission permission
48+
* @return returns true if context has access to the given permission, false otherwise.
49+
* @see #hasSelfPermissions(Context, String...)
50+
*/
51+
private static boolean hasSelfPermission(Context context, String permission) {
52+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && "Xiaomi".equalsIgnoreCase(Build.MANUFACTURER)) {
53+
return hasSelfPermissionForXiaomi(context, permission);
54+
}
55+
try {
56+
return checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
57+
} catch (RuntimeException t) {
58+
return false;
59+
}
60+
}
61+
62+
private static boolean hasSelfPermissionForXiaomi(Context context, String permission) {
63+
String permissionToOp = AppOpsManagerCompat.permissionToOp(permission);
64+
if (permissionToOp == null) {
65+
// in case of normal permissions(e.g. INTERNET)
66+
return true;
67+
}
68+
int noteOp = AppOpsManagerCompat.noteOp(context, permissionToOp, Process.myUid(), context.getPackageName());
69+
return noteOp == AppOpsManagerCompat.MODE_ALLOWED && checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
70+
}
71+
}

app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedQQPlugin.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.yyxx.wechatfp.util.DpUtil;
3333
import com.yyxx.wechatfp.util.ImageUtil;
3434
import com.yyxx.wechatfp.util.KeyboardUtils;
35+
import com.yyxx.wechatfp.util.PermissionUtils;
3536
import com.yyxx.wechatfp.util.StyleUtil;
3637
import com.yyxx.wechatfp.util.Task;
3738
import com.yyxx.wechatfp.util.Tools;
@@ -404,8 +405,13 @@ public void onStartFailedByDeviceLocked() {
404405
}
405406
});
406407
} else {
407-
L.d("系统指纹功能未启用");
408-
Toast.makeText(context, Lang.getString(Lang.TOAST_FINGERPRINT_NOT_ENABLE), Toast.LENGTH_SHORT).show();
408+
if (PermissionUtils.hasFingerprintPermission(context)) {
409+
L.d("系统指纹功能未启用");
410+
Toast.makeText(context, Lang.getString(Lang.TOAST_FINGERPRINT_NOT_ENABLE), Toast.LENGTH_LONG).show();
411+
} else {
412+
L.d("QQ 版本过低");
413+
Toast.makeText(context, Lang.getString(Lang.TOAST_NEED_QQ_7_2_5), Toast.LENGTH_LONG).show();
414+
}
409415
mMockCurrentUser = false;
410416
mFingerprintScanStateReady = false;
411417
}

0 commit comments

Comments
 (0)