Android adb sideload command - android

I am reading a tutorial on the sideload command at link.
It contains the steps of rebooting into recovery mode and using adb sideload [file].zip.
My question is that what does sideload actually do with that zip file ? In the past I have compiled AOSP and flashed a device using
adb reboot-bootloader
adb fastboot flashall -w
Is sideload trying to achieve something similar to the above ?
Edit:
I think my confusion relating to sideload stems from my lack of understanding of how Android's memory is structured. I found two links.
First is a link that explains Android partitions : partitions
Second is a SO answer, that explains Android's memory: memory
Now my understanding so far is this :
Android has RAM and ROM. ROM is divided into several partitions, namely, /system, /data, /boot, /recovery, /cache, /misc and /sdcard.
Now the link relating to sideload states that this command installs a zip file.
What I don't understand still is that, is this zip file, going to replace the entire ROM in Android ? Namely, will it have to have the right partitions as in the list above ?
This also makes me confused about a similar command 'fastboot flashall'. I know when I run it, the terminal goes by saying its writing to several of the partitions. So my questions boil down to these :
1) Is sideload replacing entire ROM ?
2) Is the related command 'fastboot flashall' also replacing entire ROM ?
3) Are there ways to replace select partitions ?
Thanks.

Yes and no. adb reboot-bootloader is used to get yoi into fastboot mode ard sideload is used to apply updates to a system which can be (and is oftenly) used to overwrite a stock OS. I used sideload for exactly that, my fairphone also delivers a small utility to factory reset every partioin of it using adb and sideload (this is the Windows version from scroll down here). Consider chris stratton's comment. You can look into adb backup and adb restore to only deal with user data and apps. Click me tenderly, click me hard. Pay attention as to apps can opt out of this - explanation in this brilliant answer by Izzy.
Depends but more or less yes. fastboot flashall is typically used to flash the recovery partition only to boot from there and continue with sideload (see 1.).
There definitely are, but I'm not able to do it on my own. The referred utility does exactly that. It should be possible to figure out the exact commands or find a similar utility for your manufacturer. I misused mine to flash everything I needed for me. To do so, i just replaced the respcetive .img files such as boot.img

Related

ADB root access but Custom recoevery not an option, how can I root and flash gapps

So as the titles suggests, I have a device whos bootloader is unlocked and adb has root access. Running android 7.0.
Custom recovery isnt an option as there is no TWRP for this android device so I am looking to both root the OS as well as flashing gapps and cant figure it out.
Does anyone have any suggestons on how I can install and update su and install gapps over adb shell?
Any help would be greatly appreciated.
You did not say what device you're using, but the following approach should be universal to all devices. Note that i do not take responsibility of what you do with your phone. Flashing wrong images can result in soft- or hard-bricks, so take care. But on the other hand, this method is rather popular and works for a lot of people, so i would suggest to try it out.
First of all, there were files which were called cf-auto-root files. With them you can easily root your phone.
Since the cf-auto-root provider has beeen superseded by firmware.mobi this method has become even easier. So if you visit https://desktop.firmware.mobi/, you can select your device, select the proper firmware and then configure a package which contains the firmware and the auto-root file. Now just donwload this file.
I could explain how you have to go on from this point, but the .zip archive contains literally everything you need. Just follow the steps inside the README.txt.
Once you got your phone rooted, there are several approaches to flash things like gapps without the need of a custom recovery. Just google for apps with such options, e.g. "Flashify" or "FlashFire". Just take the app which fits your needs best.
If you actually don't know where you can get flashable gapps archives, visit http://opengapps.org/.
Last tip: If you got your phone bricked, just try to flash your firmware agian via ODIN (without auto-root i would suggest), to restore everything to "default".

Can't pull files using adb

I've had a look at other questions but can't seem to find an answer. I'm trying to pull all the files (especially /data) from my android phone but can't seem to due to permission issues.
I am only able to get into download mode and system recovery mode on the phone (a Samsung Galaxy s3) and nothing else (installed a wrong custom rom :( hense the very limited use ). I need to backup all the data before applying a factory reset.
I've tried:
adb root
adb cannot run as root in production builds
adb pull /data ~/Desktop/backupfolder
pull: building file list...
0 files pulled. 0 files skipped.
Also adb shell doesn't allow me to pull (it says device not found even though outside the shell the device is detected). So running su from adb shell is useless if the data can't be pulled. Moving the data doesnt help.
Please help! Apart from download mode and system recovery mode, the phone is dead so solutions requiring apps don't apply.
The most probable cause might be that your phone is not rooted, so you will not be able to remount the partition for read/write access.
There is a particular stack overflow page for remounting a rooted device into RW mode.
link
Remounting is basically reloading your file system so you may read or write into the file system like any other file systems.
You may need to root your phone (please note that rooting will void your warranty).
Rooting lets all user-installed applications run privileged commands typically unavailable to the devices in the stock configuration. Rooting is required for more advanced and potentially dangerous operations including modifying or deleting system files, etc.
In normal production builds root is disabled by default, so you need to install a third party rooting software to get access to this privileged mode.
The entire process of rooting is beyond explanation in this post, but you can check this post from XDA
You need to be very careful while rooting coz it may brickyour phone.
Similar XDA posts are available on google if you search with your exact device name.
I managed to fix the problem!
Downloaded and installed Kies, which also installs the appropriate Samsung drivers. Then ran a firmware installation from there (Tools > Firmware Upgrade and Initialization).
Make sure you have the model number and S/N handy (written on inside of phone).

Android command list

I have many questions about Android command. I do not know where I should start But, anyway, I have put all question related Android commands. Here ;
Is subset of Linux commands come in Android by default ? Or, Are we installing something ?
In system/bin, there are lots of commands. Where can I find their meaning ? I have tried man, but man is not built in.
Can I start and stop application via start and stop command ?
Why cannot I run the reboot from terminal emulator ? The error permission is denied.
NOTE : feel free to reedit the question, if you see meaningless part.
Is subset of Linux commands come in Android by default ? Or, Are we installing something ?
A subset exists by default within the system. Things like ls, cd, mkdir, cat etc... are present. You can gain access to a wider range by installing Busy Box on a rooted device, as stated by Zac.
In system/bin, there are lots of commands. Where can I find their meaning ? I have tried man, but man is not built in.
The ADB Page is a good place to start. That covers many of the basic ADB and shell commands. It states near the bottom:
"For a complete list of commands and programs, start an emulator instance and use the adb -help command."
So you can use adb -help on an emualator or device to see a full list of the ADB and shell commands (note I think this list will be android specific commands only, it won't include things like cd,ls and other basic unix commands).
Can I start and stop application via start and stop command ?
No, it states on the ADB dev page:
start ........ Starts (restarts) an emulator/device instance.
stop ........ Stops execution of an emulator/device instance.
To start an application you'll use the am utility iirc it will look something like am start com.your.packagename It's been a while though, I might have syntax wrong. The instructions are listend if you issue the am command by itself with no params in a shell.
Why cannot I run the reboot from terminal emulator ? The error permission is denied.
The system prevents applications from rebooting the device unless they are signed with the same key as the OS. When you use the terminal emulator you are restricted to whatever permissions that application has declared. The reboot permission is not granted to any third party applications, so it won't work correctly from any terminals. You could probably do it if your device was rooted and you used su though
EDIT:
Here is another good resource that lists more of the shell commands
There are not many Linux commands included in android, however if you are rooted you can easily install busybox which has a large range of linux commands.
You need to have root access to reboot your device via the command line (to prevent any old app being able to do it)

Android Shell Command (or in adb) to automatically reboot and restore backup using cwm recovery

Looking for the command (or steps) to create a shell script on android that tells the device to reboot into recovery mode and automatically restore a backup located in the /sdcard/clockworkmod/backup/ folder. I know the reboot is:
reboot recovery
But I imagine there is something else I either need to add to that line or perhaps create a file somewhere that instructs cwm to automatically restore a backup and reboot.
Found my own answer... For the folks in the ether...
Install ROM Manager Premium (small $$).
Use Koush's test rom manage project (https://github.com/koush/TestRomManager) to connect to ROM Manager and essentially ask it to reboot the device into recovery and do a backup. The system is actually incredibly powerful in that you can do some kool stuff over the air. This is a good setup for internally managed devices... You can even run your own update.zip scipts...
Optionally you can add a couple of exec lines to click ok automatically to the ROM Managers popup "do you want to reboot now?".
Thats it. Lots of research, as usual a Frankenstein of source from a great world full of devs.
If you follow the comments on this file, you will manage to do what you want
https://android.googlesource.com/platform/bootable/recovery/+/fadc5ac81d6400ebdd041f7d4ea64021596d6b7d/recovery.c
Specifically, you will have to deal with the file
/cache/recovery/command
And include there the command you want to issue. Root access is needed to do so.
Alternatively, if your recovery admits it (CWM, TWRP) you can just use the recovery command through adb once you rebooted there.

How to create C++ executables for flashing ROMs?

I want to create C++ executables to flash ROMs over ADB on android phones, can anyone help me on this?
I have a basic knowledge of C++ but cannot understand from where I should start
The logic is
Initialize header files-->Initialize ADB service-->Start ADB shell-->Flash the .img files using flash_image binary--> ADB reboot
Can anyone give me a simple example for flashing boot image?
I m unaware what header files should I include, which compiler should I use.
created a new thread as I didn't find anything regarding this
Thank you
adb has nothing to do with flashing ROMs, adb is the debugger interface, which requires system up and running on your phone. And trying to reflash the ROM image with fully running system is like performing a heart surgery without an anaesthetic.
There are two basic ways of reflashing of ROM images correctly:
update.zip
fastboot
The former one is when you copy/download your ROM image as update.zip to the sdcard and then use recovery to update the system. This usually involves users pushing some buttons and powering phone off and on back again. This is the best method, because the update file is already safely stored on the sdcard, can be checked and verified, and the chance of bricking the phone is slim to none.
The second one is when you connect your phone to the PC, switch it to fastboot mode with 'adb reboot bootloader' (or switching off/on and holding some buttons), and then use fastboot to perform ROM update magic. Problem is, when using fastboot you need a very reliable USB connection. Any communication error and the phone is bricked. This is why I don't use and don't recommend fastboot method to reflash ROMs.
If you don't mind bricking your phone using fastboot method, the C++ program would be quite simple.
unpack ROM image somewhere (if you have it packed inside the program)
issue exec() or system() calls to run 'adb reboot bootloader' and then 'fastboot flash*' commands, then, finally 'fastboot reboot'
if you have done everything correctly (catch and process the output of adb and fastboot to check the results), your device will get reflashed and rebooted.
Finally, I'd like to stress again, reflashing ROMs with fastboot is quite dangerous, and I'd recommend to avoid it if possible.

Categories

Resources