jQuery鼠标指针特效

Android 11 UsbDebug 关于adb RSA 认证

user版本时默认打开adb RSA指纹密钥的 ,就是那个连接adb的时候弹出一个dialog让你确认的界面!

eng和userdebug 版本中关闭了adb RSA 指纹密钥认证.

注意:Google 现在强制要求在USER 版本中开启adb RSA 指纹认证,如果关闭,将无法通过Google CTS 测试

ro.adb.secure=1  adb RSA指纹打开
ro.adb.secure=0  adb RSA指纹关闭

ro.secure   ro.debuggable  (关于 root)

./frameworks/base/services/core/java/com/android/server/adb/AdbDebuggingManager.java
 	/**
     * This class will poll for a period of time for adbd to write the port
     * it connected to.
     *
     * TODO(joshuaduong): The port is being sent via system property because the adbd socket
     * (AdbDebuggingManager) is not created when ro.adb.secure=0. Thus, we must communicate the
     * port through different means. A better fix would be to always start AdbDebuggingManager, but
     * it needs to adjust accordingly on whether ro.adb.secure is set.
     */
//大意:如果ro.adb.secure=0 ,adb 连接不会走AdbDebuggingManager的流程


./frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
	/**
     * 允许adb debugging
     * @param allow whether the connection should be allowed
     * @param alwaysAllow whether subsequent requests from this key should be allowed without user consent
     */
    private void notifyService(boolean allow, boolean alwaysAllow) {
        try {
            IBinder b = ServiceManager.getService(ADB_SERVICE);
            IAdbManager service = IAdbManager.Stub.asInterface(b);
            if (allow) {
                service.allowDebugging(alwaysAllow, mKey);
            } else {
                service.denyDebugging();
            }
            mServiceNotified = true;
        } catch (Exception e) {
            Log.e(TAG, "Unable to notify Usb service", e);
        }
    }


./system/core/adb/daemon/main.cpp

static bool should_drop_privileges() {
	//是否可以root,drop_privileges 关于权限,降权
    // The properties that affect `adb root` and `adb unroot` are ro.secure and
    // ro.debuggable. In this context the names don't make the expected behavior
    // particularly obvious.
    //
    // ro.debuggable:
    //   Allowed to become root, but not necessarily the default. Set to 1 on
    //   eng and userdebug builds.
    //
    // ro.secure:
    //   Drop privileges by default. Set to 1 on userdebug and user builds.
    bool ro_secure = android::base::GetBoolProperty("ro.secure", true);
    bool ro_debuggable = __android_log_is_debuggable();

    // Drop privileges if ro.secure is set...
    bool drop = ro_secure;

    // ... except "adb root" lets you keep privileges in a debuggable build.
    std::string prop = android::base::GetProperty("service.adb.root", "");
    bool adb_root = (prop == "1");
    bool adb_unroot = (prop == "0");
    if (ro_debuggable && adb_root) {
        drop = false;
    }
    // ... and "adb unroot" lets you explicitly drop privileges.
    if (adb_unroot) {
        drop = true;
    }

    return drop;
}


//实际应用:改装RAS指纹认证弹窗
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
public class UsbDebuggingActivity extends AlertActivity
         ap.mView = checkbox;
         window.setCloseOnTouchOutside(false);

-        setupAlert();
+        //setupAlert();
+        alertDialog();
     }

+    //add text
+    private void alertDialog() {
+        AlertDialog.Builder builder = new AlertDialog.Builder(this);
+        final EditText editText = new EditText(this);
+        editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
+        editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
+        builder.setTitle(getString(R.string.usb_debugging_title));
+        builder.setView(editText);
+        builder.setCancelable(false);
+        builder.setPositiveButton(getString(R.string.usb_debugging_allow), new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialogInterface, int i) {
+                String str = editText.getText().toString().trim();
+                String pwd = SystemProperties.get("persist.xxx.xxx.pwd", "android");
+                if (str.equals(pwd)) {
+                    notifyService(true, false);
+                } else {
+                    notifyService(false, false);
+                }
+                finish();
+            }
+        });
+        builder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialogInterface, int i) {
+                finish();
+            }
+        });
+        builder.show();
+    }
+    //add text
+

android9.0默认打开adb调试以及默认授权RSA秘钥指纹弹框_adb rsa-CSDN博客

adbkey相关知识,以及利用它进行权限控制-CSDN博客

如何开启与关闭adb 的认证机制_adb auth-CSDN博客

adbkey相关知识,以及利用它进行权限控制-CSDN博客

Android系统 adb shell auth授权使用_adb授权-CSDN博客

关于dialog的小技巧

private void checkText(Context context) {
        final EditText editText = new EditText(context);
        //密码键盘
        editText.setInputType(InputType.TYPE_CLASS_NUMBER);
        editText.setTransformationMethod(new PasswordTransformationMethod());

        /*
        //清理焦点,显示输入法键盘
        editText.setFocusable(false);
        editText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                editText.setFocusableInTouchMode(true);
                editText.requestFocus();
                editText.requestFocusFromTouch();
                InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
            }
        });*/
        
        //dialog点击BUTTON_POSITIVE 不消失
        AlertDialog inputDialog = new AlertDialog.Builder(context).setCancelable(false)
                .setTitle("Please enter password")
                .setView(editText)
                .setPositiveButton(android.R.string.ok, null)
                .setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                        //输入法键盘隐藏
                        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
                    }
                }).create();

        inputDialog.show();
        inputDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
            String pwd = editText.getText().toString().trim();
            //todo
        });
    }
posted @ 2024-07-12 17:52  僵小七  阅读(78)  评论(0编辑  收藏  举报