[FAQ04776] 사용자 버전 debug 옵션을 기본적으로 열고 adb 연결을 기본적으로 여는 방법
사용자 버전의 USB debug 옵션을 기본적으로 열고 adb 연결을 기본적으로 여는 방법
[Keyword]
양산 버전 user usb debug root adb 연결
[Solution] 1. android4.0 이전에 이 설정은 프레임워크/베이스/서비스/.../SystemServer.java에 설정하면 시스템property의persist에 따라service.adb.enable에서 설정합니다.코드와 유사하게 볼 수 있습니다.
// make sure the ADB_ENABLED setting value matches the secure property value
Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED,
"1".equals(SystemProperties.get("persist.service.adb.enable")) ? 1 : 0);
// register observer to listen for settings changes
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secu
re.ADB_ENABLED),false, new AdbSettingsObserver());
이persist.service.adb.enable 기본값은default에 있습니다.prop에서 컴파일할 때
build/core/main.mk 중 확인,
ifeq (true,$(strip $(enable_target_debugging)))
# Target is more debuggable and adbd is on by default
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
# Include the debugging/testing OTA keys in this build.
INCLUDE_TEST_OTA_KEYS := true
else # !enable_target_debugging
# Target is less debuggable and adbd is off by default
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
endif # !enable_target_debugging
다음을 ADDITIONALDEFAULT_PROPERTIES += ro.debuggable=0
persist.service.adb.enable=0으로 변경
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
2.android4.0 이후adb의 제어로persist를 통일적으로 사용했습니다.sys.usb.config가 제어하기 때문에 대응하는 설정점도 프레임워크/베이스/서비스/.../로 변경되었습니다.usb/UsbDeviceManager.java에서도 다음과 같은 유사한 코드를 볼 수 있습니다.
public UsbHandler(Looper looper) {
// persist.sys.usb.config should never be unset. But if it is, set it to "adb"
// so we have a chance of debugging what happened.
mDefaultFunctions = SystemProperties.get("persist.sys.usb.config", "adb");
// sanity check the sys.usb.config system property
// this may be necessary if we crashed while switching USB configurations
String config = SystemProperties.get("sys.usb.config", "none");
if (!config.equals(mDefaultFunctions)) {
Slog.w(TAG, "resetting config to persistent property: " + mDefaultFunctions);
SystemProperties.set("sys.usb.config", mDefaultFunctions);
}
mCurrentFunctions = mDefaultFunctions;
String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim();
updateState(state);
mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB);
public void systemReady() {
// make sure the ADB_ENABLED setting value matches the current state
Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED, mAdbEnabled ?
1 : 0);
이persist.sys.usb.config에서adb의 설정은alps/build/tools/postprocess_props.py중
로.debuggable = 1 or 0으로 설정하고 1은adb를 켜고 0은adb debug를 닫습니다.이것
ro.debuggable도alps/build/core/main에 있습니다.mk에서 설정, 2.3 수정과 유사
그러나 이렇게 열면 사용자 버전adb 셸에 대한 루트 권한이 아니라 셸 권한이 열립니다.
루트 권한이 필요합니다. 시스템/core/adb/adb를 다시 고쳐야 합니다.c안의 shoulddrop_privileges () 이거
함수, #ifndef ALLOWADBD_ROOT 시 return 0;리턴 1이 아니라됐습니다.
---------------------------------------------------------------------------------------
1. 컴파일 명령에 따라 ro를 확정한다.debuggable
build/core/main.mk
## user/userdebug ##
user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
enable_target_debugging := true
tags_to_install :=
ifneq (,$(user_variant))
# Target is secure in user builds.
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
ifeq ($(user_variant),userdebug)
# Pick up some extra useful tools
tags_to_install += debug
# Enable Dalvik lock contention logging for userdebug builds.
ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
else
# Disable debugging in plain user builds.
enable_target_debugging :=
endif
# enable dex pre-optimization for all TARGET projects in default to
# speed up device first boot-up
#add by yanqi.liu for costomization @{
ifneq ($(JRD_IS_GOAL_PERSO),true)
WITH_DEXPREOPT := true
endif
#}
# Turn on Dalvik preoptimization for user builds, but only if not
# explicitly disabled and the build is running on Linux (since host
# Dalvik isn't built for non-Linux hosts).
ifneq (true,$(DISABLE_DEXPREOPT))
ifeq ($(user_variant),user)
ifeq ($(HOST_OS),linux)
ifneq ($(JRD_IS_GOAL_PERSO),true)
WITH_DEXPREOPT := true
endif
endif
endif
endif
# Disallow mock locations by default for user builds
ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
else # !user_variant
# Turn on checkjni for non-user builds.
# Kirby: turn off it temporarily to gain performance {
# ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
# ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=0
# } Kirby
# Set device insecure for non-user builds.
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
# Allow mock locations by default for non user builds
ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
endif # !user_variant
# always enable aed
ADDITIONAL_DEFAULT_PROPERTIES += persist.mtk.aee.aed=on
# Turn on Jazz AOT by default if not explicitly disabled and the build
# is running on Linux (since host Dalvik isn't built for non-Linux hosts).
ifneq (true,$(DISABLE_JAZZ))
ifeq ($(strip $(MTK_JAZZ)),yes)
ifeq ($(HOST_OS),linux)
# Build host dalvikvm which Jazz AOT relies on.
WITH_HOST_DALVIK := true
WITH_JAZZ := true
endif
endif
endif
ifeq (true,$(strip $(enable_target_debugging)))
# Target is more debuggable and adbd is on by default
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=0
# Include the debugging/testing OTA keys in this build.
INCLUDE_TEST_OTA_KEYS := true
else # !enable_target_debugging
# Target is less debuggable and adbd is off by default
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
endif # !enable_target_debugging
2. 기본 usb 기능 확인
build/tools/post_process_props.py
# Put the modifications that you need to make into the /system/build.prop into this
# function. The prop object has get(name) and put(name,value) methods.
def mangle_build_prop(prop):
#pass
#If ro.mmitest is true, then disable MTP, add mass_storage for default
if prop.get("ro.mmitest") == "true":
prop.put("persist.sys.usb.config", "mass_storage")
# If ro.debuggable is 1, then enable adb on USB by default
# (this is for userdebug builds)
if prop.get("ro.build.type") == "eng":
val = prop.get("persist.sys.usb.config").strip('\r
')
if val == "":
val = "adb"
else:
val = val + ",adb"
prop.put("persist.sys.usb.config", val)
# UsbDeviceManager expects a value here. If it doesn't get it, it will
# default to "adb". That might not the right policy there, but it's better
# to be explicit.
if not prop.get("persist.sys.usb.config"):
prop.put("persist.sys.usb.config", "none");
# Put the modifications that you need to make into the /system/build.prop into this
# function. The prop object has get(name) and put(name,value) methods.
def mangle_default_prop(prop):
# If ro.debuggable is 1, then enable adb on USB by default
# (this is for userdebug builds)
if prop.get("ro.debuggable") == "1":
val = prop.get("persist.sys.usb.config")
if val == "":
val = "adb"
else:
val = val + ",adb"
prop.put("persist.sys.usb.config", val)
# UsbDeviceManager expects a value here. If it doesn't get it, it will
# default to "adb". That might not the right policy there, but it's better
# to be explicit.
if not prop.get("persist.sys.usb.config"):
prop.put("persist.sys.usb.config", "none");
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Kotlin의 기초 - 2부지난 글에서는 Kotlin이 무엇인지, Kotlin의 특징, Kotlin에서 변수 및 데이터 유형을 선언하는 방법과 같은 Kotlin의 기본 개념에 대해 배웠습니다. 유형 변환은 데이터 변수의 한 유형을 다른 데이터...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.