android字体

一。背景

尽量写简单一点这次就不废话了。

二。分析

2.1. 文件系统中字体的位置:

/system/fonts/ 其中的ttf文件都是字库 对于源码/frameworks/data/fonts/下的字体文件

DroidSans-Bold.ttf 粗体的无衬线字体(拉丁字母等)

DroidSans.ttf 常规的无衬线字体(拉丁字母等)

DroidSansFallback.ttf 常规的无衬线字体(中文字符等,一般换字库就是替换此文件)

DroidSansMono.ttf 等宽的无衬线字体(拉丁字母等)

DroidSerif-Bold.ttf 粗体的衬线字体(拉丁字母等)

DroidSerif-BoldItalic.ttf 粗体+斜体的衬线字体(拉丁字母等)

DroidSerif-Italic.ttf 斜体的衬线字体(拉丁字母等)

DroidSerif-Regular.ttf 常规的衬线字体(拉丁字母等)

Clockopia.ttf (显示数字时钟时用的字体,非必须)

在frameworks/fonts/下有三个xml文件,分别是fallback_fonts.xml、system_fonts.xml、vendor_fonts.xml,最终被编进系统的是前面两个。

 

改变字体有不外乎两种方法,一是强制替换掉系统的默认字体,也就是把你想要替换的字体重命名成DroidSansFallback.ttf,替换掉/system/fonts/下原来的那个,另外一种方法就是通过定义vendor fonts xml的方法来设置,对于我们来说,第一种方法太过于暴力,且没有选择的余地。所以第二种方法更为可行

暴力替换法就不说了,现在说说厂商字体法:

2.2. vendor fonts方法:

假设你要添加一个XXXXX.ttf格式的字体文件:

按照android用例vendor_fonts.xml文件中注释介绍的方法,在/vendor/etc/目录下创建一个fallback_fonts.xml,例如

<familyset>

<family order=”9″>

<fileset>

<file>XXXXX.ttf</file>

</fileset>

</family>

</familyset>

其中family order就表示描述的插入的vendor字体的需要代替的位置,即/system/etc/fallback_fonts.xml中描述的第10个family(从0开始),也就是DroidSansFallback.ttf,使用这种方法前也需要将“XXXXX.ttf”拷贝到/system/fonts下

 

 

三。总结:

这次也不废话了,不过要提醒一下,字库大部分都是有版权的,所以用别人的字库前都要小心,这也是为什么Android不再Settings中添加字体的选择栏的原因,如果你用了别人的字库没有交保护费的话而产品又买了不少钱的话,呵呵,律师函估计已经在抵达的途中。

MTP

MTP

MTP is the “Media Transfer Protocol” and is used by many mp3 players (e.g. Creative Zen) and mobile phones (e.g. Android 3+ devices). It is part of the “Windows Media” Framework and has close relationship with Windows Media Player.

Contents

[hide]

Installation

MTP support is provided by libmtpinstallable with the libmtp package from the official repositories.

Usage

After installation, you have several MTP tools available. Upon connecting your MTP device, you use:

# mtp-detect

to see if your MTP device is detected.

To connect to your MTP device, you use:

# mtp-connect

If connection is successful, you will be given several switch options in conjunction with mtp-connect to access data on the device.

There are also several stand alone commands you can use to access your MTP device such as,

Warning: Some commands may be harmful to your MTP device!!!
 mtp-albumart        mtp-emptyfolders    mtp-getplaylist     mtp-reset           mtp-trexist
 mtp-albums          mtp-files           mtp-hotplug         mtp-sendfile
 mtp-connect         mtp-folders         mtp-newfolder       mtp-sendtr
 mtp-delfile         mtp-format          mtp-newplaylist     mtp-thumb
 mtp-detect          mtp-getfile         mtp-playlists       mtp-tracks

Using media players

You can also use your MTP device in music players such as Amarok. To do this you may have to edit /etc/udev/rules.d/51-android.rules (the MTP device used in the following example is a Galaxy Nexus): To do this run:

$ lsusb

and look for your device, it will be something like:

Bus 003 Device 011: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]

in which case the entry would be:

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="[username]"

Then, reload udev rules:

# udevadm control --reload
Note: After installing MTP you may have to reboot for your device to be recognised

mtpfs

Mtpfs is FUSE filesystem that supports reading and writing from any MTP device. Basically it allows you to mount your device as an external drive.

Mtpfs can be installed with the packge mtpfs, available from the official repositories.

  • First edit your /etc/fuse.conf and uncomment the following line:
user_allow_other
  • To mount your device
$ mtpfs -o allow_other /media/YOURMOUNTPOINT
  • To unmount your device
$ fusermount -u /media/YOURMOUNTPOINT
  • To unmount your device as root
# umount /media/YOURMOUNTPOINT

Also, you can put them into your ~/.bashrc:

alias android-connect="mtpfs -o allow_other /media/YOURMOUNTPOINT"
alias android-disconnect="fusermount -u /media/YOURMOUNTPOINT"

Or, with sudo

alias android-disconnect="sudo umount -u /media/YOURMOUNTPOINT"
Note: if you want not be asked for password when using sudo, please refer to USB Storage Devices#Mounting USB devices

jmtpfs

jmtpfs is a FUSE and libmtp based filesystem for accessing MTP (Media Transfer Protocol) devices. It was specifically designed for exchanging files between Linux systems and newer Android devices that support MTP but not USB Mass Storage. jmtpfs is available as jmtpfs in the AUR.

Use these commands to mount and unmount your device :

$ jmtpfs ~/mtp
$ fusermount -u ~/mtp

go-mtpfs

Note: Go-mtpfs gives a better performance while writing files to some devices than mtpfs/jmtpfs. Try it if you have slow speeds.
Note: Mounting with Go-mtpfs fails if external SD Card is present. If you have also external SD Card please remove it and then try mounting again.

If the above instructions don’t show any positive results one should try go-mtpfs-git from the AUR. The following has been tested on a Samsung Galaxy Nexus GSM, Asus/Google Nexus 7 (2012 1st gen model) and Samsung Galaxy S 3 mini. (This is the only mtp software which worked for me on nexus 4. Settings are usb debugging enabled, connected as media device.)

If you want do it simpler, install golibmtp and git from the official repositories. After that install go-mtpfs-git from the AUR.
As in the section above install android-udev which will provide you with “/usr/lib/udev/rules.d/51-android.rules” edit it to apply to your vendorID and productID, which you can see after running mtp-detect. To the end of the line add with a comma OWNER=”yourusername”. Save the file.

  • Add yourself to the “fuse” group:
gpasswd -a [user] fuse
  • If the group “fuse” doesn’t exist create it with:
groupadd fuse

Logout or reboot to apply these changes.

  • To create a mount point called “Android” issue the following commands:
mkdir Android
  • To mount your phone use:
go-mtpfs Android
  • To unmount your phone:
fusermount -u Android

You can create a .bashrc alias as in the example above for easier use.

gvfs-mtp

Philip Langdale is has implemented native MTP support for gvfs. The weaknesses of gphoto2 and mtpfs are listed in his blog post.

  • The native mtp implementation for gvfs has been merged upstream and has been released in gvfs 1.15.2.
  • You can grab the stable gvfs-mtp package from extra. You may want to reboot your PC to make it actually working.
  • Devices will have gvfs paths like this
gvfs-ls mtp://[usb:002,013]/

simple-mtpfs

This is another FUSE filesystem for MTP devices. You may find this to be more reliable than mtpfssimple-mtpfs is available in the AUR or can be built from source. Remember do not run the following commands as root.

  • To list MTP devices run
 simple-mtpfs --list-devices
  • To mount a MTP devices (in this example device 0) run
simple-mtpfs /path/to/your/mount/point
  • To un mount run
 fusermount -u /path/to/your/mount/point

KDE MTP KIO Slave

There is a MTP KIO Slave built upon libmtp availiable as package kio-mtp.

Using KIO makes file access in KDE seamless, in principle any KDE application would be able read/write files on the device.

Usage

The device will be available under the path mtp:/

Workaround if the KDE device actions doesn’t work

If you are not able to use the action “Open with File Manager”, you may work around this problem by editing the file /usr/share/apps/solid/actions/solid_mtp.desktop

Change the line

Exec=kioclient exec mtp:udi=%i/

To

Exec=dolphin "mtp:/"

GNOME gMTP

gMTP is a native Gnome application used for MTP access.

gmtp is currently located in the AUR .

Workarounds for Android

  • HTC Phones automatically enter usb debugging mode on usb connect. Manually turn it off once connected to give libmtp access to the device.

MTP is still buggy and may crash despite the best efforts of developers. The following are alternatives:

  • AirDroid – an Android app to access files via your web browser.
  • FTP client on Android – If you run a local FTP server on Arch (such as Vsftp), there are many FTP clients available on the Play Store which will give read/ write access to your device’s files.
  • FTP Server on Android. Note: since FTP client using passive transfer (server connect to client) do not forget to disable firewall or adding rules for allowing FTP server connect to your PC.
    • Ftp Server (by The Olive Tree) app in Play Store acts as FTP server on Android and allows RW access to pretty much all your storage.
      • Pro: Doesn’t require root and just works!
      • Cons: Doesn’t work with tethering network.
    • FTPServer (by Andreas Liebig) – Just work.
  • SSH server on Android.
    • For example, SSHelper, available on the Play Store, just works without requiring root access. Assuming SSHelper is listening on port 20 and the phone’s IP address is 192.168.0.20, the following command will synchronise a local directory with the external SD card of the Android device:
 rsync --rsh="ssh -p 20" --modify-window=1  ~/local_files  192.168.0.20:/mnt/extSdCard/remote_files

Note the --modify-window option, which is often used when rsyncing to a FAT filesystem (such as the one used by Android devices for their internal memory and external SD cards).

  • Samba – an Android app to share your SD card as a windows fileshare. Pros: Your desktop apps work as before (since the SD card appears as a windows fileshare). Cons: you need to root your phone.
  • adb – Part of the Android development kit is adb android debug bridge. It can be used to push and pull files from an Android device.
    • The device need USB debbuging to be active and later connected to the computer with usb.
    • To send a file to the device use adb push /what-to-copy /where-to-place-it
    • To receive a file adb pull /what-you-want-to-copy /where-you-want-it
      • Pro: Stable, can be used for a lot more then just copy files back and forth.
      • Cons: Can be somewhat slow.

Security features on android

If you use android 4.x please unlock phone (screen unlock) and then connect phone to USB.

If you not unlock you have in KDE “No Storages found. Maybe you need to unlock your device?” or error 02fe in console.

 

1.将MTP设备连接至PC机

2.如果是第一次使用MTP设备需要安装以下软件,否则可以跳过此步骤:

$ sudo apt-get install mtpfs libfuse-dev libmad0-dev

建立挂载点

$ sudo mkdir /media/mtp

修改权限

$ sudo chmod 775 /media/mtp

3.挂载MTP设备

$ sudo mtpfs -o allow_other /media/mtp

如果提示设备忙,可以等一会再挂载。

4.传输文件(这时候以MTP模式进行传输),方法同USB,如:

$ cp video.mp4 /media/mtp/Movies/

5.卸载设备

$ sudo umount /media/mtp

我在Ubuntu 10.10上用Android 3.0做MTP设备是可以成功挂载的,挂载后会出现mtp的盘。

貌似不能用USB挂载,连上电脑后没有反应,sudo fdisk -l 也看不到东西

Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 5522 44047237 7 HPFS/NTFS
/dev/sda3 5523 7481 15735667+ 7 HPFS/NTFS
/dev/sda4 7482 60802 428294373 5 Extended
/dev/sda5 7482 20536 104864256 7 HPFS/NTFS
/dev/sda6 20537 27064 52436128+ 7 HPFS/NTFS
/dev/sda7 27065 33143 48827392 83 Linux
/dev/sda8 33143 53811 166014976 83 Linux
/dev/sda9 53811 55027 9764864 82 Linux swap / Solaris
/dev/sda10 55027 56243 9764864 83 Linux
/dev/sda11 56243 57459 9764864 83 Linux
/dev/sda12 57459 58675 9764864 83 Linux
/dev/sda13 58675 60802 17085440 83 Linux

Ubuntu MTP ppa

Like I was telling you a while backGvfs has been updated in Ubuntu 13.04 Raring Ringtail, bringing a new MTP backend which allows users to access Android 4.0 devices which do not support the USB Mass Storage protocol, along with many other changes. Since it’s unlikely for the latest Gvfs (1.15.2) to be backported to older Ubuntu releases, you can use a PPA which has the latest Gvfs MTP backend backported to Ubuntu 12.04 and 12.10.

Android 4.0+ gvfs Ubuntu

We’ve already covered a way to connect Android 4.0 devices that don’t support UMS to Ubuntu, using Go-Mtpfs, but that requires to mount the Android device manually. If you upgrade to the backported packages in this PPA, you’ll get seamless MTP support so when you connect an Android 4.0 device via USB, it should automatically show up in Nautilus (or Thunar, it should work with it too) without having to manually mount it. You’ll also be able to unmount it from Nautilus.

I’ve tested the packages on Ubuntu 12.10 and 12.04 with my Samsung Galaxy S2 (Android 4.2.1) and Gvfs has worked as expected (with some minor issues though, see below) and I was able to transfer files to my Android 4.2.1 phone.

Also, the packages were tested by WebUpd8 reader Bhaismachine (thank you!) in Ubuntu 12.10 using a Nexus 4 and he reported that the device showed up in Nautilus and further more, it seemed faster than before.

Issues: transferring music using Rhythmbox or Clementine didn’t work in my test (including in Ubuntu 13.04 – I’ve reported the bug HERE), but it did work with Clementine for Bhaismachine. So this part doesn’t seem too reliable for now. Also, by default the image thumbnails are not displayed in Nautilus – to enable image thumbnails, open the Nautilus preferences and on the “Preview” tab, select “Always” for “Show thumbnails” under “Other Previewable Files”.

for some reason, there are no thumbnails for images on the Android device in Nautilus and the images can’t be opened directly from the device but copying and viewing them on the computer works. These issues aren’t Ubuntu 12.10 or 12.04 specific and they even occur in Ubuntu 13.04.

In other related news, the latest CyanogenMod 10.1 nightly has added an option for switching between UMS and MTP/PTP mode (System Settings > Storage), so you can now mount Android devices via USB mass storage in Ubuntu. That means you won’t need Gvfs with MTP support if you’re using the latest CM nightly.

Upgrade Gvfs in Ubuntu 12.10 and 12.04 to get Android 4.0 support for devices which don’t support USB Mass Storage interface

 

The packages in this PPA may be unstable. Use the PPA at your own risk! There are instructions on how to revert the changes at the bottom of the post.

 

1. To add the Gvfs (and libmtp) PPA created by the Gvfs MTP backend developer in Ubuntu 12.04 or 12.10, use the following commands:
sudo add-apt-repository ppa:langdalepl/gvfs-mtp
sudo apt-get update

 

2. Then, launch Software Updater (previously known as Update Manager) and install the available updates.

3. Once everything has been updated successfully, restart your computerunlock your Android device, connect it via USB and it should show up in your file manager (tested with Nautilus and Thunar 1.6).
If you don’t unlock the Android 4.0+ device, it may show up as empty in the file manager, at least that was the case for me.

Update 13 February 2013: If your device is not currently supported, check out THIS list and if your device is on that list, add our Unstable PPA and upgrade libmtp (I’ve backported the latest libmtp from Raring to Quantal and Precise in this PPA).

Revert the changes (purge the PPA)

To revert the changes (downgrade all the packages from our Gvfs PPA to the version available in the official Ubuntu repositories), firstly install PPA-Purge with multi-arch support from the main WebUpd8 PPA.

Then, purge the PPA using the following command:

sudo ppa-purge ppa:langdalepl/gvfs-mtp 
Wait for the packages to be downgraded successfully, restart the computer and everything should go back to the way it was before adding the Gvfs PPA above.

[Android] 为Android安装BusyBox —— 完整的bash shell

三篇文章差不多,但都涉及了一些其他东西,所以都转了。

第一篇

===========================================================================
1.进入终端

1. 直接执行命令emulator -shell;

2. 在启动emulator后,通过命令adb shell进入。

2.下载busybox以及交叉编译工具

1. 首先去busybox主页 下载最新版本的busybox源代码.

2. 下载交叉编译工具: GNU Toolchain for ARM Processors

下载地址:http://www.codesourcery.com/gnu_toolchains/arm/download.html

其中第一项选择ARM EABI或ARM GNU/Linux,第二项选择IA32 GNU/Linux TAR即可。

最后得到一个arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2文件

将压缩包解压到linux下某个目录, 并设置好环境变量, 使之能找到前缀为”arm-none-linux-gnueabi-“的交叉编译工具.

3.对busybox进行相应配置

3. 进入busybox源码目录.

先执行make menuconfig命令对编译过程进行配置.  过程如下:

  Busybox Settings -> Build Options ->

     [*] Build BusyBox as a static binary (no shared libs) 这个要选上,因上这样子编译出来的busyBox才是可以独立运行的。
(/home/jo/tool/arm-2008q3/bin/arm-none-linux-gnueabi-) Cross Compiler prefex 这是交叉编译器的”路径+前缀”,要根据具体的情况来设置。
Busybox Settings -> Installation Options->
[*] Don’t use /usr        这样子编译出来的busybox才不会安装到你主机的/usr目录下。一定要选上。

4 执行make编译源码.  如果编译过程中产生无法找到头文件的错误, 可指定交叉编译器用到的头文件所在路径. 如

   $make -I ./home/jo/tool/arm-2008q3/arm-none-linux-gnueabi/libc/usr/include/

5 编译成功后将得到一个名为busybox的可执行文件.

4.把busybox移植入android

6 在Android的console下建立目录/data/busybox, 并使用下面的命令将文件busybox复制该目录中:

 adb push busybox /data/busybox

7 从Android的console进入/data/busybox目录, 为可执行文件busybox加上可执行属性:chmod 775 busybox

8 这时我们就可以使用busybox工具了, 如果希望在任何目录下都可以直接使用bosybox,则需要将路径/data/busybox export到path环境变量中:

 export PATH=$PATH:/data/busybox

9 设置环境变量之后, 在命令行输入busybox, 即可看到其用法, 如:

在当前目录及其子目录中查找名为init.rc的文件可使用以下命令:

$busybox find . -name init.rc

10安装busybox

通过执行./busybox –install -s 我们会看到出现一些错误, 原因是因为Android系统的根目录和/sbin目录是只读的.  因此我们无法把一些常用命令安装到/bin目录下, 也不能修改/init.rc文件来设置PATH环境变量.

对于如何执行命令busybox –install -s 的默认安装路径, 这里我还不太清楚, 或许跟Makefile和编译busybox的相关设置有关.

尽管我们不可以在Android里面通过执行busybox –install -s 命令来安装常用命令, 我们却可以通过另外一个方法来把常用命令安装到Android里面.

方法很简单, 可以先在外面的linux系统中执行make install命令把相关的命令提取出来. 然后再通过命令adb push ./_install/bin /data/busybox/bin 把这些常用命令复制进Android系统中. 注意: make install安装命令的所在路径可通过执行make menuconfig进行设置, 默认为./_install目录下面.

这样,我们就不用每次使用busybox提供的一个命令时, 都要在前面加上busybox了.

11 修改/init.rc文件设置环境变量.

要提醒的是, 修改PATH环境变量的时候, 应该把busybox常用命令的路径”/data/busybox/bin”放在Android的常用命令路径”/system/bin”的前面, 否则, 先查找得到的将不是busybox的命令,  可以这样设置:

export PATH /data/busybox/bin:/sbin:/system/sbin:/system/bin:/system/xbin

===========================================================================

第二篇

大家是否有过这样的经历,在命令行里输入adb shell,然后使用命令操作你的手机或模拟器,但是那些命令都是常见Linux命令的阉割缩水版,用起来很不爽。是否想过在Android上使用较完整的shell呢?用BusyBox吧。不论使用adb连接设备使用命令行还是在手机上直接用terminal emulator都可以。

一、什么是BusyBox ?

BusyBox 是标准 Linux 工具的一个单个可执行实现。BusyBox 包含了一些简单的工具,例如 cat 和 echo,还包含了一些更大、更复杂的工具,例如 grep、find、mount 以及 telnet。有些人将 BusyBox 称为 Linux 工具里的瑞士军刀.简单的说BusyBox就好像是个大工具箱,它集成压缩了 Linux 的许多工具和命令。(摘自百度百科)

二、在Android上安装BusyBox

准备:

0. 先要把手机给Root了,具体教程这里就不提供了,网上有很多。

1. 下载BusyBox的binary,打开这个地址 http://www.busybox.net/downloads/binaries ,选择最新版本,然后下载对应你的设备架构的版本,这里我下载了busybox-armv6l,下面将以这个文件名为示例。

2. 需要有一个命令行的环境,在电脑上使用adb或在手机上使用terminal emulator。

3. 连接手机和电脑,手机的USB Mode设置成None(仅充电),并且开启USB调试模式。

安装:

1. 将busybox-armv6l重命名为busybox

2. 将busybox传入手机的SD卡,可以使用下面的命令或自己想其他办法。

打开terminal(Linux,Mac)或cmd(Windows)

adb push ~/Desktop/busybox /mnt/sdcard

其中的~/Desktop请根据自己的情况替换成正确的路径

3. 输入以下命令,为了在/system目录写入文件

adb shell
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

使用 ls 检查一下 /system 里是否有 xbin 目录,没有的话输入 mkdir xbin 创建,因为本示例是要把busybox安装到 /system/xbin 。

4. 复制 busybox 文件到 /system/xbin,并为其分配“可执行”的权限

cp /mnt/sdcard/busybox /system/xbin
chmod 755 busybox

5. 这时就可以使用 busybox 的命令了,例如以前没有清屏的clear命令,现在只需输入 busybox clear 就可以实现清屏功能,使用完整版的 ls 只需输入 busybox ls 。

但是每次前面都加上个busybox太麻烦了,所以我们还要继续完成安装。

在 /system/xbin 下输入

busybox –install .

如果想安装到别的目录,则把点替换成别的路径。

至此就安装完成了,比较一下原来的 ls 命令和 busybox 里的 ls 命令。

常见错误:

1. 如果安装时出现这样的错误,

busybox: /bin/zcat: No such file or directory

busybox: /sbin/zcip: Invalid cross-device link

说明没有输入安装路径,正确的示例 busybox –install /system/xbin

2. 如果出现这样的错误,

cp: /system/xbin/busybox: Read-only file system

说明没有正确输入上面第三步的mount命令。

小技巧:

1. busybox 里有 ash 和 hush 还有 sh 这几种 shell,在命令行输入 ash 或 hush,可以像在 bash 里那样,通过按上下键选择刚才输入的命令。

2. android系统本身就有ls命令,busybox里也有ls,输入ls时调用的是android的ls,那么想用busybox的ls就要每次都在前面加个busybox吗?不用,使用alias命令可以搞定。

alias ls=’busybox ls’

同样的,cp、mv等二者都有的命令都可以这样搞定。也可以通过修改 /init.rc 来解决。

===========================================================================

第三篇

 

android 自带的toolbox

shell实现分为两部分:

一、shell解释器和内置命令

源码位于system/core/sh目录下,主要完成shell命令的解释查找,对于builtins.c中包含的内置命令,直接执行,对于toolbox的扩展命令,间接调用toolbox程序完成。

二、toolbox扩展命令

主要完成扩展命令的执行,每一个扩展命令对应一个name_main函数,如ls命令,对应ls_main函数。同时,每一个扩展命令都由一个system/core/toolbox/目录下面的.c文件实现。toolbox.c会根据这个目录下面的.c文件生成tools.h头文件,并在system/core/toolbox/Android.mk文件中为每个命令生成指向toolbox的连接。toolbox的实现结构使它扩展一个命令很容易。

假设现在我们自己想手工添加一个shell命令mycommand,只要在system/core/toolbox/目录下面新建一个mycommand.c文件,并在里面实现一个mycommand_main函数,然后在system/core/toolbox/Android.mk中添加mycommand.c即可。Android.mk会自动把它编译进toolbox程序,并在编译生成的Android系统/system/bin目录下为这个命令生成一个指向toolbox的连接。

 

替换toolbox为busybox

接下来翻译一下网上的一篇文章,借助它,可以把Android自带的toolbox替换成busybox。

Installing Busybox command line tools

Android系统中安装busybox命令行工具

本文简单地介绍了怎么把busybox安装到Android的文件系统中去。如果你想直接安装,可以从下面的地址下载我已经预编译好并在Android2.1系统上试验成功的busybox,然后直接跳过下面的安装步骤。

下载在Linux公社的1号FTP服务器里,下载地址:

FTP地址:ftp://www.linuxidc.com

用户名:www.linuxidc.com

密码:www.muu.cc

在 2011年LinuxIDC.com3月Android自带的toolbox分析及扩展

下载方法见 http://www.linuxidc.net/thread-1187-1-1.html

一、编译busybox

1、下载busybox的最新版本,本文写作时最新版本是1.13.3。

下载地址:http://www.busybox.net/

2、解压源码:

tar jxf busybox-1.13.3.tar.bz2

3、运行menuconfig对busybox进行配置

cd busybox-1.13.3/

make menuconfig

4、在menuconfig中设置以下选项

Busybox Settings –> Build Options –> Build Busybox as a static binary (no shared libs)  –  Enable this option by pressing “Y”

Busybox Settings –> Build Options –> Cross compiler prefix  –  Set this option equal to “arm-none-linux-gnueabi-”

Busybox Settings –> Installation Options –> Don’t use /usr  –  Enable this option by pressing “Y”

5、把交叉编译器的地址导入到环境变量:

export PATH=/opt/arm/arm-2007q3/bin:$PATH

6、编译busybox

make

二、安装busybox

把busybox安装到Android系统中去,做这几步:

1、在Android系统根目录下创建一个/bin目录。

mkdir /<path-to-Android-fs>/bin

2、把编译出来的busybox复制到/bin目录下

cp busybox /<path-to-Android-fs>/bin

3、把busybox安装到Android机器中

cd /bin

./busybox –install

三、把busybox作为默认shell

需要像下面这样编辑一下init.rc

1、编辑console服务,让它默认运行busybox

service console /system/bin/sh  ->  service console /bin/sh

2、把busybox路径加入到环境变量中

export PATH /sbin:/system/sbin:/system/bin:/system/xbin  –>  export PATH /bin:/sbin:/system/sbin:/system/bin:/system/xbin

注:

我使用busybox时,只是想简单地增加一些命令,把toolbox一些功能不是很全的命令替换掉,所以操作上没有上面说的那么复杂。下面是我的替代方案,可以试一下:

1、把busybox复制到/system/bin目录下。

adb push busybox /system/bin

2、把要添加的命令通过ln建立到busybox的连接。

比如,Android自带的toolbox是没有test这个命令的。我们要添加test命令就可以:

cd /system/bin

ln -s busybox test

这样,用户通过机器上的shell执行test命令时,就会调用busybox中实现test功能的applet。

对于一些原有的命令,如ls、chown等,如果不想用toolbox,也可以把它们的连接目标指向toolbox,拿chown来举例。

cd /system/bin

rm chown

ln -s busybox chown

这样做,最大的好处就是保证对系统的改动最少,又可以最大限度的扩展shell功能。

===========================================================================

英文文档

To build busybox

Download the latest version of busybox from the following website. At the time of writing the latest version was v.1.13.3.

http://www.busybox.netExtract the busybox source:

tar jxf busybox-1.13.3.tar.bz2Configure busybox by running menuconfig

cd busybox-1.13.3/
make menuconfigIn menuconfig set the following options

Busybox Settings –> Build Options –> Build Busybox as a static binary (no shared libs)  –  Enable this option by pressing “Y”
Busybox Settings –> Build Options –> Cross compiler prefix  –  Set this option equal to “arm-none-linux-gnueabi-”
Busybox Settings –> Installation Options –> Don’t use /usr  –  Enable this option by pressing “Y”Export path to where the cross-compiler is located on the host, for example:

export PATH=/opt/arm/arm-2007q3/bin:$PATH
Build busybox

make

Installing Busybox
——————————————————————————–

To install busybox in the target file-system

Create a /bin directory in the target file-system. For example:

mkdir /<path-to-Android-fs>/binCopy the busybox binary to the /bin directory in the target file-system

cp busybox /<path-to-Android-fs>/bin Install the busybox command line tools on the target by executing the following commands:

cd /bin
./busybox –install
Make the Busybox shell the default shell

 

——————————————————————————–

To make the busybox shell the default shell, edit the file “init.rc” in the target file-system as follows:

Edit the console service so that it runs the busybox shell and not the default shell by replacing:

service console /system/bin/shWith:

service console /bin/shAdd the path of the busybox command line tools to the system path variable by replacing:

export PATH /sbin:/system/sbin:/system/bin:/system/xbinWith

export PATH /bin:/sbin:/system/sbin:/system/bin:/system/xbin

9300rom

ROM说明:官方一体线刷包!

至于本ROM更新内容大家可以看论坛其它用户,本人9300出售给别人了,现在只能看你们刷了!
第一时间上传后就分享过来了,没别的,只希望下载的朋友可以回复支持一下!

设备名称: Galaxy S 3 (International)
型号: GT-I9300
地区: CHN
ROM版本: I9300ZCUBMK2
系统版本: 4.3
更新时间: 04.11.2013
Changelist: 1969761
百度网盘首发地址: http://pan.baidu.com/s/11jV1t
有一些朋友下载后不能解压,我特从百度网盘下载后测试,文件一切正常!
如果你不能解压,请对比一下MD5信息:
MD5 :D322C812CF8A26A34AA534BE13E151CD
SHA1 :D98A032A2EFB00DC2BFA7CD28A2E1F103901FF75
CRC32 :39F5CB41
百度网盘下载地址一:4.2013.09.30_4.1.2_I9300ZSEMI1_I9300OZSEMI1_BRI_HongKong.zip
KIES_HOME_I9300ZSEMI1_I9300OZSEMI1_1386718_REV00_user_low_shi.tar.md5 MD5:8f95560939c45440d28282e578fd8c3d
固件版本: I9300ZSEMI1(4.1.2)
地区: 亚洲
国家: 香港/台湾
定制厂商: 非定制
编译日期: 2013.09.02
基带: (待确定)
CSC: I9300OZSEMI
更新列表: 1386718

android pm用法

usage: pm list packages [-f] [-d] [-e] [-s] [-e] [-u] [FILTER]
pm list permission-groups
pm list permissions [-g] [-f] [-d] [-u] [GROUP]
pm list instrumentation [-f] [TARGET-PACKAGE]
pm list features
pm list libraries
pm path PACKAGE
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
pm uninstall [-k] PACKAGE
pm clear PACKAGE
pm enable PACKAGE_OR_COMPONENT
pm disable PACKAGE_OR_COMPONENT
pm disable-user PACKAGE_OR_COMPONENT
pm set-install-location [0/auto] [1/internal] [2/external]
pm get-install-location
pm createUser USER_NAME
pm removeUser USER_ID

pm list packages: prints all packages, optionally only
those whose package name contains the text in FILTER. Options:
-f: see their associated file.
-d: filter to only show disbled packages.
-e: filter to only show enabled packages.
-s: filter to only show system packages.
-3: filter to only show third party packages.
-u: also include uninstalled packages.

pm list permission-groups: prints all known permission groups.

pm list permissions: prints all known permissions, optionally only
those in GROUP. Options:
-g: organize by group.
-f: print all information.
-s: short summary.
-d: only list dangerous permissions.
-u: list only the permissions users will see.

pm list instrumentation: use to list all test packages; optionally
supply <TARGET-PACKAGE> to list the test packages for a particular
application. Options:
-f: list the .apk file for the test package.

pm list features: prints all features of the system.

pm path: print the path to the .apk of the given PACKAGE.

pm install: installs a package to the system. Options:
-l: install the package with FORWARD_LOCK.
-r: reinstall an exisiting app, keeping its data.
-t: allow test .apks to be installed.
-i: specify the installer package name.
-s: install package on sdcard.
-f: install package on internal flash.

pm uninstall: removes a package from the system. Options:
-k: keep the data and cache directories around after package removal.

pm clear: deletes all data associated with a package.

pm enable, disable, disable-user: these commands change the enabled state
of a given package or component (written as “package/class”).

pm get-install-location: returns the current install location.
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media

pm set-install-location: changes the default install location.
NOTE: this is only intended for debugging; using this can cause
applications to break and other undersireable behavior.
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media

 

设置设置默认安装位置为SD 卡方法

root@android:/ # pm set-install-location 2

利用笔记本无线网卡共享上网

无线网卡对联,也就是所谓的 HOC 方式。我的笔记本无线网卡是Intel(R) PRO/wireless 3945ABG,操作系统是Windows XP sp2,VISTA的或者WINDOWS 7在后面有写到。(不是所有的无线网卡都支持,不过大部分都支持。),今天晚上成功将M8用wifi与笔记本电脑连接成功,M8可以通过笔记本共享上网,也可以用飞鸽传送文件,非常方面,推荐中。(此方法由魅族论坛网友samogogo提供)

XP:
1、“网上邻居”右键“属性”,“无线网络连接”右键“属性”,选择“常规”旁边的“无线网络配置选项卡”,点右下角的“高级”,将“仅计算机到计算机”选上,还有将“自动连接到非首选网络”前面打勾。完成后点“关闭”
2、回到”无线网络配置“,点中首选网络下面的添加按钮,自行输入网络名,本例中为“Test”,将“自动为我提供密钥”的对号去掉,将数据加密选项改成“已禁用”,确定返回。
3.共享本地连接:“本地连接”右键“属性”,选择“高级”选项卡,将“Internet连接共享” 下面的两个“允许”前面打勾,网卡将自动配置无线网卡IP为192.168.0.1,子网掩码为255.255.255.0。双击你的无线网络,会发现多了一个“Test”的无线网络出来,点击连接,然后打开你的M8搜索网络,如果能搜索到samogogo的无线网络,则恭喜你,配置无线网络成功。(如果你是宽带拨号,只需要在你的宽带拨号的属性里“高级”选项卡共享下网络也一样。)

VISTA和WINDOWS 7的用户:
1.点击左下角的球球,“网络”上右键“属性”,进入“网络和共享中心”,VISTA点右边的“查看状态”按钮,WINDOWS 7点左边的“无线网络管理”按钮。
2.进入“无线网络管理”窗口,点左边的“添加”,OK,按向导的方法来配置吧。
“创建临时网络”–“下一步”–填写上你要的无线网络名,选择无身份验证,开放式,保存这个网络,下一步——-“关闭”,OK了。
3.第三步是共享本地连接网络,和XP类似。