赞
踩
repo sync -j4
设置ccache来减少编译时间:
添加环境变量:
1.$ export USE_CCACHE=1
#建立缓存目录
2.$ export CCACHE_DIR=~/.ccache
设置缓存大小:
3.$cd android/
4.$prebuilt/linux-x86/ccache/ccache -M 50G
有可能在./prebuilts/misc/linux-x86/ccache/ccache
You can watch ccache being used by doing the following:
$ watch -n1 -d prebuilt/misc/linux-x86/ccache/ccache -s
ubuntu 12.10配置adb:
以前adb连接都没有问题的,但是用来连接RK3188的机子,死活连不上,摸索很久,发现要如下配置:
/etc/udev/rules.d/51-android.rules中加入pid, vid:
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", ATTR{idProduct}=="0010", MODE="0666", OWNER="lsc"
重启udev:
sudo service udev restart
/home/lsc/.android/adb_usb.ini中加入vid:
0x2207
重启adb即可:
adb kill-server
adb shell即可连上去了
我们的工程中,没有用到在linux-3.0/scripts/build_sun4i.sh中的(已经删除了该语句),而是用build/core/Makefile中的
全志A10平台制作boot.img和ramdisk.img、system.img方法:
boot.img:
out/host/linux-x86/bin/mkbootimg --kernel out/target/product/crane-rearview/kernel --ramdisk out/target/product/crane-rearview/ramdisk.img --cmdline "console=ttyS0,115200 rw init=/init loglevel=8" --base 0x40000000 --output out/target/product/crane-rearview/boot.img
ramdisk:
out/host/linux-x86/bin/mkbootfs out/target/product/crane-rearview/root | out/host/linux-x86/bin/minigzip > out/target/product/crane-rearview/ramdisk.img
system.img:
make_ext4fs -s -l 536870912 -a system out/target/product/crane-rearview/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/crane-rearview/system
git commit后,没有提交,不小心git checkout回到了以前的分支,这时候要恢复先前提交的,用:
git reflog查看所有提交记录,然后git cherry-pick commitID即可
如果不知道repo init路径,进入其他项目的.repo/manifests目录下,git branch -a查看名称,然后切换如git checkout -b rockchip remotes/origin/rockchip,就可以切到rockchip分支看到xml文件了
repo init老是无法连接google服务器,可以拷贝一份其他项目.repo/repo的文件,然后加上--no-repo-verify参数,如:
repo init -u --no-repo-verify ssh://venus/home/git/android/kitkat/platform/manifest -b mediatek -m kk_mt8127_default.xml
最新可用方法:
万恶的墙下,我们可以用其他的url来下载代码。
屏蔽掉repo里面的
#REPO_URL = 'https://gerrit.googlesource.com/git-repo'
在你的下载连接后添加 --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=caf-stable
意外发现:
添加/etc/hosts
203.208.46.200 android.googlesource.com
但还要修改文件 ~/.viminfo 的权限,否则要sudo vim 才能起作用,修改后的权限如下:
-rwx-wx--x 1 lsc lsc 5240 4月 19 15:49 .viminfo
如果是A20,则编译uboot和kernel为:cd ./vendor/softwinner/ && ./build.sh -p sun7i_android
再运行上一条命令就可以啦
还有记得加上usb权限,
sudo gpasswd -a xxx vboxusers //xxx为自己的用户名字 如果共享文件不成功,再安装一次增强包然后重启就可以了 android截屏的方法: 执行文件在system/bin/中,有screencap screenshot,它们的源代码在 frameworks/base/cmds目录下面,用法: screencap -p /sdcard1/screenshot.png screenshot -s /system/media/audio/Cesium.ogg -i /sdcard1/screenshot.png apktool的使用: 从http://code.google.com/p/android-apktool/下载apktool1.5.2.tar.bz2和apktool-install-linux-r05-ibot.tar.bz2,然后解压放到usr/local/bin/目录下, 运行apktool的时候记得加上sudo,否则打包时候报错: Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 3, --target-sdk-version, 15, -F, /home/lsc/disk/jbs-cwhl/device/softwinner/crane-jbs7/preinstall/co.apk, -0, arsc, /home/lsc/disk/jbs-cwhl/device/softwinner/crane-jbs7/preinstall/compa/build/apk] Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 3, --target-sdk-version, 15, -F, /home/lsc/disk/jbs-cwhl/device/softwinner/crane-jbs7/preinstall/co.apk, -0, arsc, /home/lsc/disk/jbs-cwhl/device/softwinner/crane-jbs7/preinstall/compa/build/apk] ... 5 more Caused by: java.io.IOException: Cannot run program "aapt": java.io.IOException: error=13, Permission denied ... 6 more Caused by: java.io.IOException: java.io.IOException: error=13, Permission denied ... 9 more 用法 解包:sudo apktool d xxx.apk 打包:sudo apktool b xxx xxx.apk
vim里面有一个特性,如果你在一行注释后新加一行,vim会自动在下一行的开始位置添加注释符号,但是,我经常从其它地方复制一些代码,如果代码中有一行注释, 就会导致后面的所有代码全部自动被注释掉,相当不方便,去掉自动注释的办法,在.vimrc中增加如下内容即可 autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o wifi密码保存的路径为/data/misc/wifi/wpa_supplicant.conf,如我的机子上adb shell;cat /data/misc/wifi/wpa_supplicant.conf得到的信息: network={ ssid="Test" psk="0013076247" key_mgmt=WPA-PSK priority=2 } psk就是密码啦 infotmic LCD: linux-3.0.8/drivers/InfotmMedia/lcd_api/source中为所有lcd的配置文件,其中结构体类型LCD_Priv_conf配置了上电的时序,时序的解析文件在同目录下的lcd_api.c中 而CLK的频率计算方法则如下: h_total = cfg->width + cfg->HSPW + cfg->HBPD + cfg->HFPD; v_total = cfg->height + cfg->VSPW + cfg->VBPD + cfg->VFPD; pixTotal = h_total * v_total; clkfreq = pixTotal / 1000 * cfg->fpsx1000; 我们配置中填写的是fpsx1000,想要得到合适的频率,可以根据这个公式计算合适的fpsx1000 android启动过程在init中启动不了主要的进程,就会reboot并进入recovery模式,代码位置: system/core/init/signal_handler.c 93 if (svc->flags & SVC_CRITICAL) { 94 if (svc->time_crashed + CRITICAL_CRASH_WINDOW >= now) { 95 if (++svc->nr_crashed > CRITICAL_CRASH_THRESHOLD) { 96 ERROR("critical process '%s' exited %d times in %d minutes; " 97 "rebooting into recovery mode\n", svc->name, 98 CRITICAL_CRASH_THRESHOLD, CRITICAL_CRASH_WINDOW / 60); 99 android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); 100 return 0; 101 }
今天用A20的代码编译kernel,自己增加了几个驱动的C文件,和打开了SPI配置的功能,晕死,编译时候老是出错,要不是提示找不到SPI函数,要不是提示要手动选择YES/NO
来配置选项,明明把arch/arm/configs/sun7ismp_android_defconfig复制到.config,make menuconfig后发现根本不是sun7ismp_android_defconfig;把配置直接写到arch/arm/configs/sun7ismp_android_defconfig中也不行,make之后发现新加的配置不生效,以前A10是没有这些问题的,了搞了半天发现真的有点不同于A10,正确的配置如下:
make ARCH=arm sun7ismp_android_defconfig //要加上ARCH,否则用X86下面的配置
make ARCH=arm sun7ismp_android_defconfig menuconfig //不能直接make menuconfig,否则前面一步生成的.config还是不起作用
这样进入图形界面选择SPI功能,和自己新增的配置,保存退出,然后把.config 复制到sun7ismp_android_defconfig就可以了
如果自己网上下载的内核,要编译一个平台如s3c6400_defconfig,正确做法是:
make ARCH=arm s3c6400_defconfig;
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- zImage modules; //记得加modules啊,否则不编译ko的
adb中启动一个acitvity的命令:
am start -n com.example.tabhost/com.example.tabhost.MainActivy
android.intent.action.MAIN 决定点击apk时候启动那个activity
android.intent.category.LAUNCHER 决定时候把图标显示在桌面上
android.intent.category.HOME 决定开机启动那个应用程序,即设置为launcher
power上报机制:
drivers/power/power_supply_core.c power_supply_register函数中
- dev->class = power_supply_class;
- dev->type = &power_supply_dev_type;
- dev->parent = parent;
- dev->release = power_supply_dev_release;
- dev_set_drvdata(dev, psy);
- psy->dev = dev;
power_supply_class->dev_uevent = power_supply_uevent;
使得后续kobject_uevent上报时候,power_supply_uevent的内容,位于 drivers/power/power_supply_sysfs.c中;
在上层cat时候显示的则为power_supply_sysfs.c中
- #define POWER_SUPPLY_ATTR(_name) \
- { \
- .attr = { .name = #_name }, \
- .show = power_supply_show_property, \
- .store = power_supply_store_property, \
- }
一直不知道android是如何判断一个输入设备是何种类型的吗?比如注册了一个键盘驱动,生成一个节点input5, android如何就知道这个input5是一个键盘设备呢,这是在驱动中set_bit(EV_KEY, input->evbit)来设置的,EV_KEY就是键盘类型啊。
而android又是如何为这个设备查找对应的kl键盘布局的呢,也是在驱动中,比如input->name = "uartkeyboard-input", 那么android就查找看有没有uartkeyboard-input.kl文件,如果没有就用默认的
如果要上层在插入物理键盘时候隐藏软件盘,那么底层驱动的键值表必须包括KEY_Q这个键值,这是为什么呢?看frameworks/base/services/input/EventHub.cpp的一段代码就知道了:
- // 'Q' key support = cheap test of whether this is an alpha-capable kbd
- if (hasKeycodeLocked(device, AKEYCODE_Q)) {
- device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY;
- }
简单判断是否包含Q键值,有的话才会认为是INPUT_DEVICE_CLASS_ALPHAKEY类型,这样才能自动隐藏软件盘
android中指定读取硬件时钟芯片的实时时间用命令: busybox hwclock
设置系统时间:busybox date -s "2007-08-03 14:15:00"
将系统时间写入时钟芯片:busybox hwclock -w
查看系统时间:busybox date
原因:
hwclock工具调用的是linux标准的接口/dev/rtc0设备节点,文件在drivers/rtc/rtc-dev.c
android自己实现了一个rtc驱动,读取的是/dev/alarm, 位置在drivers/staging/android/alarm-dev.c, JNI层在frameworks/base/core/jni/android_os_SystemClock.cpp
而且android必须要实现alarm功能才能设置时间,即时间struct rtc_class_ops结构体的.read_alarm, .set_alarm方法,并且device_may_wakeup为true, 否则只能用/dev/rtc0节点才能读取,设置硬件芯片时间
kenel中rtc不能编译成ko加载,否则每次启动时间不对
A20 spi驱动 spi-sun7i.c:
/* spi device on or off control */
static void sun7i_spi_cs_control(struct spi_device *spi, bool on)
{
struct sun7i_spi *aw_spi = spi_master_get_devdata(spi->master);
unsigned int cs = 0;
if (aw_spi->cs_control) {
if (on) {
/* set active */
cs = (spi->mode & SPI_CS_HIGH) ? 1 : 0; //on为1表示使能cs引脚,SPI_CS_HIGH为1,表示高电平使能,所以如果高点平使能,则cs为1
} else {
/* set inactive */
cs = (spi->mode & SPI_CS_HIGH) ? 0 : 1;
}
spi_ss_level(aw_spi->base_addr, cs);
}
}
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; //这是4个spi适配器通用的配置,如果某个spi设备比较特殊,则在这里根据判断名字不同,更改成自己想要的配置
在sun7i_spi_work函数中:
- struct spi_message *msg = NULL;
- struct spi_device *spi = NULL;
- struct spi_transfer *t = NULL;
- unsigned int cs_change = 0;
- 。。。。。。
- /* first active the cs */
- if (cs_change)
- aw_spi->cs_control(spi, 1);
- /* update the new cs value */
- cs_change = t->cs_change;
-
- /* full duplex mode */
- if (t->rx_buf && t->tx_buf)
- spi_clear_dhb(aw_spi->base_addr);
-
- /*
- * do transfer
- * > 64 : dma ; <= 64 : cpu
- * wait for done completion in this function, wakup in the irq hanlder
- */
- status = sun7i_spi_xfer(spi, t);
- if (status)
- break; /* fail quit, zero means succeed */
-
- /* accmulate the value in the message */
- msg->actual_length += t->len;
- /* may be need to delay */
- if (t->delay_usecs)
- udelay(t->delay_usecs);
-
- /* if zero, keep active, otherwise deactived. */
- if (cs_change)
- aw_spi->cs_control(spi, 0);
- }
其中spi_transfer结构体定义:
- struct spi_transfer {
- /* it's ok if tx_buf == rx_buf (right?)
- * for MicroWire, one buffer must be null
- * buffers must work with dma_*map_single() calls, unless
- * spi_message.is_dma_mapped reports a pre-existing mapping
- */
- const void *tx_buf;
- void *rx_buf;
- unsigned len;
-
- dma_addr_t tx_dma;
- dma_addr_t rx_dma;
-
- unsigned cs_change:1;
- u8 bits_per_word;
- u16 delay_usecs;
- u32 speed_hz;
-
- struct list_head transfer_list;
- };
android 的launcher只有一个桌面时候,默认壁纸是不居中的,而是靠最左边,修改居中的办法:
- diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
- index f6416c8..e432c45 100644
- --- a/src/com/android/launcher3/Workspace.java
- +++ b/src/com/android/launcher3/Workspace.java
- @@ -1143,8 +1143,14 @@ public class Workspace extends SmoothPagedView
- mWaitingForUpdate = false;
- if (computeScrollOffset() && mWindowToken != null) {
- try {
- - mWallpaperManager.setWallpaperOffsets(mWindowToken,
- - mWallpaperOffset.getCurrX(), 0.5f);
- +
- + Log.e(TAG, "sclu mWallpaperOffset.getCurrX() = " + mWallpaperOffset.getCurrX() + "child = " + getChildCount());
- + if (((mWallpaperOffset.getCurrX() == 0) && (getChildCount() == 0)) || ((mWallpaperOffset.getCurrX() == 0) && (getChildCount() == 1)))
- + mWallpaperManager.setWallpaperOffsets(mWindowToken,
- + 0.5f, 0.5f);
- + else
- + mWallpaperManager.setWallpaperOffsets(mWindowToken,
- + mWallpaperOffset.getCurrX(), 0.5f);
- setWallpaperOffsetSteps();
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Error updating wallpaper offset: " + e);
RK3168 android 4.4.2 代码,设置中不选24小时格式,但是状态栏和锁屏界面日期栏没有出现PM或者AM格式,修正如下:
- --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
- +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
- @@ -59,7 +59,7 @@ public class Clock extends TextView {
- private static final int AM_PM_STYLE_SMALL = 1;
- private static final int AM_PM_STYLE_GONE = 2;
-
- - private static final int AM_PM_STYLE = AM_PM_STYLE_GONE;
- + private static final int AM_PM_STYLE = AM_PM_STYLE_NORMAL;
-
- public Clock(Context context) {
- this(context, null);
- diff --git a/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java b/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java
- index 6c701c7..ac8489e 100644
- --- a/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java
- +++ b/policy/src/com/android/internal/policy/impl/keyguard/ClockView.java
- @@ -95,7 +95,7 @@ public class ClockView extends RelativeLayout {
-
- AmPm(View parent, Typeface tf) {
- // No longer used, uncomment if we decide to use AM/PM indicator again
- - // mAmPmTextView = (TextView) parent.findViewById(R.id.am_pm);
- + //mAmPmTextView = (TextView) parent.findViewById(R.id.am_pm);
- if (mAmPmTextView != null && tf != null) {
- mAmPmTextView.setTypeface(tf);
- }
- @@ -213,6 +213,18 @@ public class ClockView extends RelativeLayout {
- mCalendar.setTimeInMillis(System.currentTimeMillis());
-
- CharSequence newTime = DateFormat.format(mFormat, mCalendar);
- + Context context = getContext();
- + String ampmValues;
- + if(DateFormat.is24HourFormat(context)){
- + ampmValues = "";
- + }else{
- + if(mCalendar.get(Calendar.AM_PM) == 0){
- + ampmValues = " AM";
- + }else{
- + ampmValues = " PM";
- + }
- + }
- + newTime = newTime + ampmValues;
- mTimeView.setText(newTime);
- mAmPm.setIsMorning(mCalendar.get(Calendar.AM_PM) == 0);
- }
Your version is: java version "1.6.0_27".
The correct version is: Java SE 1.6.
解决方法:
</pre><pre name="code" class="cpp">
android 资源文件string.xml中的product属性有default, nosdcard和tablet,比如:
<string name="progress_unmounting" product="nosdcard" msgid="3923810448507612746">"正在卸载 USB 存储设备..."</string>
<string name="progress_unmounting" product="default" msgid="1327894998409537190">"正在卸载 SD 卡..."</string>
在device.mk中有PRODUCT_CHARACTERISTICS := tablet可以设置,如果没有制定,就用default指定的
android自带浏览器搜索功能无法使用,比如在音乐中长按一首歌,会弹出选择浏览器搜索歌名的界面,但是点击无响应,是因为没有安装google自带的Velvet.apk。
android init.rc的service有一个属性 class main, 表示将该服务归入为main类,就是多个服务可以归为一类,有点像分组;这样后续如果要启动该类服务可以用 class_start main
即可
低级错误导致android ProgressDialog不能更新:
错误方法:
在线程中handler message通知handler处理后,用m_pDialog.setMessage("升级完成");来更新标题,接着Thread.sleep延时2秒再关闭。导致dialog无法更新
正确方法:
handler中不能延时,应该在thread中,发送更新message,延时2秒,再发一个message通知关闭;handler中用switch (msg,what) 来区分两次的消息
ubuntu重装virtualbox后,提示:
- The character device /dev/vboxdrv does not exist.
- Please install the virtualbox-ose-dkms package and the appropriate
- headers, most likely linux-headers-generic.
-
- You will not be able to start VMs until this problem is fixed.
网上搜索,方法很多,各有各的说法,解决的办法都不一样,很多都尝试过,都失败了。最后终于找到了合适我的:
gcc g++版本和先前不一样,第一次安装virtualbox时候用的是 4.7版本,后来由于编译android系统,降级为4.4;才出现了上述问题,将gcc g++版本升级回4.7再重装virtualbox即可。
官网下载libiconv-1.14
libiconv-1.14/jni/libcharset/lib/localcharset.c:51:24: error: langinfo.h: No such file or directory
按照网上的解决方法:
修改目录文件libcharset/config.h的宏定义,禁止该宏定义:
/* Define if you haveand nl_langinfo(CODESET). */
#define HAVE_LANGINFO_CODESET 0
发现不行,直接在.c代码开头#undef HAVE_LANGINFO_CODESET即可还有,代码用编译出来的iconv.a库老是编译不过,后来直接把代码放到iconv源代码中编译生成执行文件即可,省得麻烦。
理一下A23平台的axp代码架构,免得每次都要看半天才清楚:
代码在drivers/power/axp_power中,用的是axp223
axp22-board.c负责用platform注册芯片所有的电源,包括DC/DC和LDO
struct regulator_init_data中有一个.enabled成员,如:
- [vcc_ldo2] = {
- .constraints = {
- .name = "axp22_aldo1",
- .min_uV = 700000,
- .max_uV = 3300000,
- .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS,
- .initial_state = PM_SUSPEND_STANDBY,
- .state_standby = {
- //.uV = ldo2_vol * 1000,
- .enabled = 0,
- }
- },
为0表示休眠时候不供电, 它还有一个disabled成员,为1表示休眠时候关掉电源,enabled和disabled的值总是相反,否则不起作用,判断代码在drivers/regulator/core.c中:
- if (!rstate->enabled && !rstate->disabled) {
- if (can_set_state)
- rdev_warn(rdev, "No configuration\n");
- return 0;
- }
-
- if (rstate->enabled && rstate->disabled) {
- rdev_err(rdev, "invalid configuration\n");
- return -EINVAL;
- }
-
- if (!can_set_state) {
- rdev_err(rdev, "no way to set suspend state\n");
- return -EINVAL;
- }
-
- if (rstate->enabled)
- ret = rdev->desc->ops->set_suspend_enable(rdev);
- else
- ret = rdev->desc->ops->set_suspend_disable(rdev);
- if (ret < 0) {
- rdev_err(rdev, "failed to enabled/disable\n");
- return ret;
- }
axp22-regulator + id的名字如“ axp22-regulator.2”等
这样文件drivers/power/axp_power/axp22-regu.c中platform_driver_register将会匹配上面的对应的device名字,在probe中用regulator_register注册进入了前面说的drivers/regulator/core.c中,这样axp的电源开关,休眠等就交给了regulator core来管理。
如何配置默认打开电源?
在axp22-regu.c的regulator_register中,把该路电源注册到core.c中,会调用set_machine_constraints函数:
- static int set_machine_constraints(struct regulator_dev *rdev,
- const struct regulation_constraints *constraints)
- {
- ...................
- ret = machine_constraints_voltage(rdev, rdev->constraints);
- ....................
- if ((rdev->constraints->always_on || rdev->constraints->boot_on) &&
- ops->enable) {
- ret = ops->enable(rdev);
- if (ret < 0) {
- rdev_err(rdev, "failed to enable\n");
- goto out;
- }
- }
- }
machine_constraints_voltage就是负责设置输出电压的:
- /* do we need to apply the constraint voltage */
- if (rdev->constraints->apply_uV &&
- rdev->constraints->min_uV == rdev->constraints->max_uV) {
- ret = _regulator_do_set_voltage(rdev,
- rdev->constraints->min_uV,
- rdev->constraints->max_uV);
- if (ret < 0) {
- rdev_err(rdev, "failed to apply %duV constraint\n",
- rdev->constraints->min_uV);
- return ret;
- }
- }
.min_uV = 3300000,
.max_uV = 3300000,
这两个设置为相同的值,
unsigned always_on:1; /* regulator never off when system is on */
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
unsigned apply_uV:1; /* apply uV constraint if min == max */
apply_uV使用位域定义的,给他赋值为1即可。
这样设置了默认输出电压,接着enable就可以输出了,从前面core中的函数看要,要enable那么设置always_on为1(或则boot_on为1并且定义了enable)即可,所以还要在axp22-board.c的.constraints中设置always_on即可,(或则后面两个条件满足也可以)
驱动中申请regulator时候的名字是那个?
regulator_get -> _regulator_get -> regulator_dev_lookup, 在该函数中会调用如下
- list_for_each_entry(r, ®ulator_list, list)
- if (strcmp(rdev_get_name(r), supply) == 0)
- return r;
- static const char *rdev_get_name(struct regulator_dev *rdev)
- {
- if (rdev->constraints && rdev->constraints->name)
- return rdev->constraints->name;
- else if (rdev->desc->name)
- return rdev->desc->name;
- else
- return "";
- }
可见,名字就是axp22-board.c中constraints结构体name的名字,如.name = "axp20_ldo4":
- [vcc_ldo4] = {
- .constraints = {
- /* board default is 3.3V */
- .name = "axp22_ldo4",
- .min_uV = 1250000,
- .max_uV = 3300000,
- .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS,
- .initial_state = PM_SUSPEND_STANDBY,
- .state_standby = {
- //.uV = ldo4_vol * 1000,
- //.enabled = 1,
- }
- },
android mtp模式:
如果为mtp模式,/mnt/sdcard/分区的空间和userdata分区空间是一样大,而且为同一个分区,因为/mnt/sdcard/挂载的是/data/media,两者的内容是一样的。如果连接usb到电脑,那么根据MTP协议把/mnt/sdcard/分区共享到了电脑上,这有点像电脑的网络共享,android和电脑都可以同事访问该MTP分区,但是android占权限的主导地位。由此可见mtp是一种移动设给和电脑通过USB共享文件夹的协议
编译网络工具ethtool android版本,下载ethtool-2.6.37源代码,在./configure生成Makefile时候加上参数GCC=arm-none-linux-gnueabi,这样生成Makefile后,打开它,在arm-none-linux-gnueabi-gcc后面加上参数 --static,编译成静态文件ethtool即可,用法比如./ethtool -i eth0
全志平台配置插入电源直接开机,不进入充电模式:
代码在vendor/softwinner/boot/boot1/apps/Boot_Android/Board/fel_detect/fel_detect.c中
- power_start = 0;
- // 0: 不允许插火牛直接开机,必须通过判断:满足以下条件可以直接开机:长按power按键,前次是系统状态,如果电池电量过低,则不允许开机
- // 1: 任意状态下,允许插火牛直接开机,同时要求电池电量足够高
- // 2: 不允许插火牛直接开机,必须通过判断:满足以下条件可以直接开机:长按power按键,前次是系统状态,不要求电池电量
- // 3: 任意状态下,允许插火牛直接开机,不要求电池电量
- if(wBoot_script_parser_fetch("target", "power_start", &power_start, 1))
- {
- power_start=0;
- }
所以只要把sys_config.fex中的power_start配置为3即可,默认是0
私人定制adb需求:
蛋疼的客户为了产品保密,要求做一个特别的adb 工具,只能连接他的平板,那好吧,修改adb 源代码,把数据位全部反过来:
- lsc@lsc:~/disk/M71GY2/system/core/adb$ git diff
- diff --git a/adb/transport_local.c b/adb/transport_local.c
- index 96a24ba..49c275e 100644
- --- a/adb/transport_local.c
- +++ b/adb/transport_local.c
- @@ -29,15 +29,24 @@
- #define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)
- static inline void fix_endians(apacket *p)
- {
- - p->msg.command = H4(p->msg.command);
- - p->msg.arg0 = H4(p->msg.arg0);
- - p->msg.arg1 = H4(p->msg.arg1);
- - p->msg.data_length = H4(p->msg.data_length);
- - p->msg.data_check = H4(p->msg.data_check);
- - p->msg.magic = H4(p->msg.magic);
- + p->msg.command = ~H4(p->msg.command);
- + p->msg.arg0 = ~H4(p->msg.arg0);
- + p->msg.arg1 = ~H4(p->msg.arg1);
- + p->msg.data_length = ~H4(p->msg.data_length);
- + p->msg.data_check = ~H4(p->msg.data_check);
- + p->msg.magic = ~H4(p->msg.magic);
- }
- #else
- -#define fix_endians(p) do {} while (0)
- +//#define fix_endians(p) do {} while (0)
- +static inline void fix_endians(apacket *p)
- +{
- + p->msg.command = ~(p->msg.command);
- + p->msg.arg0 = ~(p->msg.arg0);
- + p->msg.arg1 = ~(p->msg.arg1);
- + p->msg.data_length = ~(p->msg.data_length);
- + p->msg.data_check = ~(p->msg.data_check);
- + p->msg.magic = ~(p->msg.magic);
- +}
- #endif
-
- #if ADB_HOST
- diff --git a/adb/transport_usb.c b/adb/transport_usb.c
- index ee6b637..ef92e20 100644
- --- a/adb/transport_usb.c
- +++ b/adb/transport_usb.c
- @@ -31,19 +31,28 @@
- #define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)
- static inline void fix_endians(apacket *p)
- {
- - p->msg.command = H4(p->msg.command);
- - p->msg.arg0 = H4(p->msg.arg0);
- - p->msg.arg1 = H4(p->msg.arg1);
- - p->msg.data_length = H4(p->msg.data_length);
- - p->msg.data_check = H4(p->msg.data_check);
- - p->msg.magic = H4(p->msg.magic);
- + p->msg.command = ~H4(p->msg.command);
- + p->msg.arg0 = ~H4(p->msg.arg0);
- + p->msg.arg1 = ~H4(p->msg.arg1);
- + p->msg.data_length = ~H4(p->msg.data_length);
- + p->msg.data_check = ~H4(p->msg.data_check);
- + p->msg.magic = ~H4(p->msg.magic);
- }
- unsigned host_to_le32(unsigned n)
- {
- return H4(n);
- }
- #else
- -#define fix_endians(p) do {} while (0)
- +//#define fix_endians(p) do {} while (0)
- +static inline void fix_endians(apacket *p)
- +{
- + p->msg.command = ~(p->msg.command);
- + p->msg.arg0 = ~(p->msg.arg0);
- + p->msg.arg1 = ~(p->msg.arg1);
- + p->msg.data_length = ~(p->msg.data_length);
- + p->msg.data_check = ~(p->msg.data_check);
- + p->msg.magic = ~(p->msg.magic);
- +}
重新编译成下位机adb adbd和 linux 主机adb工具
window下adb 工具这样编译:
sudo apt-get install mingw32;
make USE_MINGW=y adb
生成:
out/host/windows-x86/bin/AdbWinUsbApi.dll
out/host/windows-x86/bin/AdbWinApi.dll
out/host/windows-x86/bin/adb.exe
替换掉原来的即可
android编译代码,如果要拷贝很多so到out目录,那么下面这个脚本超级有用,在mk文件中加入即可,路径修改成自己的:
src_files := $(shell ls $(CUR_PATH)/airis )
PRODUCT_COPY_FILES += $(foreach file, $(src_files), \
$(CUR_PATH)/airis/$(file):system/lib/$(file))
在launcher中隐藏某个apk的icon:
- --- a/src/com/android/launcher2/AllAppsList.java
- +++ b/src/com/android/launcher2/AllAppsList.java
- @@ -91,6 +91,11 @@ class AllAppsList {
-
- if (matches.size() > 0) {
- for (ResolveInfo info : matches) {
- + String name = info.activityInfo.name;
- + if(name.equals("com.google.android.maps.PlacesActivity")
- + || name.equals("com.google.android.maps.driveabout.app.DestinationActivity"))
- + continue;
- +
- add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null));
- }
- }
2. 默认铃声, 通知, 闹钟音乐
可以在system.prop 分别配置
ro.config.ringtone=Playa.ogg(默认铃声设置,文件在/system/media/audio/ringtones 把喜欢的铃声放这里,比如123.MP3放入ringtones文件夹中,这里代码改为ro.config.ringtone=123.mp3)
ro.config.notification_sound=regulus.ogg(默认提示音,文件在/system/media/audio/notifications 修改方法同上)
ro.config.alarm_alert=Alarm_Beep_03.ogg(默认闹铃,文件在/system/media/audio/alarms 修改方法同上)
3. 壁纸不跟随滑动
packages/apps/Launcher2/./src/com/android/launcher2/Workspace.java 大概 875行
private float wallpaperOffsetForCurrentScroll()
修改 wallpaperOffsetForCurrentScroll 的返回值。改成 return 0.5f;
全志A83T编译kernel时候报错:
./stdio.h:456:1: error: 'gets' undeclared here (not in a function)
网上搜索很久,不过最管用的还是修改stdio.in.h, 如下:
cd ./out/sun9iw1p1/linux/common/buildroot/build/host-m4-1.4.15/lib/
sed -i -e '/gets is a security/d' ./stdio.in.h
然后重新编译即可
蛋疼的客户没有什么做不出来的,提供的apk放在内部不可卸载方式安装就报错不能运行,把so库单独拿出来也不管用;安装在外部可卸载就正常,但是又要求app不能卸载,好吧,只能把setting和launcher中的可卸载地方屏蔽掉,还有禁止用adb 来卸载,分别修改如下:
- --- a/src/com/android/launcher3/DeleteDropTarget.java
- +++ b/src/com/android/launcher3/DeleteDropTarget.java
- @@ -38,6 +38,7 @@ import android.view.ViewGroup;
- import android.view.animation.AnimationUtils;
- import android.view.animation.DecelerateInterpolator;
- import android.view.animation.LinearInterpolator;
- +import android.util.Log;
-
- import com.android.launcher3.compat.UserHandleCompat;
-
- @@ -180,6 +181,18 @@ public class DeleteDropTarget extends ButtonDropTarget {
- boolean isVisible = true;
- boolean useUninstallLabel = !LauncherAppState.isDisableAllApps() &&
- isAllAppsApplication(source, info);
- + boolean flag = info instanceof AppInfo;
- + Log.e("sclu", "flag=" + flag);
- + if (flag) {
- + AppInfo appInfo = (AppInfo) info;
- + String name = appInfo.componentName + "";
- + if (name.contains("com.android.chrome")) {
- + useUninstallLabel = false;
- + isVisible = false;
- + }
- + Log.e("sclu", "className=" + appInfo.componentName);
- + }
- --- a/src/com/android/launcher2/DeleteDropTarget.java
- +++ b/src/com/android/launcher2/DeleteDropTarget.java
- @@ -34,6 +34,7 @@ import android.view.ViewGroup;
- import android.view.animation.AnimationUtils;
- import android.view.animation.DecelerateInterpolator;
- import android.view.animation.LinearInterpolator;
- +import android.util.Log;
-
- import com.android.launcher.R;
-
- @@ -147,11 +148,18 @@ public class DeleteDropTarget extends ButtonDropTarget {
- // delete the app (it was downloaded), and rename the string to "uninstall" in such a case
- if (isAllAppsApplication(source, info)) {
- ApplicationInfo appInfo = (ApplicationInfo) info;
- + String name = appInfo.componentName + "";
- if ((appInfo.flags & ApplicationInfo.DOWNLOADED_FLAG) != 0) {
- isUninstall = true;
- } else {
- isVisible = false;
- }
- +
- + if (name.contains("com.android.chrome")) {
- + isUninstall = false;
- + isVisible = false;
- + }
- + Log.e("sclu", "className=" + appInfo.componentName);
- --- a/src/com/android/settings/applications/InstalledAppDetails.java
- +++ b/src/com/android/settings/applications/InstalledAppDetails.java
- @@ -368,7 +368,7 @@ public class InstalledAppDetails extends Fragment
- }
- // If this is a device admin, it can't be uninstalled or disabled.
- // We do this here so the text of the button is still set correctly.
- - if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
- + if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName) || mPackageInfo.packageName.equals("com.android.chrome")) {
- enabled = false;
- }
- --- a/services/core/java/com/android/server/pm/PackageManagerService.java
- +++ b/services/core/java/com/android/server/pm/PackageManagerService.java
- @@ -11496,6 +11497,10 @@ public class PackageManagerService extends IPackageManager.Stub {
- ret = deleteSystemPackageLI(ps, allUserHandles, perUserInstalled,
- flags, outInfo, writeSettings);
- } else {
- + if (ps.name.equals("com.google.android.talk") || ps.name.equals("com.android.chrome")) {
- + Slog.e("sclu", "can't remove google talk or chrome");
- + return false;
- + }
android 4.4编译老是提示:
out/target/common/obj/PACKAGING/public_api.txt:23888: error 12: Class android.telephony.gsm.SmsManager changed static qualifier out/target/common/obj/PACKAGING/public_api.txt:23888: error 26: Class android.telephony.gsm.SmsManager added final qualifier but was previously uninstantiable and therefore could not be subclassed out/target/common/obj/PACKAGING/public_api.txt:23889: error 4: Added public method android.telephony.gsm.SmsManager.divideMessage out/target/common/obj/PACKAGING/public_api.txt:23890: error 4: Added public method android.telephony.gsm.SmsManager.getDefault out/target/common/obj/PACKAGING/public_api.txt:23891: error 4: Added public method android.telephony.gsm.SmsManager.sendDataMessage out/target/common/obj/PACKAGING/public_api.txt:23892: error 4: Added public method android.telephony.gsm.SmsManager.sendMultipartTextMessage out/target/common/obj/PACKAGING/public_api.txt:23893: error 4: Added public method android.telephony.gsm.SmsManager.sendTextMessage out/target/common/obj/PACKAGING/public_api.txt:23894: error 5: Added public field android.telephony.gsm.SmsManager.RESULT_ERROR_GENERIC_FAILURE out/target/common/obj/PACKAGING/public_api.txt:23895: error 5: Added public field android.telephony.gsm.SmsManager.RESULT_ERROR_NO_SERVICE out/target/common/obj/PACKAGING/public_api.txt:23896: error 5: Added public field android.telephony.gsm.SmsManager.RESULT_ERROR_NULL_PDU out/target/common/obj/PACKAGING/public_api.txt:23897: error 5: Added public field android.telephony.gsm.SmsManager.RESULT_ERROR_RADIO_OFF out/target/common/obj/PACKAGING/public_api.txt:23898: error 5: Added public field android.telephony.gsm.SmsManager.STATUS_ON_SIM_FREE out/target/common/obj/PACKAGING/public_api.txt:23899: error 5: Added public field android.telephony.gsm.SmsManager.STATUS_ON_SIM_READ out/target/common/obj/PACKAGING/public_api.txt:23900: error 5: Added public field android.telephony.gsm.SmsManager.STATUS_ON_SIM_SENT out/target/common/obj/PACKAGING/public_api.txt:23901: error 5: Added public field android.telephony.gsm.SmsManager.STATUS_ON_SIM_UNREAD out/target/common/obj/PACKAGING/public_api.txt:23902: error 5: Added public field android.telephony.gsm.SmsManager.STATUS_ON_SIM_UNSENT
我的就是把整个硬盘拿到新电脑上用导致的问题,需要更新代码日期,最好办法就是删除代码,重新checkout出来即可
RK解压resource.img:
在kernel目录有resource_tool工具,新建tempdir临时目录
./resource_tool --unpack --verbose --image=resource.img tempdir
解压dtb文件:
dtc -I dtb -O dts firefly-rk3288.dtb -o my.dtsi
即可生成dtsi文件
bootanimation.zip打包命令:
zip -Z store bootanimation.zip part0/*jpg part1/*jpg desc.txt
git 新建一个工程比如android6.0:
在marshmallow/platform下新建一个repo文件夹,进入repo 运行new_project.sh manifest
回到本地计算机,运行git clone ssh://venus/home/git/android/marshmallow/platform/repo/manifest.git克隆
进入manifext目录新建default.xml文件并添加一下内容:
- <?xml version="1.0" encoding="UTF-8"?>
- <manifest>
- <remote name="origin"
- fetch="/home/git/android/marshmallow/platform/repo"
- sync-c="true" />
-
- <default revision="a64_android6.0_dvk"
- remote="origin"
- sync-c="true"
- sync-j="8" />
- <project name="device/common"/>
- <project name="device/asus"/>
- <project name="device/generic"/>
- <project name="device/google"/>
- <project name="device/htc"/>
- <project name="device/lge"/>
- <project name="device/moto"/>
- <project name="device/sample"/>
- <project name="device/softwinner/common"/>
- <project name="device/softwinner/octopus-common"/>
- <project name="device/softwinner/octopus-f1"/>
- <project name="device/softwinner/tulip-common"/>
- <project name="device/softwinner/tulip-p1"/>
- <project name="platform/abi" path="abi"/>
- <project name="platform/art" path="art"/>
- <project name="platform/bionic" path="bionic" />
- <project name="platform/bootable" path="bootable" />
- <project name="platform/build" path="build" >
- <copyfile dest="Makefile" src="core/root.mk"/>
- <copyfile dest="编译说明.txt" src="readme.txt"/>
- </project>
-
- </manifest>
这样合并好代码并提交后,以后下载代码用:
repo init -u ssh://venus/home/git/android/marshmallow/platform/repo/manifest.git -b a64_android6.0_game.xml
-b后面的xml是新增的分支,如果不用-b参数,则默认default.xml
如果要保留原来的git修改记录,可以先git branch创建一个自己的分支,然后scp .git目录到服务器即可,同步时候manifest.xml branch中写上刚才创建的分支名字即可
A33 lvds屏:
亮度很暗,调节背光也没效果,其他显示正常,lcd_lvds_colordepth配置为8位模式即可;如果一直闪屏,配置了各种vt bp等参数也不起效果,并且颜色有红绿蓝的交替变化,lcd_lvds_colordepth配置为6位即可
如果屏幕能正常显示,但是有些区域看起来有色彩失真,可能是clk 和hsyc的极性问题,反相即可
如果屏幕黑屏,则是hbp vbp vt ht等参数不对
Android eng版本有串口输出,user版本则禁止串口输出,是因为一下属性:
- on property:ro.debuggable=1
- start console
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。