首页 » 软件开发 » 「Android R」「MTK」进入开发者模式菜单的时候增加密码框(增加密码开发者模式文件)

「Android R」「MTK」进入开发者模式菜单的时候增加密码框(增加密码开发者模式文件)

乖囧猫 2024-07-24 16:51:43 0

扫一扫用手机浏览

文章目录 [+]

修改文件:vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java

//增加声明import android.app.AlertDialog;import android.content.DialogInterface;import android.text.Editable;import android.text.InputType;import android.text.Selection;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.CheckBox;import android.widget.CompoundButton;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;...... //设定固定密码 private static final String PASSWORD = "1234"; @Override public boolean onPreferenceTreeClick(Preference preference) { android.util.Log.d(TAG, "Hexh preference:" + preference.getKey()); if (preference.getKey().contains("DevelopmentSettingsDashboardActivity")) { showPasswdDialog(preference); return true; } return super.onPreferenceTreeClick(preference); } private void showPasswdDialog(final Preference preference) { android.util.Log.d("DevelopmentSettingsActivity", "showPasswdDialog"); final View view = getLayoutInflater().inflate(R.layout.dialog_develop_password, null, false); final EditText password = (EditText) view.findViewById(R.id.password); final CheckBox showPasswd = (CheckBox) view.findViewById(R.id.show_password); showPasswd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { password.setInputType(InputType.TYPE_CLASS_NUMBER | (isChecked ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : InputType.TYPE_NUMBER_VARIATION_PASSWORD)); Editable etable = password.getText(); Selection.setSelection(etable, etable.length()); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()) .setTitle(R.string.crypt_keeper_enter_password) .setView(view) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (password.getText().toString().equals(PASSWORD)) { SystemDashboardFragment.super.onPreferenceTreeClick(preference); } else { Toast.makeText(SystemDashboardFragment.this.getContext(), R.string.lockpassword_invalid_password, Toast.LENGTH_SHORT).show(); } } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); } ......

新增文件:vendor/mediatek/proprietary/packages/apps/MtkSettings/res/layout/dialog_develop_password.xml

<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="24dp"> <TextView android:text="@string/wifi_password" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <EditText android:id="@+id/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberPassword" android:maxLength="8"/> <CheckBox android:id="@+id/show_password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/show_password" /> </LinearLayout></ScrollView>

Android O,P版本可能会有点差别。
主要是要找到system界面中点击开发者模式的位置,然后就好下手了。

「Android R」「MTK」进入开发者模式菜单的时候增加密码框(增加密码开发者模式文件) 软件开发
(图片来自网络侵删)
标签:

相关文章

语言中的借用,文化交融的桥梁

自古以来,人类社会的交流与发展离不开语言的传播。在漫长的历史长河中,各民族、各地区之间的文化相互碰撞、交融,产生了许多独特的语言现...

软件开发 2025-01-01 阅读1 评论0

机顶盒协议,守护数字生活的新卫士

随着科技的飞速发展,数字家庭逐渐走进千家万户。在这个时代,机顶盒成为了连接我们与丰富多彩的数字世界的重要桥梁。而机顶盒协议,作为保...

软件开发 2025-01-01 阅读1 评论0

语言基础在现代社会的重要性及方法步骤

语言是人类沟通的桥梁,是社会发展的基础。语言基础作为语言学习的基石,对于个人、社会乃至国家的发展具有重要意义。本文将从语言基础在现...

软件开发 2025-01-01 阅读2 评论0

粤语电影,传承文化,点亮时代之光

粤语电影,作为中国电影产业的一朵奇葩,以其独特的地域特色、丰富的文化内涵和鲜明的艺术风格,赢得了广大观众的喜爱。本文将从粤语电影的...

软件开发 2025-01-01 阅读5 评论0

苹果游戏语言,塑造未来娱乐体验的基石

随着科技的飞速发展,游戏产业逐渐成为全球娱乐市场的重要支柱。在我国,游戏产业更是蓬勃发展,吸引了无数玩家和投资者的目光。而在这其中...

软件开发 2025-01-01 阅读1 评论0