浏览代码

优化暗门逻辑

losion.liu@sikey.com.cn 3 月之前
父节点
当前提交
d54d4ff0e7

+ 17 - 8
app/src/main/java/com/xplora/xpsettings/Activity/BasePasswordActivity.java

@@ -30,15 +30,15 @@ public class BasePasswordActivity extends BaseActivity {
     }
 
     protected boolean checkTestPassword(String value) {
-        boolean isDefault = (getImei().length() < 15 && value.equals(BD_PW_DEFAULT));
-        boolean isOK = value.equals(getPwd(0));
-        return isDefault || isOK;
+        return value.equals(getPwd(0));
     }
 
     protected boolean checkLogPassword(String value) {
-        boolean isDefault = (getImei().length() < 15 && value.equals(BD_PW_DEFAULT));
-        boolean isOK = value.equals(getPwd(1));
-        return isDefault || isOK;
+        return value.equals(getPwd(1));
+    }
+
+    protected boolean checkDefaultPassword(String value) {
+        return getImei().length() < 15 && value.equals(BD_PW_DEFAULT);
     }
 
     // type 0: test tool; type 1: log tool
@@ -47,8 +47,17 @@ public class BasePasswordActivity extends BaseActivity {
         if (imei.length() < 15) {
             return BD_PW_DEFAULT;
         } else {
-            imei = new StringBuilder(imei).reverse().toString();
-            int start = imei.charAt(0) - '0';
+            int start = 0;
+            if (type == 0) { //相加取模
+                int sum = 0;
+                for (int i = 0; i < imei.length(); i++) {
+                    sum += imei.charAt(i) - '0';
+                }
+                start = sum % 10;
+            } else { //翻转取第一位
+                imei = new StringBuilder(imei).reverse().toString();
+                start = imei.charAt(0) - '0';
+            }
             StringBuilder sb = new StringBuilder();
             sb.append(imei.charAt(start));
             sb.append(imei.charAt(start + 1));

+ 2 - 2
app/src/main/java/com/xplora/xpsettings/Activity/BlackDoorActivity.java

@@ -107,12 +107,12 @@ public class BlackDoorActivity extends BasePasswordActivity {
 
     private void actionOK() {
         int entry = getIntent().getIntExtra("from", 1);
-        if (entry == 0 && checkTestPassword (mInput)) {
+        if (entry == 0 && (checkTestPassword (mInput) || checkDefaultPassword(mInput))) {
             resetAfterTimeout(true);
             Intent intent = new Intent(BlackDoorActivity.this, TestToolsActivity.class);
             startActivity(intent);
             finish();
-        } else if (entry == 1 && checkLogPassword(mInput)) {
+        } else if (entry == 1 && (checkLogPassword(mInput) || checkDefaultPassword(mInput))) {
             resetAfterTimeout(true);
             Intent intent = new Intent();
             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);