If I change a .mk or a .xml file in the android source code, how do I send this updated file to the device? Do I first rebuild the source tree? Or is building not necessary? After building/not-building, do I use adb push or adb sync or do I have to reflash the device?
No you can't just push the these files as these files are merged in the img file like boot.img ,system.img etc. so you need to find out that in which img file these .xml files are added. Then you just need to make that img file like
make bootimage -j4
and flash the image to the device
In case you did't figure out then you need to rebuild the source tree.
Yes building is absolutely necessary. See https://source.android.com/setup/build/building for more complete information but here are some quick notes:
If using mm or related commands you can usually follow it up with adb remount (needed just once per boot) and then: adb sync, adb shell stop, adb shell start.
If you built the entire tree via a command such as lunch aosp_xyzdevice-eng then you should probably use fastboot or other raw flashing tool provided by your SOC to flash the entire system image (and possibly boot or other images) to the device.
Related
My Project runs C++ test cases on Android devices. An exectuable gets generated and along with that, couple of shared object files also gets copied over to the device and the executable is then run. Till now, all those data were being copied over to /data/local/tmp folder. After the test cases are run, the content from /data/local/tmp is deleted using adb shell command. With Pixel 2 devices, I am able to copy the exe and shared object files to the tmp folder, but unable to delete them once the test cases are completed. I tried using /data/local/temp folder, but I am unable to push files to that folder. Tried using /sdcard but it does not allow the exe files to be executed. I am clueless as to which specific directory I should be using to run my native test cases on Pixel 2 devices. Does anyone has any pointers? Please help.
if you create files from adb, uid:gid is set to 2000:2000 and permissions of /data/local/tmp is 0771, this means you always can remove your own files. There is no other location for this, you must have messed with permissions
adb shell
touch /data/local/tmp/my-file
ls -an /data/local/tmp
rm /data/local/tmp/my-file
I am developing an application using ionic framework.
The app creates files (*.json) and stores them in /data/user/0/ when i verify whether they exist or not, the result was true which means the files exist in the mentioned directory and I can access and modify their content without problem, but when I check the directory with a file manager or from the computer, no result, the directory is empty.
Could someone tell me what should I do?
use adb to copy the file. Even if it's in root dir, u should have access to it via adb.
Do adb pull data/user/0/filename.json path_on_ur_comp.json.
this will copy the file to the directory you define in the 2nd parameter.
// EDIT:
adb is part of the Android SDK, stands for Android Debug Bridge.
You can use this for MANY MANY different reason but of course, the "main" reason is to debug Android devices. You can use it to transfer files in your case.
In Windows, it's located here:
C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools\adb
In Mac, it's lcoated here:
/Users/USERNAME/Library/Android/sdk/platform-tools/adb
Depending on which OS you use, open that either with Terminal (Mac) or Command Prompt (Windows).
Once you do that, run the following command:
For Mac:
adb pull data/user/0/filename.json /Users/USERNAME/Desktop/somefile.json
For Windows:
adb pull data/user/0/filename.json c:\Users\USERNAME\Desktop\somefile.json
This will copy the file and put it on your desktop
I pulled out a file from the android sdcard using adb and it seems it goes to c:\documents and settings\userName by default. I don't know how it got set to this folder since this is not where adb is installed, but probably has got something to do with the fact that both the workspace and .android folders are located here. How do I change this default location for pull command of adb?
The default directory for adb pull or adb push seems to be the current directory (aka . ).
If you issue a command such as the following, not specifying the target directory
adb pull /boot.txt
the file (provided it exists) will be copied to the current directory.
Windows users:
Take notice of the following: If you are using Windows (Vista or newer), chances are that if the current directory requires elevated privileges to write on, Windows will silently replicate the directory structure of your current directory in a special folder called VirtualStore and will copy your files in it.
The full path for VirtualStore is: %LOCALAPPDATA%\VirtualStore, which most likely will translate into C:\Users\<account_name>\AppData\Local\VirtualStore.
So, in the following scenario,
C:\> cd "C:\Program Files (x86)\MyCustomADBInstallLocation"
C:\Program Files (x86)\MyCustomADBInstallLocation> adb pull /boot.txt
your file boot.txt will end up in this folder
C:\Users\<account_name>\AppData\Local\VirtualStore\Program Files (x86)\MyCustomADBInstallLocation\
you can mention the destination location for adb push/pull, see example:-
adb push a.txt /data/local
adb pull /data/local/a.txt .
. means present directory.
or
adb pull /data/local/a.txt C:\
Hope this helps.
i'm using linux, and noticed that if i opened the terminal as root, its opened # home. when i pull items, it dumps to that repository, meaning to my "home" directory. will try opening terminal in a different folder and running adb pull from there to see if that makes the files dump to the folder terminal is opened in.
I want to change the init.rc file of an android pad. But after I change it and reboot the system, the original init.rc comes back.
How can I make the change to the init.rc persistently without rebuild the system (since I don't have the source code of the system)? Or is there any way to work around?
Unpack the uramdisk using following command in host PC(Linux)
mkdir /tmp/initrc cd /tmp/initrd
sudo mount /dev/sdb1 /mnt
sdb1 is partion where uramdisk/uInitrd resides.
dd bs=1 skip=64 if=/mnt/uInitrd of=initrd.gz
gunzip initrd.gz
At this point running the command file initrd should show:
mkdir fs
cd fs
cpio -id < ../initrd
Make changes to init.rc
Pack uramdisk using following commands:
find ./ | cpio -H newc -o > ../newinitrd
cd ..
gzip newinitrd
mkimage -A arm -O linux -C gzip -T ramdisk -n "My Android Ramdisk Image" -d newinitrd.gz uInitrd-new
A number of Android devices include code to prevent root modifications to the system files. The way this is done is by using the recovery partition. On reboot, they basically restore the system partition using the recovery image. If your system is doing that then you cannot make persistent changes - the best you could do would be to hook up something to run after reboot to re-apply your change. In CyanogenMod they had hooks in the init.rc to run sdcard scripts if found. Perhaps you can create an app or widget to then launch a script to make the mods required using a setuid root script from the data partition. Without building your own ROM you are quite restricted in this area.
Possibly you could fetch the recovery image and try unpacking that, making your changes and repacking and flashing it. But make sure you can recover with fastboot before you try this.
Try this site:
http://bootloader.wikidot.com/linux:boot:android
Read the section at the bottom:
•The Android boot image: boot.img
◦Unpack, re-pack boot image: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images#Background
When an android system boots, uboot unpacks a special compressed ball of files in your boot partition called 'uRamdisk' to RAM, and defines those files to comprise the root directory of the system. uRamdisk normally contains a bunch of directories (system, data, media, etc.) that serve as mountpoints for partitions that contain the files that go in them, but also has some very basic files vital to your system, including the init binary and startup scripts like init.rc.
when you edit the init.rc, you've actually just edited the unpackaged copy of init.rc that resides in your RAM. To really change it then, you have to copy your uRamdisk, extract it, edit the init.rc from there, repackage uRamdisk and then replace the new one with the old one in /boot.
Try looking up the 'xuramdisk' and 'mkuramdisk' scripts, these make the process very simple.
Your root partition (where /init.rc lives) is a ramdisk which is unpacked from an initrd file and mounted every time your device boots. Any changes you make are to the ramdisk only, and will be lost on the next reboot.
If you can get the initrd file, you can mount it on your Linux host system, modify the files there, unmount it, and write it back to your Android.
The initrd file exists in its own partition on the device. If you can figure out which partition it is, you can grab it from the device onto your host, mount it, modify it, and write it back to the device. This is what tripler was talking about above.
In general, modifying boot.img is something that only system developers do. If you're building the entire Android system, you'll have access to the necessary source code. My workflow for this looks like this:
# Modify init.rc
m -j8 bootimage_signed
adb reboot bootloader
fastboot flash boot $OUT/boot.img
fastboot reboot
I don't know if you are still trying to do this but without knowing your exact device nobody can give you an exact answer.
Try taking a dd image of all your internal partitions and use some scripts like those included with android kitchen on xda forums. Your recovery and boot partitions will both have a ram disk but odds are you want to modify the init.rc in the boot.img not recovery, unless you only want the changes present in recovery mode.
The unyaffs thing doesn't apply to all devices and most devices have different partition layouts so you have to figure out which is boot and what type of fs it is. Maybe if you give your device specs you can get a better answer.
Please note that it may be easier for you to use an app like Scripter to run a script at boot time than modify this file.
Before following #tripler's instructions above you need a file called boot.img which can be extracted by (run on rooted Android device, untested without root):
dd if=/dev/block/platform/<someplatform>/by-name/boot of=/sdcard/boot.img
Then connect your Android to your computer and copy the boot.img file from there.
Script:
http://linuxclues.blogspot.ca/2012/11/split-bootimg-python-android.html
Here is a modified, easier to see version of tripler's instructions (assuming boot.img is in tmp):
cd /tmp
mkdir fs
# Now use the linked script above to split the boot.img file into ramdisk.gz and kernel
python split_boot_img.py -i boot.img -o parts
cd fs
gunzip -c ../parts/ramdisk.gz | cpio -id
# make changes to init.rc
At that point you will have to rebuild the boot.img back together before reflashing, which will be device-specific. Can't help you with that, sorry!
You have to edit/change the init.rc before building your Android pad file system. This is the preferred way, and always works.
Disk Utility in OSX easily mounts an SD Card image as a device, but not so the other img files.
I want to get the database I just created in the Android Emulator off the drive and into my osx file system.
I updated my system with qemu using macports but no combination I try succeeds. Anyone figured out how to do this?
Obviously one way I can do this is run the app on my phone than mount the phone as a USB drive. But I don't wanna. I wanna get it off the drive the emulator uses :-)
Thanks in advance, folks.
Michael
Can't you just use adb to pull the database off of the emulator? I actually just answered a similar question... here it was:
The database for a specific app lives in /data/data/[packagename]/databases
The packagename is the package you define in your manifest, for instance /data/data/org.vimtips.supacount/databases/counts.db.
You can view it with adb shell and type sqlite3 /data/data/org.vimtips.supacount/databases/counts.db
Or you can pull it from the device to look at it with a third party utility, with a command like adb pull /data/data/org.vimtips.supacount/databases/counts.db ..
Use the File Explorer in DDMS (from Eclipse SDK), you can see the whole file system there and download/upload files to the desired place. That way you don't have to mount and deal with images, and no adb commands either