In this recipe, we will modify the default search text in the quick search widget. The aim of this recipe is to make the reader comfortable with making changes, compiling them, and testing those changes.
The search widget's code is in the directory named QuickSearchBox
under ANDROID_SRC/packages/apps/
. Navigate to this directory and open up ANDROID_SRC/packages/apps/QuickSearchBox/res/drawable/text_field_search_empty_google.xml
.
<item android:drawable="@drawable/hint_google" />
with
<item android:drawable="@drawable/packt" />
drawable-hdpi
, drawable-ldpi
, and drawable-mdpi
.QuickSearchWidget
application. In a terminal, as usual, navigate to the Android source directory, include the environment setup and lunch the emulator target. Issue the following command:mmm packages/app/QuickSearchWidget
adb
shell. We need to remount the system partition as read/write, since system applications are installed on to this partition which is mounted read-only. To be able to write a new executable of the QuickSearchWidget
application, and without rebuilding and reflashing the entire operating system, we will simply "push" the generated APK onto the remounted directory./system
partition is mounted. In an adb
shell, execute the following command:cat /proc/mtd
The output will be similar to the following:
dev: size erasesize name mtd0: 0c200000 00020000 "system" mtd1: 0c200000 00020000 "userdata" mtd2: 04000000 00020000 "cache"
/system
exists in mtd0
. To remount as read/write, in an adb
shell:mount -o rw,remount -t yaffs2 /dev/block/mtd0 /system chmod 777 /system/app
adb
shell and navigate to ANDROID_SRC/out/target/product/generic/system/app
. This is where the built APK is stored.adb push QuickSearchWidget.apk /system/app
This will install the new widget. The change should be visible on the emulator:
The mmm
command selectively builds code. The argument to it is the path to the source directory containing an Android.mk
file. The path should end with the name of a target that can be built. For example, if you open the Android.mk
file, the target is identified by the LOCAL_PACKAGE_NAME
tag.
As we have seen in earlier recipes, the system partition is mounted as read-only for security reasons. To install a system application, we need to remount this. The remount can only be done by a root user. On the emulator, ADB runs as root by default.
The side effect of simply pushing an APK to /system/app
results in its installation.
The different drawable
directories are used based on different screen densities. This has the same meaning as the directories used when writing SDK-based apps.
18.222.111.24