getvar display a
bootloader variable
boot [ ] download and boot kernel
flash:raw boot [ ] create bootimage and flash it
devices list all
connected devices
continue continue
with autoboot
reboot reboot
device normally
reboot-bootloader reboot device
into bootloader
help show this
help message
options:
-w erase userdata and cache (and
format if supported by partition type)
-u do not first erase partition
before formatting
-s specify device serial number or path to
device port
-l with “devices”, lists device
paths
-p specify product name
-c override kernel commandline
-i specify a custom USB vendor id
-b <base_addr> specify a custom kernel base
address
-n specify the nand page size.
default: 2048
-S [K|M|G] automatically sparse files
greater than size. 0 to disable
fastboot 提供了扩展的命令符号
fastboot oem command args
下面以fastboot oem hello test 来说明如何扩展
(1).在bootable/bootloader/lk/app/mt_boot/fastboot.c
的fastboot_init 函数中添加一个新的register
//第一个参数是命令的名称
//第二个参数是命令的执行函数
//第三个参数是在security IC 中是否还提供此命令
fastboot_register(“oem hello”, cmd_oem_hello, FALSE);
(2). 实现cmd_oem_hello 函数
void cmd_oem_hello(const char *arg, void *data, unsigned size) {
//注意args 是以command 结束开始,即" args"
if(!strncmp(arg, " OK", strlen(" OK"))){
fastboot_okey(“OK”);
}else{
fastboot_fail(“Not OK”);
}
}
(3). 与PC 端交互
您可以使用下面已经定义好的三个函数与PC 端交互
fastboot_okey(const char* result);
fastboot_fail(const char* reason);
fastboot_info(const char* reason);
注意这三个打印字符串的长度都不能超过64-1-4 = 59 个字
4.在任意界面按某个实体键进入某个Activity
有些手机会有附加的功能键,比如拍照实体键,甚至有两端式的,轻按聚焦,深按拍照。那么类似功能是如何在Android手机上实现的呢?
可以修改源码下
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java文件中的如下方法:
public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event,int policyFlags)
找到如下代码段:
else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
if (down && repeatCount == 0 && !keyguardOn) {
showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS);
}
return -1;
}
在这个else if后面增加相应代码:
else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
if (down && repeatCount == 0 && !keyguardOn) {
showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS);
}
return -1;
} //add begin
else if (keyCode == KeyEvent.KEYCODE_XXX) {
if (down && repeatCount == 0 && !keyguardOn) {
mContext.startActivity(new Intent(“intent.xxx”)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
return -1;
} // add end
注意:
1、上面写的KeyEvent.KEYCODE_XXX是预设定好的实体键的键值,根据需要来设定即可;
2、startActivity(new Intent(“intent.xxx”)中的intent.xxx需要根据所启动的activity来写
5.在关机界面添加重启功能
Google原生的Android系统一般是没有“重启”这个选项的。有时候重启也是不可或缺的一个Feature,那么如何在源码环境下添加这个选项呢?
1. 在frameworks\base\core\res\res\values\strings.xml
中添加标签:
Reboot
当然这只是英语语系的,需要添加其它语系的标示,把"Reboot" 替换成其它语言。
2. 在alps\frameworks\base\core\res\res\drawable-hdpi 中添加图标:
zms_ic_lock_power_reboot.png
3. 打开frameworks\policies\base\phone\com\android\internal\policy\impl\GlobalActions.java
大概在这个文件的261行有这样的代码:
mItems = Lists.newArrayList(
// silent mode
mSilentModeToggle,
// next: airplane mode
mAirplaneModeOn,
// last: power off
在这里,我们添加power reboot 的新的item.
具体这个mItems 更新为如下:
mItems = Lists.newArrayList(
// silent mode
mSilentModeToggle,
// next: airplane mode
mAirplaneModeOn,
// last: power off
new SinglePressAction(
com.android.internal.R.drawable.ic_lock_power_off,
R.string.global_action_power_off) {
public void onPress() {
// shutdown by making sure radio and power are handled
accordingly.
ShutdownThread.shutdown(mContext, true);
}
public boolean showDuringKeyguard() {
return true;
}
public boolean showBeforeProvisioning() {
return true;
}
}//zms add start
,
new SinglePressAction(
com.android.internal.R.drawable.zms_ic_lock_power_reboot,
R.string.zms_global_action_power_reboot) {
public void onPress() {
// reboot by making sure radio and power are handled
accordingly.
ShutdownThread.reboot(m