微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 数据保护设置图案锁为某些形状时,重启手机后图案锁失效

数据保护设置图案锁为某些形状时,重启手机后图案锁失效

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
数据保护设置图案锁为某些形状时,重启手机后图案锁失效
[SOLUTION]
DataProtectionLockPatternUtils修改为如下:
package com.mediatek.dataprotection.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
public class DataProtectionLockPatternUtils {
private static final String TAG = "DataProtectionLockPatternUtils";
private Context mContext = null;
public DataProtectionLockPatternUtils(Context context) {
mContext = context;
}
public boolean saveLockPattern(String pattern) {
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(mContext);
SharedPreferences.Editor editor = prefs.edit();
if (pattern == null) {
editor.clear();
editor.coMMIt();
return true;
}
// final byte[] hash = LockPatternUtils.patternToHash(LockPatternUtils
// .stringToPattern(pattern));
editor.putString("password", pattern);
// editor.putString(arg0, arg1)
boolean result = editor.commit();
Log.d(TAG, "saveLockPattern...result " + result);
return result;
}
public boolean isPatternSet() {
Log.d(TAG, "isPatternSet...");
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(mContext);
String pattern = prefs.getString("password", null);
return pattern != null;
}
public boolean checkPattern(String pattern) {
Log.d(TAG, "checkPattern...");
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(mContext);
String oldPattern = prefs.getString("password", null);
return oldPattern.equals(pattern);
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top