android note【转】
本文转载自:http://blog.csdn.net/u012719256/article/details/52094982
1.重要的property属性
#define ANDROID_RB_PROPERTY "sys.powerctl" // 控制启动状态
property_set(ANDROID_RB_PROPERTY, "shutdown,");
property_set(ANDROID_RB_PROPERTY, "reboot,bootloader");
property_set(ANDROID_RB_PROPERTY, "reboot,");
property_set(ANDROID_RB_PROPERTY, "reboot,edl");
- 1
- 2
- 3
- 4
- 5
- 6
2.propety属性的管理
init.c
if (is_charger)
{
action_for_each_trigger("charger", action_add_queue_tail);
}
else
{
if (is_ffbm)
{
action_for_each_trigger("ffbm", action_add_queue_tail);
}
else
{
// 正常开机模式进入最后的 late-init 阶段
action_for_each_trigger("late-init", action_add_queue_tail);
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
init.rc
on late-init
trigger load_all_props_action // 在late-init阶段加载所有的属性
----------
on load_all_props_action
load_all_props
- 1
- 2
- 3
- 4
- 5
- 6
- 7
keywords.h property_service.c
KEYWORD(load_all_props, COMMAND, 0, do_load_all_props) //keywords.h
-> do_load_all_props // builtins.c
->load_all_props // property_service.c
// 依次从下面几个路径中加载所有的属性
"system/build.prop" (常用)
"system/default.prop"
- 1
- 2
- 3
- 4
- 5
- 6
- 7
build/tools/buildinfo.sh
☆ 生成 system/build.prop 文件,需要添加prop只需要在这个编译脚本中添加即可!!!
in system/build.prop
# begin build properties
3 # autogenerated by buildinfo.sh
4 ro.build.id=LMY47V
5 ro.build.display.id=LMY47V.WW_Phone.12.0.0.020-20160719_userdebug
6 ro.build.display.wtid=LMY47V.WW_Ph
- 1
- 2
- 3
- 4
- 5
- 6
- 7
3.属性值的获取设置
1. 在system.prop里面添加需要使用的系统属性,添加完后需要编译生成system.img
2. 在native层,使用property_set(...)和property_get(...)来存取系统属性
3. 在Java层, 使用SystemProperties.set(...)和SystemProperties.get(...)来存取系统属性
4. 在adb shell命令行,使用getprop和setprop来存取系统属性
- 1
- 2
- 3
- 4
- 5
- 6
- 7
3.charger
# init.rc
on charger
class_start charger
----------
# init.qcom.rc
service charger /charger
class charger
----------
#system/core/healthd/Android.mk
LOCAL_MODULE := healthd
...
# Symlink /charger to /sbin/healthd
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
4.屏幕截图 & 屏幕录制
adb shell screencap /sdcard/test.png
adb shell screenrecord sdcard/sss.mp4
- 1
- 2
5.关闭selinux
setenforce 0
- 1
6.adb devices 串号
(1)init.rc
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
- 1
- 2
- 3
(2)cat /pro/cmdline
adb root;adb shell cat /proc/cmdline
androidboot.serialno=YOGABOOK12
- 1
(3)init.cpp
process_kernel_cmdline
->import_kernel_cmdline(false, import_kernel_nv);
->import_kernel_nv
----------
char *value = strchr(name, '=');
(!strncmp(name, "androidboot.", 12) && name_len > 12) {
char *boot_prop_name = name + 12;
char prop[PROP_NAME_MAX];
snprintf(prop, sizeof(prop), "ro.boot.%s", boot_prop_name);
property_set(prop, value);
}
----------
static void export_kernel_boot_props() {
struct {
const char *src_prop;
const char *dst_prop;
const char *default_value;
} prop_map[] = {
...
{ "ro.boot.serialno", "ro.serialno", "", },
...
};
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
7.system/bin/input 命令
demo
input keyevent keycodeNum //4 表示KEYCODE_BACK
- 1
常用的几种事件:
//键值对应 android/keycodes.h
26 --> KEYCODE_POWER // 电源
82 --> "KEYCODE_MENU" //菜单
3 --> "KEYCODE_HOME" //返回home
4 --> "KEYCODE_BACK" //返回上一级菜单
19 --> "KEYCODE_DPAD_UP" //向上
20 --> "KEYCODE_DPAD_DOWN" //向下
21 --> "KEYCODE_DPAD_LEFT" //向左
22 --> "KEYCODE_DPAD_RIGHT" //向右
24 --> "KEYCODE_VOLUME_UP" //音量加
25 --> "KEYCODE_VOLUME_DOWN" //音量减
66 --> "KEYCODE_ENTER" //确定键
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
8. 重新挂载某个分区
mount -o remount,rw system system
- 1
9.命令行查看分辨率
frameworks/base/cmds/wm/
窗口分辨率
wm size
10.android init阶段 bootanimation之前的一张启动画面
// 在init.c中通过 “console_init” 这个action触发
queue_builtin_action(console_init_action, "console_init");
- 1
- 2
- 3
11.aplog
1.位置
/data/logs/aplog.n
data/local/log/aplog
- 1
- 2
2.crash信息
//logs\crashlog0_72612f74d4e263a53665\crashfile 中表明了crash原因
EVENT=CRASH
ID=61c96fdba2162a052323
SN=4cca94f595db403f749622792dfe73a6167ded48
DATE=2016-10-08/08:09:56
UPTIME=0000:00:19
BUILD=YB-Q501L_USR_S000014_1610010228_WW12_ROW,Lenovo/yogi_12_row_lte/YOGABOOK12:6.0.1/MMB29M/1610010228:user/release-keys,3.14.55-x86_64,queen@fyy-SMBIOSfyy,unknown,YOGI.T2000AH.V015,,,,
BOARD=Lenovo YB-Q501L
IMEI=
TYPE=SWWDT_UNHANDLED // crash 类型 看门狗
DATA_READY=1
OPERATOR=UNKNOWN
DATA0=SWWDT_RESET //
_END
----------
EVENT=CRASH
ID=72612f74d4e263a53665
SN=7f406c2f2e2675c73a5a85d52a237d80f747c2ea
DATE=2016-10-07/21:23:08
UPTIME=0000:00:22
BUILD=YB-Q501L_USR_S000014_1610010228_WW12_ROW,Lenovo/yogi_12_row_lte/YOGABOOK12:6.0.1/MMB29M/1610010228:user/release-keys,3.14.55-x86_64,queen@fyy-SMBIOSfyy,unknown,YOGI.T2000AH.V015,,,,
BOARD=Lenovo YB-Q501L
IMEI=
TYPE=IPANIC // // crash 类型 kernel panic
DATA_READY=1
OPERATOR=UNKNOWN
_END
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
3. ” BUG: “
搜索“ BUG: ”会有栈回溯或者null point信息
- 1
2.kernel启动信息/重启信息
beginning of kernel
10-07 21:22:46.780 0 0 I KERNEL : [ 0.000000] Initializing cgroup subsys cpuset
10-07 21:22:46.780 0 0 I KERNEL : [ 0.000000] Initializing cgroup subsys cpu
10-07 21:22:46.780 0 0 I KERNEL : [ 0.000000] Initializing cgroup subsys cpuacct
10-07 21:22:46.780 0 0 I KERNEL : [ 0.000000] Linux version 3.14.55-x86_64 (queen@fyy-SMBIOSfyy) (gcc version 4.9.2 (GCC) ) #1 SMP PREEMPT Sat Oct 1 03:04:35 CST 2016
10-07 21:22:46.780 0 0 I KERNEL : [ 0.000000] Command line: androidboot.bootloader=yogi_t2000ah_v015_kernelflinger-02_1f androidboot.diskbus=10.0 androidboot.verifiedbootstate=green androidboot.bootreason=kernel_panic androidboot.mode=0 :
12. 指定工程的 .config
KERNEL_DEFCONFIG
device/intel/cherrytrail/cht_ffd/AndroidBoard.mk
13. Android.mk中添加打印
$(warning "print info")
- 1
14.U盘插入拔出打印
1.mountservice 完整流程
MountService: Volume public:8,1 broadcasting checking to UserHandle{0} // 插入后检测挂载
MountService: Volume public:8,1 broadcasting mounted to UserHandle{0}
MountService: Volume public:8,1 broadcasting ejecting to UserHandle{0} // 点击弹出umount
MountService: Volume public:8,1 broadcasting unmounted to UserHandle{0}
MountService: Volume public:8,1 broadcasting removed to UserHandle{0} // 拔出U盘
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
2.kernelU盘插入拔出kernel打印
usb 2-1: new SuperSpeed USB device number 2 using xhci_hcd // 插上
30375936 512-byte logical blocks: (15.5 GB/14.4 GiB) // 读取大小
USB disconnect, device number // 拔出
- 1
- 2
- 3
- 4
15.U盘插入拔出mount/umount代码流程
1.监听subsystem为block 的uevent事件
NetlinkHandler::onEvent
VolumeManager::handleBlockEvent
case add:
Disk::create // disk.cpp
disk::readMetadata();
disk::readPartitions();
notifyEvent(ResponseCode::DiskCreated, StringPrintf("%d", mFlags));
case chager:
disk::readMetadata();
disk::readPartitions();
case remove:
Disk::destroy()
destroyAllVolumes();
notifyEvent(ResponseCode::DiskDestroyed);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
2.发送广播
Disk::notifyEvent
VolumeManager::Instance()->getBroadcaster()->sendBroadcast
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
3.mountService接收来着vold的广播
MountService.onEvent
MountService.onEventLocked
case VoldResponseCode.VOLUME_STATE_CHANGED: //每一次状态的改变都会调用这个分支
onVolumeStateChangedLocked(vol, oldState, newState); // 状态改变做相应操作
mHandler.obtainMessage(H_VOLUME_BROADCAST, userVol).sendToTarget(); // mountService发广播给mountService
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
3.mountService接收来着mountService的广播
MountServiceHandler.handleMessage //接收广播
case H_VOLUME_MOUNT: // 挂载
mConnector.execute("volume", "mount", vol.id, vol.mountFlags,vol.mountUserId);
case H_VOLUME_BROADCAST: // 发送广播给用户告知状态
Slog.d(TAG, "Volume " + userVol.getId() + " broadcasting " + envState + " to "+ userVol.getOwner());
mContext.sendBroadcastAsUser(intent, userVol.getOwner());
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
16.查看android分区及dd命令烧写分区
#ls /dev/block/by-name/
android_boot
android_bootloader
android_bootloader2
android_cache
android_config
android_data
android_factory
android_metadata
android_misc
android_persistent
android_recovery
android_system
----------
push boot.img到及机子的任意目录,在此目录执行 ,dd if=boot.img of=/dev/block/by-name/android_boot,重启之后,boot.img烧写成功.其他分区也类似.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
17.android 各层次获取时间的方法
1. 在Java层,long now = SystemClock.uptimeMillis();
2. 在native层,nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
3. 在驱动层,s64 time = ktime_to_us(ktime_get());
- 1
- 2
- 3
- 4
- 5
18.android 分区大小设置
vendor/qcom/non-hlos/MSM8953.LA.2.0/common/config/partition.xml
- 1
19.android framwork打印调用栈
// c++ 代码
#include <utils/CallStack.h>
...
CallStack stack;
stack.update();
stack.dump();
----------
// java 代码
Log.d(TAG,Log.getStackTraceString(new Throwable()));
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
20.快速编译打包bootimage和system
make kernel:只重新编译kernel部分镜像,但是不会打包更新boot.img
make bootimage-nodeps:不会编译kernel以及ramdisk,只会将out目录中现有的kernel和ramdisk.img重新打包一次生成boot.img
make ramdisk:只重新编译ramdisk镜像,生成ramdisk.img,但是不会打包更新boot.img
make ramdisk-nodeps:不会编译ramdisk,只会将out目录中现有的文件重新打包一次。out/target/product/hq6737t_66_1ha_m0/root,比如更改了init..rc之类的文件,只需要修改out/…/root/中对应的文件,然后重新用此命令打包一次,就会生成一个包含更改过init..rc的ramdisk.img
make snod:打包system
21.modern
./mk johnson-eng update-none-hlos.bin
vendor/qcom/non-hlos/MSM8953.LA.2.0/common/build/bin/asic/NON-HLOS.bin
- 1
- 2
- 3
22.Qcom 开机后继续打印串口log
主要是修改 persist.console.silent.config 属性,
persist.console.silent.config = 1是不打印,
persist.console.silent.config = 0继续打印。
修改的文件,
将手机中的build.prop导出, 直接修改,再push进去;
修改 device/qcom/msmXXX/system.prop,编译systemimage。
- 1
- 2
- 3
- 4
- 5
- 6
23.关闭selinux
when build, open the CONFIG_SECURITY_SELINUX_DEVELOP, add then append the " androidboot.selinux=permissive" in commandline.
or in device/qcom/msmxxxx/system.prop, add ro.boot.selinux=disable
- 1
- 2
- 3
- 4
24.sbl检测电池是否在位
Non-HOLS/BOOT.BF.3.3/boot_images/core/systemdrivers/pmic/app/chg/src/pm_app_smbchg.c 里有个检测电池在不在的函数,Check Battery presence
- 1
25.charge log mask
qpnp-smbcharger.c:
+ #define DEBUG
- static int smbchg_debug_mask;
+ static int smbchg_debug_mask = 0xFF;
- 1
- 2
- 3
- 4
26.各模块JNI层代码
26.1 surfaceflinger
android_view_Surface.cpp
static const JNINativeMethod gSurfaceMethods[] = {
demo
SurfaceTest.cpp
- 1
- 2
- 3
- 4
- 5
- 6
27.input keyevent 命令
对应的键值 frameworks/native/include/android/keycodes.h
$adb shell input keyevent 26 // power
$adb shell input keyevent 4 //模拟返回键(BACK)
$adb shell input keyevent 82 //模拟菜单键(MENU)
$adb shell input keyevent 3 //模拟主页键(HOME)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
28.inpudispatch中添加tp报点
--- a/frameworks/native/services/inputflinger/InputDispatcher.cpp
+++ b/frameworks/native/services/inputflinger/InputDispatcher.cpp
@@ -2483,15 +2483,16 @@ bool InputDispatcher::shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args
}
void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
-#if DEBUG_INBOUND_EVENT_DETAILS
- ALOGD("notifyMotion - eventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
+ ALOGE("zch----in notifyMotion");
+#if 1
+ ALOGE("notifyMotion - eventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
"action=0x%x, actionButton=0x%x, flags=0x%x, metaState=0x%x, buttonState=0x%x,"
"edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld",
args->eventTime, args->deviceId, args->source, args->policyFlags,
args->action, args->actionButton, args->flags, args->metaState, args->buttonState,
args->edgeFlags, args->xPrecision, args->yPrecision, args->downTime);
for (uint32_t i = 0; i < args->pointerCount; i++) {
- ALOGD(" Pointer %d: id=%d, toolType=%d, "
+ ALOGE(" Pointer %d: id=%d, toolType=%d, "
"x=%f, y=%f, pressure=%f, size=%f, "
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
"orientation=%f",
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
29.wifi连接adb
1. 在目标板上通过使用以太网连接来配置adb守护进程,使用setprop来设置守护进程的端口号
# setprop service.adb.tcp.port 5555
2. 如果以上配置成功,再重启目标板上的adbd服务
# stop adbd
# start adbd
3. 在主机端使用如下命令建立adb连接
export ADBHOST=<target's ip address>
adb kill-server
adb start-server
adb connect <target_ip_address>:5555
4. 使用如下命令确认设备连接成功
adb devices
设备连接成功后将出现设备序列号和名称
android note【转】的更多相关文章
- Android NOTE
一些小的点就记在这里吧…… MultiDex打包时zip错误 我遇到的是 Execution failed for task ':excelSior:packageAllDebugClassesFor ...
- android 官方文档 JNI TIPS
文章地址 http://developer.android.com/training/articles/perf-jni.html JNI Tips JNI is the Java Native I ...
- Build Android Webrtc Libjingle Library On Ubuntu
Our team is developing an app to help people solve problem face to face. We choose webrtc protocol a ...
- 编译android源码官方教程(2)建立编译环境「linux & mac osx」
https://source.android.com/source/initializing.html Establishing a Build Environment IN THIS DOCUMEN ...
- !! 2.对十份论文和报告中的关于OpenCV和Android NDK开发的总结
http://hujiaweibujidao.github.io/blog/2013/11/18/android-ndk-and-opencv-development-3/ Android Ndk a ...
- Android NDK 和 OpenCV 整合开发总结(3)
Android NDK 和 OpenCV 整合开发总结(3) http://hujiaweibujidao.github.io/blog/2013/11/18/android-ndk-and-open ...
- NDK(5) Android JNI官方综合教程[JavaVM and JNIEnv,Threads ,jclass, jmethodID, and jfieldID,UTF-8 and UTF-16 Strings,Exceptions,Native Libraries等等]
JNI Tips In this document JavaVM and JNIEnv Threads jclass, jmethodID, and jfieldID Local and Global ...
- Android 性能优化(18)JNI优化:JNI Tips 提升性能技巧
JNI Tips 1.In this document JavaVM and JNIEnv Threads jclass, jmethodID, and jfieldID Local and Glob ...
- VS2015+cordova+ionic安装配置
VS2015已经出了正式版,想用来试一下cordova方面的开发.最近在看ionic这个框架,于是想能在VS2015里编辑js就好了. 下面说一下蛋疼的安装配置过程. 一.安装VS2015及Andro ...
随机推荐
- Linux的网卡由eth0变成了eth1或eth2,如何修复??
背景:做linux下分布式测试的时候,重新安装了两个linux虚拟机,结果分布式脚本没有做好,分布式也没有做成. 今天想练练linux命令,打开vmware,启动linux1 虚拟机,使用ifconf ...
- 基础:VS快捷键
VS.net中快捷键收缩和展开代码段 i. Ctrl-M-O 折叠所有方法 ii. Ctrl-M-P 展开所有方法并停止大纲显示(不可以再折叠了) iii. Ctrl-M-M 折叠或展开当 ...
- 牛客多校Round 1
Solved:1 rank:249 E. Removal dp i,j表示前i个数删除了j个且选择了第i个的答案 类似字符串的dp 预处理一下nex i_k即i后面k第一次出现的位置 就好转移了 # ...
- form表单中只有一个input时,按回车键后表单自动提交(form表单的一个小坑)
form中只有一个input按回车键表单会自动提交 在一个form表单中,若只有一个input,按回车键表单会自动提交,但是当表单中存在多个input时,按回车键不会执行任何操作,这是form表单的一 ...
- 洛谷——P3275 [SCOI2011]糖果
P3275 [SCOI2011]糖果 差分约束模板题,基本思路就是$d[v]+w[v,u]<=d[u]$,$Spfa$更新方法, 有点套路的是要建立原点,即图中不存在的点来向每个点加边,但同样这 ...
- [bzoj1867][Noi1999][钉子和小球] (动态规划)
Description Input 第1行为整数n(2<=n<=50)和m(0<=m<=n).以下n行依次为木板上从上至下n行钉子的信息,每行中‘*’表示钉子还在,‘.’表示钉 ...
- 3.1.1 简单的 grep
grep 最简单的用法就是使用固定字符串: [many@avention Desktop]$ who many :0 2019- ...
- Java基础学习总结(76)——Java异常深入学习研究
异常机制是指当程序出现错误后,程序如何处理.具体来说,异常机制提供了程序退出的安全通道.当出现错误后,程序执行的流程发生改变,程序的控制权转移到异常处理器. 异常处理的流程 当程序中抛 ...
- Java中list集合ArrayList 中contains包含的使用
Java中list集合ArrayList 中contains包含的使用 https://blog.csdn.net/qq_38556611/article/details/78774690
- Eclipse不编译解决方案
原文链接:http://blog.csdn.net/huahuagongzi99999/article/details/7719882 转来自己用 这两天Eclipse 不编译了,无论怎么更改保 ...