MTK6757 9.0 USB debugger 默认打开, 开发者选项无法打开

一. USB debugger 默认打开

1. build\make\core\main.mk

将ro.debuggable 值改为1

ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1

2. frameworks\base\services\usb\java\com\android\server\usb\UsbDeviceManager.java

修改    public void systemReady() {

Settings.Global.putInt(mContentResolver,Settings.Global.ADB_ENABLED, 1 );

3. system\core\adb\daemon\main.cpp

修改为

//        if (ALLOW_ADBD_NO_AUTH && !android::base::GetBoolProperty("ro.adb.secure", false)) {
            auth_required = false;
//        }

二. 打开"开发者选项" 设置崩溃

log:

04-27 09:30:05.410  3402  3402 W ndroid.settings: type=1400 audit(0.0:1042): avc: denied { read } for name="u:object_r:logpersistd_logging_prop:s0" dev="tmpfs" ino=11447 scontext=u:r:system_app:s0 tcontext=u:object_r:logpersistd_logging_prop:s0 tclass=file permissive=0
04-27 09:30:05.416  3402  3402 E libc    : Access denied finding property "logd.logpersistd.enable"
04-27 09:30:05.417  3402  3402 W libc    : Unable to set property "persist.logd.logpersistd.buffer" to "": error code: 0x18
04-27 09:30:05.418  3402  3402 D AndroidRuntime: Shutting down VM
04-27 09:30:05.419  3402  3402 E AndroidRuntime: FATAL EXCEPTION: main
04-27 09:30:05.419  3402  3402 E AndroidRuntime: Process: com.android.settings, PID: 3402
04-27 09:30:05.419  3402  3402 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {com.android.settings/com.android.settings.SubSettings}: java.lang.RuntimeException: failed to set system property

04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3815)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3847)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1836)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:193)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6702)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
04-27 09:30:05.419  3402  3402 E AndroidRuntime: Caused by: java.lang.RuntimeException: failed to set system property
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.os.SystemProperties.native_set(Native Method)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.os.SystemProperties.set(SystemProperties.java:183)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settingslib.development.AbstractLogpersistPreferenceController.setLogpersistOff(AbstractLogpersistPreferenceController.java:185)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settingslib.development.AbstractLogpersistPreferenceController.writeLogpersistOption(AbstractLogpersistPreferenceController.java:233)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settingslib.development.AbstractLogpersistPreferenceController.onLogdSizeSettingUpdate(AbstractLogpersistPreferenceController.java:129)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settingslib.development.AbstractLogpersistPreferenceController.access$000(AbstractLogpersistPreferenceController.java:39)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settingslib.development.AbstractLogpersistPreferenceController$1.onReceive(AbstractLogpersistPreferenceController.java:65)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:312)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.support.v4.content.LocalBroadcastManager.sendBroadcastSync(LocalBroadcastManager.java:290)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settingslib.development.AbstractLogdSizePreferenceController.updateLogdSizeValues(AbstractLogdSizePreferenceController.java:112)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settings.development.LogdSizePreferenceController.updateState(LogdSizePreferenceController.java:34)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settings.dashboard.DashboardFragment.updatePreferenceStates(DashboardFragment.java:317)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settings.dashboard.DashboardFragment.onResume(DashboardFragment.java:169)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at com.android.settings.dashboard.RestrictedDashboardFragment.onResume(RestrictedDashboardFragment.java:137)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.Fragment.performResume(Fragment.java:2568)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1341)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1576)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1637)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3046)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:3008)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.FragmentController.dispatchResume(FragmentController.java:204)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.Activity.performResume(Activity.java:7314)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3807)
04-27 09:30:05.419  3402  3402 E AndroidRuntime:        ... 11 more
04-27 09:30:05.225  1001  2897 I chatty  : uid=1000(system) Binder:1001_F identical 1 line
04-27 09:30:05.234  1001  2897 E UserRestrictionsUtils: Unknown restriction: null
04-27 09:30:05.423  1001  3417 W ActivityManager:   Force finishing activity com.android.settings/.SubSettings

1. 看到log 首先注意到 绿色字体部分

com.android.settingslib.development.AbstractLogpersistPreferenceController.setLogpersistOff(AbstractLogpersistPreferenceController.java:185)

找到相应位置 SystemProperties.set(SELECT_LOGPERSIST_PROPERTY_BUFFER, ""); 发现是修改配置文件时报错, 

04-27 09:30:05.419  3402  3402 E AndroidRuntime: FATAL EXCEPTION: main
04-27 09:30:05.419  3402  3402 E AndroidRuntime: Process: com.android.settings, PID: 3402
04-27 09:30:05.419  3402  3402 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {com.android.settings/com.android.settings.SubSettings}: java.lang.RuntimeException: failed to set system property

2. 猜想应该和权限相关,于是在向上分析log 看到如下:

04-27 09:30:05.410  3402  3402 W ndroid.settings: type=1400 audit(0.0:1042): avc: denied { read } for name="u:object_r:logpersistd_logging_prop:s0" dev="tmpfs" ino=11447 scontext=u:r:system_app:s0 tcontext=u:object_r:logpersistd_logging_prop:s0 tclass=file permissive=0

其中tcontext=u:object_r:logpersistd_logging_prop:s0

于是在 grep -rn "logpersistd_logging_prop" ./system/sepolicy/ 查找相关权限配置

./system/sepolicy/prebuilts/api/28.0/private/system_app.te:47:userdebug_or_eng(`set_prop(system_app, logpersistd_logging_prop)')

打开system_app.te 添加相应权限, remake验证. ok

问题搞定.

userdebug_or_eng(`set_prop(system_app, logpersistd_logging_prop)') 这句配置 字面意思都可以理解, 只有在userdebug 或者eng 模式下 才会有set_prop 权限

你可能感兴趣的:(Android9.0)