Android Security PIN 相关代码

开发项目遇到一个问题,具体描述及复制步骤如下:

就是开启"Enhanced PIN privacy"(增强的PIN隐私)的时候输入秘密的时候还是会显示数字
如下图,应该是直接是“.” 不应该出现PIN 密码

想要的效果如下图:

设置的步骤如下图:

其中涉及到的部分code如下:

/frameworks/base/core/java/com/android/internal/widget/LockPatternUtils.java
/frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java

/frameworks/base/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java

/frameworks/base/services/core/java/com/android/server/locksettings/LockSettingsStorage.java

I.LockPatternUtils.java:

/*** @return Whether enhanced pin privacy is enabled.*/public boolean isPinEnhancedPrivacyEnabled(int userId) {return getBoolean(LOCK_PIN_ENHANCED_PRIVACY, false, userId);}/*** Set whether enhanced pin privacy is enabled.*/public void setPinEnhancedPrivacyEnabled(boolean enabled, int userId) {setBoolean(LOCK_PIN_ENHANCED_PRIVACY, enabled, userId);}private boolean getBoolean(String secureSettingKey, boolean defaultValue, int userId) {Log.i("TD","LockPatternUtils----->getBoolean: "+secureSettingKey);try {return getLockSettings().getBoolean(secureSettingKey, defaultValue, userId);} catch (RemoteException re) {return defaultValue;}}private void setBoolean(String secureSettingKey, boolean enabled, int userId) {Log.i("TD","LockPatternUtils----->setsetBoolean: "+secureSettingKey);try {getLockSettings().setBoolean(secureSettingKey, enabled, userId);} catch (RemoteException re) {// What can we do?Log.e(TAG, "Couldn't write boolean " + secureSettingKey + re);}}

II.KeyguardPinBasedInputViewController.java

protected void onViewAttached() {super.onViewAttached();Log.i("TD","KeyguardPinBasedInputViewController------------->onViewAttached");boolean showAnimations = !mLockPatternUtils.isPinEnhancedPrivacyEnabled(KeyguardUpdateMonitor.getCurrentUser());mPasswordEntry.setShowPassword(showAnimations);for (NumPadKey button : mView.getButtons()) {button.setOnTouchListener((v, event) -> {if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {mFalsingCollector.avoidGesture();}return false;});button.setAnimationEnabled(showAnimations);}mPasswordEntry.setOnKeyListener(mOnKeyListener);mPasswordEntry.setUserActivityListener(this::onUserInput);View deleteButton = mView.findViewById(R.id.delete_button);deleteButton.setOnTouchListener(mActionButtonTouchListener);deleteButton.setOnClickListener(v -> {// check for time-based lockoutsLog.i("TD","KeyguardPinBasedInputViewController------------->deleteButton");if (mPasswordEntry.isEnabled()) {mPasswordEntry.deleteLastChar();}});deleteButton.setOnLongClickListener(v -> {// check for time-based lockoutsif (mPasswordEntry.isEnabled()) {mView.resetPasswordText(true /* animate */, true /* announce */);}Log.i("TD","KeyguardPinBasedInputViewController------------->deleteButton#longPress");mView.doHapticKeyClick();return true;});View okButton = mView.findViewById(R.id.key_enter);if (okButton != null) {okButton.setOnTouchListener(mActionButtonTouchListener);okButton.setOnClickListener(v -> {Log.i("TD","KeyguardPinBasedInputViewController------------->okButton");if (mPasswordEntry.isEnabled()) {verifyPasswordAndUnlock();}});okButton.setOnHoverListener(mLiftToActivateListener);}}

III.LockSettingsStorage.java
Pattern 的加密也会走到这边

public void setBoolean(String key, boolean value, int userId) {Log.i("TD","LockSettingsStorage*******>setBoolean-=-key is: "+key + "  **value: "+value);setString(key, value ? "1" : "0", userId);}public void setString(String key, String value, int userId) {Preconditions.checkArgument(userId != USER_FRP, "cannot store lock settings for FRP user");writeKeyValue(key, value, userId);if (ArrayUtils.contains(SETTINGS_TO_BACKUP, key)) {BackupManager.dataChanged("com.android.providers.settings");}}public void writeKeyValue(String key, String value, int userId) {writeKeyValue(mOpenHelper.getWritableDatabase(), key, value, userId);}@VisibleForTestingpublic void writeKeyValue(SQLiteDatabase db, String key, String value, int userId) {Log.i("TD","LockSettingsService---->writeKeyValue");Log.i("TD","LockSettingsService---->COLUMN_KEY: "+key);Log.i("TD","LockSettingsService---->COLUMN_USERID: "+userId);Log.i("TD","LockSettingsService---->COLUMN_VALUE: "+value);ContentValues cv = new ContentValues();cv.put(COLUMN_KEY, key);cv.put(COLUMN_USERID, userId);cv.put(COLUMN_VALUE, value);db.beginTransaction();try {db.delete(TABLE, COLUMN_KEY + "=? AND " + COLUMN_USERID + "=?",new String[] {key, Integer.toString(userId)});db.insert(TABLE, null, cv);db.setTransactionSuccessful();mCache.putKeyValue(key, value, userId);} finally {db.endTransaction();}dispatchChange(this);}    

IV.PasswordTextView.java

private void startDotAppearAnimation(long delay) {cancelAnimator(dotAnimator);if (!mShowPassword) {// We perform an overshoot animationValueAnimator overShootAnimator = ValueAnimator.ofFloat(currentDotSizeFactor,DOT_OVERSHOOT_FACTOR);overShootAnimator.addUpdateListener(dotSizeUpdater);overShootAnimator.setInterpolator(mAppearInterpolator);long overShootDuration = (long) (DOT_APPEAR_DURATION_OVERSHOOT* OVERSHOOT_TIME_POSITION);overShootAnimator.setDuration(overShootDuration);ValueAnimator settleBackAnimator = ValueAnimator.ofFloat(DOT_OVERSHOOT_FACTOR,1.0f);settleBackAnimator.addUpdateListener(dotSizeUpdater);settleBackAnimator.setDuration(DOT_APPEAR_DURATION_OVERSHOOT - overShootDuration);settleBackAnimator.addListener(dotFinishListener);AnimatorSet animatorSet = new AnimatorSet();animatorSet.playSequentially(overShootAnimator, settleBackAnimator);animatorSet.setStartDelay(delay);animatorSet.start();dotAnimator = animatorSet;} else {ValueAnimator growAnimator = ValueAnimator.ofFloat(currentDotSizeFactor, 1.0f);growAnimator.addUpdateListener(dotSizeUpdater);growAnimator.setDuration((long) (APPEAR_DURATION * (1.0f - currentDotSizeFactor)));growAnimator.addListener(dotFinishListener);growAnimator.setStartDelay(delay);growAnimator.start();dotAnimator = growAnimator;}dotAnimationIsGrowing = true;}
void startAppearAnimation() {boolean dotNeedsAnimation = !mShowPassword&& (dotAnimator == null || !dotAnimationIsGrowing);boolean textNeedsAnimation = mShowPassword&& (textAnimator == null || !textAnimationIsGrowing);boolean widthNeedsAnimation = (widthAnimator == null || !widthAnimationIsGrowing);if (dotNeedsAnimation) {startDotAppearAnimation(0);}if (textNeedsAnimation) {startTextAppearAnimation();}if (widthNeedsAnimation) {startWidthAppearAnimation();}if (mShowPassword) {postDotSwap(TEXT_VISIBILITY_DURATION);}}

出现问题的地方就是下面代码注释的部分,这个值为True.

 public void append(char c) {if (ZTelephonyManagerCommon.IS_ZEBRA_WWAN&& (mPasswordMaxSize != -1)&& (mText.length() >= mPasswordMaxSize)) {return;}int visibleChars = mTextChars.size();CharSequence textbefore = getTransformedText();mText = mText + c;int newLength = mText.length();CharState charState;if (newLength > visibleChars) {charState = obtainCharState(c);mTextChars.add(charState);} else {charState = mTextChars.get(newLength - 1);charState.whichChar = c;}//        if (XXX.orElse(false)) {
//            mShowPassword = Settings.System.getInt(mContext.getContentResolver(),
//                    Settings.System.TEXT_SHOW_PASSWORD, 1) == 1;
//        }Log.i("TD","mShowPassword--------->"+Settings.System.getInt(mContext.getContentResolver(),Settings.System.TEXT_SHOW_PASSWORD, 1));charState.startAppearAnimation();// ensure that the previous element is being swappedif (newLength > 1) {CharState previousState = mTextChars.get(newLength - 2);if (previousState.isDotSwapPending) {previousState.swapToDotWhenAppearFinished();}}userActivity();sendAccessibilityEventTypeViewTextChanged(textbefore, textbefore.length(), 0, 1);}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/582410.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

RabbitMQ 和 Kafka 对比

本文对RabbitMQ 和 Kafka 进行下比较 文章目录 前言RabbitMQ架构队列消费队列生产 Kafka本文小结 前言 开源社区有好多优秀的队列中间件,比如RabbitMQ和Kafka,每个队列都貌似有其特性,在进行工程选择时,往往眼花缭乱,不…

多态-多态的基本概念-类和对象

多态的基本 #include<iostream> using namespace std; //动物类 class Animal { public:virtual void Speak(){cout << " 动物在噢噢叫" << endl;} }; //猫类 class Cat :public Animal { public:void Speak(){cout << "小猫在噢噢叫&…

C++系列-第3章循环结构-26-认识do-while语句

C系列-第3章循环结构-26-认识do-while语句 在线练习&#xff1a; http://noi.openjudge.cn/ https://www.luogu.com.cn/ 对于 while 语句而言&#xff0c;如果不满足条件&#xff0c;则不能进入循环。但有时候我们需要即使不满足条件&#xff0c;也至少执行一次。 do-while循环…

购买腾讯云服务器需要多少钱?购买腾讯云服务器方法教程

腾讯云轻量应用服务器购买指南&#xff0c;有两个入口&#xff0c;一个是在特价活动上购买&#xff0c;一个是在轻量应用服务器官方页面购买&#xff0c;特价活动上购买价格更便宜&#xff0c;轻量2核2G3M带宽服务器62元一年起&#xff0c;阿腾云atengyun.com分享腾讯云轻量应用…

算法导论复习纲要

函数 1. 上界下界&#xff0c;紧确界的定义 2. 求解递推式&#xff0c;代入法&#xff0c;递归树法&#xff0c;主方法 分治算法 动态规划 1. 切割钢条&#xff1a;递归方法&#xff0c;动态的自上而下&#xff0c; 2. 矩阵乘法&#xff1a;最优子结构性的证明&#xff0c…

Go语言学习

1、运行和解析 go run 命令已包含了编译和运行。它会先在一个临时目录编译程序&#xff0c;然后执行完后清理掉. 如果在run的后面加上 --work参数来查看临时目录。 go run --work main.go也可以通过go build命令来编译代码&#xff0c;执行后会生成一个可以执行文件&#xff…

如何本地部署Nextcloud结合cpolar搭建专属私有云盘远程访问(内网穿透)

文章目录 摘要1. 环境搭建2. 测试局域网访问3. 内网穿透3.1 ubuntu本地安装cpolar3.2 创建隧道3.3 测试公网访问 4 配置固定http公网地址4.1 保留一个二级子域名4.1 配置固定二级子域名4.3 测试访问公网固定二级子域名 摘要 Nextcloud,它是ownCloud的一个分支,是一个文件共享服…

算法设计与分析 | 矩阵连乘

题目描述 一个n*m矩阵由n行m列共n*m个数排列而成。两个矩阵A和B可以相乘当且仅当A的列数等于B的行数。一个N*M的矩阵乘以一个M*P的矩阵等于一个N*P的矩阵&#xff0c;运算量为nmp。 矩阵乘法满足结合律&#xff0c;A*B*C可以表示成(A*B)*C或者是A*(B*C)&#xff0c;两者的运算…

什么是https证书?

HTTPS证书&#xff0c;也称为SSL&#xff08;Secure Sockets Layer&#xff09;证书或TLS&#xff08;Transport Layer Security&#xff09;证书&#xff0c;是一种数字证书&#xff0c;用于在网络上建立安全的加密连接。它的主要目的是确保在互联网上进行的数据传输的安全性和…

Android : 画布绘制矩形和文字 让其居中显示简单应用

示例图&#xff1a; CenterView.java package com.example.demo;import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.Log; import android.view.View;public class Center…

openGauss学习笔记-175 openGauss 数据库运维-备份与恢复-导入数据-管理并发写入操作示例

文章目录 openGauss学习笔记-175 openGauss 数据库运维-备份与恢复-导入数据-管理并发写入操作示例175.1 相同表的INSERT和DELETE并发175.2 相同表的并发INSERT175.3 相同表的并发UPDATE175.4 数据导入和查询的并发 openGauss学习笔记-175 openGauss 数据库运维-备份与恢复-导入…

训练和测试的loss、accuracy等数据保存到文件并读出

首先是写文件到excel import os.path from openpyxl import load_workbook import pandas as pd import matplotlib.pyplot as pltdef write_excel(excel_name, sheet_name, value):columns ["epoc", "train_loss", "train_acc", "test_a…

idea Spring Boot项目使用JPA创建与数据库链接

1.pom.xml文件中添加依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency><groupId>com.mysql</groupId><artifactId>…

创建和配置Spring MVC框架构建Web应用

1 认识Spring MVC Spring Web MVC是构建在Servlet API之上的Web框架&#xff0c;自诞生之时就被纳入了Spring框架中。其正式/官方名称为“Spring Web MVC”&#xff0c;源自其所属的模块&#xff08;spring-webmvc&#xff09;&#xff0c;但通常被称为“Spring MVC”。 1.1…

最短路径(数据结构实训)(难度系数100)

最短路径 描述&#xff1a; 已知一个城市的交通路线&#xff0c;经常要求从某一点出发到各地方的最短路径。例如有如下交通图&#xff1a; 则从A出发到各点的最短路径分别为&#xff1a; B&#xff1a;0 C&#xff1a;10 D&#xff1a;50 E&#xff1a;30 F&#xff1a;60 输…

go 源码解读 - sync.Mutex

sync.Mutex mutex简介mutex 方法源码标志位获取锁LocklockSlowUnlock怎么 调度 goroutineruntime 方法 mutex简介 mutex 是 一种实现互斥的同步原语。&#xff08;go-version 1.21&#xff09; &#xff08;还涉及到Go运行时的内部机制&#xff09;mutex 方法 Lock() 方法用于…

网盘项目话术(0.5w字精选)

功能结构图 数据库设计总结 该项目主要就是对文件的操作&#xff0c;file表&#xff0c;file_share表。 file表主要字段&#xff1a;id&#xff0c;用户id&#xff0c;父级目录id&#xff0c;文件的地址&#xff0c;文件的封面图片地址&#xff0c;创建和修改时间。 file_sha…

国际物流公司科普_集装箱种类区分和介绍_箱讯科技

集装箱运输的不断发展&#xff0c;为适应装载不同种类货物的需要&#xff0c;因而出现了不同种类的集装箱。今天和大家一起来总结一下。 按使用材料分类 根据箱子主体部件&#xff08;侧壁、端壁、箱顶等&#xff09;采用什么材料&#xff0c;就叫做什么材料制造的集装箱&…

TPRI-DMP平台介绍

TPRI-DMP平台介绍 TPRI-DMP平台概述 TPRI-DMP为华能集团西安热工院自主产权的工业云PaaS平台&#xff0c;已经过13年的发展和迭代&#xff0c;其具备大规模能源电力行业生产应用软件开发和运行能力。提供TPRI-DMP平台主数据管理、业务系统开发与运行、应用资源管理与运维监控…

【数据结构】C语言实现单链表的基本操作

单链表基本操作的实现 导言一、查找操作1.1 按位查找1.1.1 按位查找的C语言实现1.1.2 按位查找的时间复杂度 1.2 按值查找1.2.1 按值查找的C语言实现1.2.2 按值查找的时间复杂度 二、插入操作2.1 后插操作2.2 前插操作 三、删除操作结语 导言 大家好&#xff0c;很高兴又和大家…