|
@@ -4,48 +4,55 @@ import android.content.ComponentName;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.SystemProperties;
|
|
|
+import android.provider.Settings;
|
|
|
import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.ImageButton;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.xplora.xpsettings.R;
|
|
|
|
|
|
-public class BlackDoorPasswordActivity extends BaseActivity {
|
|
|
- public String mInput = "";
|
|
|
+public class BlackDoorActivity extends BasePasswordActivity {
|
|
|
+ private RelativeLayout mLockLayout = null;
|
|
|
private TextView mTextView1 = null;
|
|
|
- private TextView mTextView2 = null;
|
|
|
- private TextView mTextView3 = null;
|
|
|
- private TextView mTextView4 = null;
|
|
|
- View.OnClickListener mOnClickListener = v -> {
|
|
|
- int tag = Integer.parseInt((String) v.getTag());
|
|
|
- if (tag == 100) {
|
|
|
- actionBack();
|
|
|
- } else if (tag == 101) {
|
|
|
- actionOK();
|
|
|
- } else {
|
|
|
- if (mInput.length() >= 4)
|
|
|
- return;
|
|
|
- mInput += tag;
|
|
|
- showPinCode();
|
|
|
- }
|
|
|
- };
|
|
|
- private final int subID = 0;
|
|
|
- private final String mSavePin = "";
|
|
|
- private final int mPinOrPuk = 1; //1:pin 2:puk
|
|
|
+ public String mInput = "";
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_blackdoor_password);
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
- mTextView1 = findViewById(R.id.text1);
|
|
|
- mTextView2 = findViewById(R.id.text2);
|
|
|
- mTextView3 = findViewById(R.id.text3);
|
|
|
- mTextView4 = findViewById(R.id.text4);
|
|
|
|
|
|
+ resetAfterTimeout(false);
|
|
|
+ initInputView();
|
|
|
+ refreshLockView();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void refreshLockView() {
|
|
|
+ if (!isLock())
|
|
|
+ return;
|
|
|
+ long minutes = getLeftTime() / 60;
|
|
|
+ long second = getLeftTime() % 60;
|
|
|
+ long time = minutes + (second > 0 ? 1 : 0);
|
|
|
+ String content = getString(R.string.bd_3_content, time);
|
|
|
+
|
|
|
+ mLockLayout = findViewById(R.id.lockLayout);
|
|
|
+ TextView errorContent = findViewById(R.id.mErrorContent);
|
|
|
+ Button button = findViewById(R.id.mErrorBtn);
|
|
|
+
|
|
|
+ mLockLayout.setVisibility(View.VISIBLE);
|
|
|
+ errorContent.setText(content);
|
|
|
+ button.setOnClickListener((e)-> {
|
|
|
+ finish();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initInputView() {
|
|
|
+ mTextView1 = findViewById(R.id.text1);
|
|
|
Button button1 = findViewById(R.id.button1);
|
|
|
Button button2 = findViewById(R.id.button2);
|
|
|
Button button3 = findViewById(R.id.button3);
|
|
@@ -58,7 +65,6 @@ public class BlackDoorPasswordActivity extends BaseActivity {
|
|
|
Button button0 = findViewById(R.id.button0);
|
|
|
ImageButton buttonOK = findViewById(R.id.buttonOK);
|
|
|
ImageButton buttonBack = findViewById(R.id.buttonBack);
|
|
|
-
|
|
|
button1.setOnClickListener(mOnClickListener);
|
|
|
button2.setOnClickListener(mOnClickListener);
|
|
|
button3.setOnClickListener(mOnClickListener);
|
|
@@ -73,11 +79,22 @@ public class BlackDoorPasswordActivity extends BaseActivity {
|
|
|
buttonBack.setOnClickListener(mOnClickListener);
|
|
|
}
|
|
|
|
|
|
+ View.OnClickListener mOnClickListener = v -> {
|
|
|
+ int tag = Integer.parseInt((String) v.getTag());
|
|
|
+ if (tag == 100) {
|
|
|
+ actionBack();
|
|
|
+ } else if (tag == 101) {
|
|
|
+ actionOK();
|
|
|
+ } else {
|
|
|
+// if (mInput.length() >= 6)
|
|
|
+// return;
|
|
|
+ mInput += tag;
|
|
|
+ showPinCode();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
private void showPinCode() {
|
|
|
- mTextView1.setText(mInput.length() >= 1 ? String.valueOf(mInput.charAt(0)) : "");
|
|
|
- mTextView2.setText(mInput.length() >= 2 ? String.valueOf(mInput.charAt(1)) : "");
|
|
|
- mTextView3.setText(mInput.length() >= 3 ? String.valueOf(mInput.charAt(2)) : "");
|
|
|
- mTextView4.setText(mInput.length() >= 4 ? String.valueOf(mInput.charAt(3)) : "");
|
|
|
+ mTextView1.setText(mInput);
|
|
|
}
|
|
|
|
|
|
private void actionBack() {
|
|
@@ -87,52 +104,15 @@ public class BlackDoorPasswordActivity extends BaseActivity {
|
|
|
showPinCode();
|
|
|
}
|
|
|
|
|
|
- private static final String DICTIONARY = "5127940836";
|
|
|
- // type 0: test tool
|
|
|
- // type 1: log tool
|
|
|
- private String getPwd(int type) {
|
|
|
- String imei = SystemProperties.get("persist.zs.imei.number", "");
|
|
|
- if (imei.isEmpty()) {
|
|
|
- if (type == 0)
|
|
|
- return "1123";
|
|
|
- else
|
|
|
- return "2234";
|
|
|
- }
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- String imei_sub;
|
|
|
- if (type == 0) {
|
|
|
- imei_sub = imei.substring(4, 12);
|
|
|
- } else {
|
|
|
- imei_sub = imei.substring(6, 14);
|
|
|
- }
|
|
|
- for (int i = 0; i < imei.length(); i = i + 2) {
|
|
|
- int index = Integer.parseInt(String.valueOf(imei_sub.charAt(i)));
|
|
|
- sb.append(DICTIONARY.charAt(index));
|
|
|
- if (sb.length() == 4) break;
|
|
|
- }
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
-
|
|
|
- private String getBackBackDoor() {
|
|
|
- String imei = SystemProperties.get("persist.zs.imei.number", "");
|
|
|
- if (imei.isEmpty()) {
|
|
|
- return "1123";
|
|
|
- }
|
|
|
- String sub = imei.substring(imei.length() - 4);
|
|
|
- StringBuilder sb = new StringBuilder(sub).reverse();
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
-
|
|
|
private void actionOK() {
|
|
|
int entry = getIntent().getIntExtra("from", 1);
|
|
|
- String pwdTestTool = getPwd(0);
|
|
|
- String pwdLogTool = getPwd(1);
|
|
|
- String pwdBackBackDoor = getBackBackDoor();
|
|
|
- if ((mInput.equals(pwdTestTool) && entry == 0) || mInput.equals(pwdBackBackDoor)) {
|
|
|
- Intent intent = new Intent(BlackDoorPasswordActivity.this, TestToolsActivity.class);
|
|
|
+ if (entry == 0 && checkTestPassword (mInput)) {
|
|
|
+ resetAfterTimeout(true);
|
|
|
+ Intent intent = new Intent(BlackDoorActivity.this, TestToolsActivity.class);
|
|
|
startActivity(intent);
|
|
|
finish();
|
|
|
- } else if (mInput.equals(pwdLogTool) && entry == 1) {
|
|
|
+ } else if (entry == 1 && checkLogPassword(mInput)) {
|
|
|
+ resetAfterTimeout(true);
|
|
|
Intent intent = new Intent();
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
intent.setComponent(new ComponentName(
|
|
@@ -142,6 +122,9 @@ public class BlackDoorPasswordActivity extends BaseActivity {
|
|
|
startActivity(intent);
|
|
|
finish();
|
|
|
} else {
|
|
|
+ mInput = "";
|
|
|
+ showPinCode();
|
|
|
+ addError();
|
|
|
Toast toast = Toast.makeText(this, getString(R.string.blackdoor_password_error), Toast.LENGTH_SHORT);
|
|
|
toast.show();
|
|
|
}
|