How to Restore/Change Android ID in Android 6.0 Marshmallow - Nexus 6 General

I haven't found this posted anywhere so figured it might be useful to others as well.
When you reinstall Android it is set up as a new device with a new unique Android ID. This ID is often used by apps to identify the device - for example all my internet banking apps use it to register the device with the service. To avoid having to re-register after reinstall the ID can be changed to what it was previously.
The Android ID backup/restore function is included in Titanium Backup. However, the Settings Storage (com.android.providers.settings) doesn't seem to be backed by a traditional SQLite database in Android 6.0 Marshmallow - /data/data/com.android.providers.settings/databases/settings.db is empty (0 bytes) on my device. Therefore the Android ID cannot be restored/changed by the usual tools (including Titanium Backup).
I have found a way to query/update the settings database via adb though as follows:
Get current Android ID:
Code:
adb shell content query --uri content://settings/secure --where "name=\'android_id\'"
Normally, you would update the value as follows:
Code:
adb shell content update --uri content://settings/secure --bind value:s:<new_android_id> --where "name=\'android_id\'"
However, this wasn't working for me - I kept getting the same ID when querying after update. So, I tried removing the current record and re-inserting it with the new ID:
Code:
adb shell content delete --uri content://settings/secure --where "name=\'android_id\'"
adb shell content insert --uri content://settings/secure --bind name:s:android_id --bind value:s:<new_android_id>
Which worked just fine

Any idea if this works going from CM to Stock or the reverse? Or does it only work stock to stock?
I ask because my two factor auth token for work is on my CM, but if I restore it on stock using Titanium Backup, it works oddly. I wonder if changing the ID would make it work better on stock

Sweet. Any idea how to do this to get the device ID for exchange in gmail?

So were the SETTINGS.DB file gone?

For Windows, exclude escape characters
Simply perfect. I was worried when Titanium Backup couldn't restore old ID, but this worked like a beauty.
The only hitch was that the cmd.exe doesn't need escape characters for apostrophes.
So the code for me was just
Code:
adb shell content delete --uri content://settings/secure --where "name='android_id'"
adb.exe shell content insert --uri content://settings/secure --bind name:s:android_id --bind value:s:<newID>

edit: installing adbwireless and using that solved the problem. not sure why adb from my computer won't work though.
I have the latest SDK installed, have root, and have allowd adb shell root privileges and everytime i run a command I get:
tmp-mksh: adb: not found
Can anyone help me out? I'm using a Nexus 6.
edit: seems like no matter what command i type i get adb : not found. I get a response from the command adb devices when I don't have a shell open. running the abobe commands outside of a shell returns an error, and when i go into a shell no commands work. I always get the adb: not found response.

exactly what I just needed for my nexus 5, worked flawless... thanks a lot!

nyreyn said:
edit: installing adbwireless and using that solved the problem. not sure why adb from my computer won't work though.
I have the latest SDK installed, have root, and have allowd adb shell root privileges and everytime i run a command I get:
tmp-mksh: adb: not found
Can anyone help me out? I'm using a Nexus 6.
edit: seems like no matter what command i type i get adb : not found. I get a response from the command adb devices when I don't have a shell open. running the abobe commands outside of a shell returns an error, and when i go into a shell no commands work. I always get the adb: not found response.
Click to expand...
Click to collapse
Of course! This is a simple problem arising from the absence of the adb.exe executable from the system path being read by your shell or terminal program. You can either add your adb.exe to your system path or else navigate to the platform-tools directory and use the adb.exe from there:
Verify that adb.exe resides in %LOCALAPPDATA%\Android\sdk\platform-tools\
Set the path and restart the cmd or PowerShell and then try again.

I tried doing this, but my adb shell doesn't seem to have content in its sbin.
Nevermind.. it works now.

piit79 said:
I haven't found this posted anywhere so figured it might be useful to others as well.
When you reinstall Android it is set up as a new device with a new unique Android ID. This ID is often used by apps to identify the device - for example all my internet banking apps use it to register the device with the service. To avoid having to re-register after reinstall the ID can be changed to what it was previously.
The Android ID backup/restore function is included in Titanium Backup. However, the Settings Storage (com.android.providers.settings) doesn't seem to be backed by a traditional SQLite database in Android 6.0 Marshmallow - /data/data/com.android.providers.settings/databases/settings.db is empty (0 bytes) on my device. Therefore the Android ID cannot be restored/changed by the usual tools (including Titanium Backup).
I have found a way to query/update the settings database via adb though as follows:
Get current Android ID:
Code:
adb shell content query --uri content://settings/secure --where "name=\'android_id\'"
Normally, you would update the value as follows:
Code:
adb shell content update --uri content://settings/secure --bind value:s:<new_android_id> --where "name=\'android_id\'"
However, this wasn't working for me - I kept getting the same ID when querying after update. So, I tried removing the current record and re-inserting it with the new ID:
Code:
adb shell content delete --uri content://settings/secure --where "name=\'android_id\'"
adb shell content insert --uri content://settings/secure --bind name:s:android_id --bind value:s:<new_android_id>
Which worked just fine
Click to expand...
Click to collapse
Thanks! Thanks! Thanks! Thanks! Thanks! Thanks! Thanks!

Hi,
another way is :
to read Android ID:
Code:
adb shell settings get secure android_id
To write Android ID:
Code:
adb shell settings put secure android_id <new_android_id>
Tested on Android 6.0 Marshmallow.

Thanks! Thanks! Thanks! Thanks! Thanks! Thanks! Thanks!

Any way to get this done without pc access?

IparryU said:
Any way to get this done without pc access?
Click to expand...
Click to collapse
Sure. Just open Terminal Emulator as root and use the same commands as above but without "adb shell":
Code:
su
settings get secure android_id
settings put secure android_id <new_android_id>
I used it in my Nexus 5 (Marshmallow).

I'm already on Marshmallow, so I'm guessing that the "settings get secure android_id" will just tell me my current, new, unwanted android_id. Correct, or am I confused? Is there an easy way to find out what my previous android_id was so that I know what to restore it to? Perhaps Titanium Backup has it squirreled away somewhere?
Or do I need to follow this process?
1. Make nandroid of current Marshmallow setup.
2. Restore nandroid of prior Lollipop setup.
3. From terminal window, "settings get secure android_id" and write down the ID (e.g. "abcdef0123456789")
4. Restore Marshmallow nandroid
5. From terminal window, "settings put secure android_id abcdef0123456789"

There has to be a way to change the device ID for GMail but I haven't figure it out yet. There was an module on Xposed that claimed it could do it but I'm on 6.0 so that doesn't do me any good. Any one have ideas?

Hi!
I am trying adb shell settings but I get:
"/system/bin/sh: /system/bin/settings: /bin/sh: No such file or directory"
In other words the settings command is not found.
Am I missing something?
Thanks for the help!
Crios said:
Hi,
another way is :
to read Android ID:
Code:
adb shell settings get secure android_id
To write Android ID:
Code:
adb shell settings put secure android_id <new_android_id>
Tested on Android 6.0 Marshmallow.
Click to expand...
Click to collapse

MSKS said:
Hi!
I am trying adb shell settings but I get:
"/system/bin/sh: /system/bin/settings: /bin/sh: No such file or directory"
In other words the settings command is not found.
Am I missing something?
Thanks for the help!
Click to expand...
Click to collapse
Seems I'm not watching my own thread! Duh Lots of useful info here.
I was getting the same error message. The /system/bin/settings script is there but it's missing the "shebang" line at the beginning to specify what interpreter to use (e.g. #!/bin/bash). For some reason the system defaults to /bin/sh - which is not there.
You can get around it by running the scripts like so:
Code:
sh /system/bin/settings ...
Hope that helps.

Thanks a lot man! Appreciated.
piit79 said:
Seems I'm not watching my own thread! Duh Lots of useful info here.
I was getting the same error message. The /system/bin/settings script is there but it's missing the "shebang" line at the beginning to specify what interpreter to use (e.g. #!/bin/bash). For some reason the system defaults to /bin/sh - which is not there.
You can get around it by running the scripts like so:
Code:
sh /system/bin/settings ...
Hope that helps.
Click to expand...
Click to collapse

merouleau said:
I'm already on Marshmallow, so I'm guessing that the "settings get secure android_id" will just tell me my current, new, unwanted android_id. Correct, or am I confused? Is there an easy way to find out what my previous android_id was so that I know what to restore it to? Perhaps Titanium Backup has it squirreled away somewhere?
Or do I need to follow this process?
1. Make nandroid of current Marshmallow setup.
2. Restore nandroid of prior Lollipop setup.
3. From terminal window, "settings get secure android_id" and write down the ID (e.g. "abcdef0123456789")
4. Restore Marshmallow nandroid
5. From terminal window, "settings put secure android_id abcdef0123456789"
Click to expand...
Click to collapse
Did you try this and did it turn out? I'm about to do the same thing because it makes sense.

Related

adb remount operation not permitted

Hey Guys,
I Clockwork3'd my Aria, but I wanted to update my sources (thread 730398) so I can get non market apps. When I follow the instructions in that post I get an error:
Code:
./adb remount
remount failed: operation not permitted
'adb devices' does show my Aria's SN, I'm su'd and I'm running in debug mode. I also chowned everything in the android sdk tools and its subdirectories.
Here's the question -
In searching, I found (thread 614645) that suggested ro.secure wasn't set properly, and sure enough if I do:
Code:
./adb shell
$ getprop ro.secure
1
$
Shouldn't applying clockwork have set that properly? Would the instructions at (thread 8041739 post 9 ) be the right steps to resolve this on an Aria?
Thanks!
PS - sorry I can't post direct links.
if you have all the drivers installed, it should work...
which OS are you using?? (Mac, Win7, etc)
dont rund SDK command in Clockwork, with phone on connect data cable and select "charge only" when asked.
the ./ command is used for Linux i think, i never got that command to work either. just go to the folder where SDK/Tools is located in CMD prompt or Terminal(depending on the OS) and run the following command:
adb remount
hope this helps a bit
I had a lot of issues with driver installs on Windows 7, so I'm doing this on a netbook with Ubuntu netbook remix. Also tried the reflash CD, similar issue.
Right, so with Ubuntu, and the cable my phone came with (have tried a few others just in case)
1. phone on and operational
2. plug in to laptop
3. phone gives happy USB connected and Charge Only notifications
4. fire up terminal window, and su
5. type ./adb remount
and I get the error above. If I do kill-server to refresh it, I get the demon starting successfully on port 5037.
Yeah, I was hoping I'd just missed something stupid. Should I need to modify the boot.img file outside of what Clockwork did?
My symptoms match those described in thread 685146 post #3, however, I've only applied Clockwork (which seems to work) not done anything else funky.
I have my windows 7 machine at the same point now -
adb remount gives 'remount failed: operation not permitted'
and
getprop ro.secure at the adb shell returns 1.
I think this means there's something wrong on the phone, if both machines act the same.
One other data point, I noticed the new Superuser Permissions app that installing clockwork gave me is asking to give superuser permissions to /system/bin/sh when I try to run the adb shell, but it doesn't trigger that when I do the adb remount.
Not sure what this means, any ideas most welcome - TIA!
steps here fixed it, thanks - http://forum.xda-developers.com/showthread.php?t=730398

[Q] busybox throwing "precmd" errors after rooting ICS

Hello,
Thanks for looking at this post! I wanted to post it to the rooting thread, but I'm too much of a noob to have access to developer threads. I searched around (both here and google), but couldn't find any useful info on my problem.
I'll get right to the point. I rooted my Acer A500 (after doing an OTA update to 4.0.3), as per the instructions on this thread:
http://forum.xda-developers.com/showthread.php?t=1546593
Everything seems to have worked well (I have root access, etc), but there is something quirky with Busybox. Every time I type a command in terminal (it doesn't matter which - I use both connectbot and terminal emulator), I get a "precmd: not found" message (even for simple things like directory changes). The odd thing is: the commands work, but I still get the message. For instance, if I ask for a directory listing, I'll get the listing, and at the end, it will say precmd: not found (usually with the name of the command it's referencing, e.g. bash: precmd: not found).
It seems to be looking for it in /system/xbin/bash, but bash is in /data/local; I tried creating a symlink but it didn't work ("link failed Cross-device link"). This is really a nuisance, and I'd like to try installing some linux user-land tools, but I fear the outcome might be disastrous if the busybox tools are misconfigured somehow.
I'd appreciate and help/suggestions. Many thanks.
mdhobbes said:
"precmd: not found" message
Click to expand...
Click to collapse
Connectbot seems to set shell variable 'PS1' to "$(precmd)[email protected]$HOSTNAME:${PWD:-?} $ ".
It means your shell (the busybox's ash applet) will try to use output from 'precmd' as a part of a command prompt.
So when 'precmd' was not provided, error messages will be generated wenever a prompt was to be shown.
Though the messages should be safe to ignore, you may get rid of them by setting something harmless to PS1 like:
PS1="> "​, or reset PS1 by:
unset PS1​from your (busybox) shell.
# The same method should work for terminal emulator.
precmd is a shell function.
To display it run this from the default shell:
Code:
typeset -f
You will see something like
Code:
function precmd {
typeset e=$?
let " e " && print -n "$e|"
}
If you add that to one of your shell's startup files (".profile", ".bashrc", etc.) you will have a working precmd.
It works (function runs), but shows nothing neither 0 or error code. What is it?
[edit]
Nvm, my fault, figured it out

ADB Pull Error

I am getting the following error when I try to pull a TWRP backup from my Nexus 4. Can anyone please help?
Code:
remote object '/sdcard/TWRP' does not exist
It doesn't exist there. /sdcard/ is really a symlink. The actual location is /data/media/0/TWRP, but try /storage/emulated/0/TWRP as well.
Next time type "adb shell" to go into the phone, then type:
find / -type d -iname twrp
this will search the entire phone for folders with the name TWRP and list their path.
/ is the root folder of the phone to search in
-type d means search for folders only, leave it out if you want to search for file names
-iname means to search for terms case insensitive
sent from xda premium app
Thanks for the help eksasol. I've tried to pull many different paths and they all return the same remote object does not exist error. I've even tried sudo adb pull, with the same result. I've tried this, find / -type d -iname twrp but, all I get is Permission denied. If anyone else has got some ideas I'd be happy to hear them. Thanks. :good:
If you are using Ubuntu or linux, typing 'find' only search what is in your PC. You get permission denied because you want to search in a root directly that required root permission.
To search for files in your phone, you need to log into your phone by typing "adb shell". TWRP give you root by default, then you can use the find command.
Since you have root by default in TWRP, you don't need to use sudo, also Android do not have "sudo" installed. The correct way to gain root privilege in linux (Android) is by typing: su -
To tell if you have are root, you should see # where your user name is in the command window.
Once you are done finding the path, you need to exit the adb shell in order to make contact with your PC, so just type exit. Only then you can start using "adb pull".
by the way, its "adb pull /data/media/0/TWRP/ \home\username\backup\"
Rememer in linux (Android), it's case sensitive.
OK, I see my mistakes now. I was not exiting adb shell when typing adb pull. Anyway, thanks to your help, everything is working correctly now. Thank you again, I really appreciate it. Now I can flash the 4.4 update safely.
eksasol said:
If you are using Ubuntu or linux, typing 'find' only search what is in your PC. You get permission denied because you want to search in a root directly that required root permission.
...
by the way, its "adb pull /data/media/0/TWRP/ \home\username\backup"
Rememer in linux (Android), it's case sensitive.
Click to expand...
Click to collapse
Thanks for helping me re-learn that linux (Android) is case sensitive

[HELP] Logcat enable.

Hi,
I've just set up a new handset.
Since changes ive made over night im getting;
- unfortunately, 'app name' has stopped.
I'm trying to generate a logcat, having no joy.
- handset; SGSV
- rom; XTRESTROLITE
- kernel; blaze
I have turned logging on via 'pimp my rom' tweaks.
Upon adb logcat command i get;
- Unable to open log device '/dev/log/main': No such file or directory
So i set about tying to manually ensure logcat is enabled.
First with ADB;
> adb shell
> logcat-enable
Result;
C:\android-sdk\platform-tools>adb shell
[email protected]:/ $ logcat-enable
logcat-enable
/system/bin/sh: logcat-enable: not found
Then via USSD code;
> *#*#2846579#*#*
Result;
Number dialled, no code.
Then i attempted to follow as per these instructions;
http://bitmote.com/index.php?post/2013/02/19/Enabling-Logcat-in-Custom-Android-Roms
I found system set to ro, remounted rw ok.
But ran into a dead end here;
"First you need to locate the logger kernel module...
logger.ko located in...your /system folder...
Try these locations:
/system/lib/modules/logger.ko
/system/modules/logger.ko"
The folder "modules" does not exist in system or lib/system.
Help would be much appreciated.
Cheers.

How do I adb pull root directories (like "/" or "/system"?)

Hi there, I'm trying to pull root directories like /system and /data without any luck. My purpose it to have them on my PC as a backup, and be able to browse them to pull out apps and pieces of data as necessary if it ever becomes necessary.
Device: Nexus 6P (North American version)
ROM: Stock 6.0.1 Rooted, using Wugfresh Nexus Root Toolkit and SuperSU
PC OS: Windows 7 PC (64 bit)
Adb is working properly and I can easily pull non-root directories like "/sdcard" and so on. I'd like to be able to backup the entire root directory ("/") or at least the child directories (like "/system" and "/data", etc.) Unfortunately, when I try
Code:
adb pull -p "/system" "C:\somewhere"
it skips a bunch of files, so I need to come up with a better method.
I've tried
Code:
adb root
and it tells me it's already running in root mode.
I try
Code:
adb remount
and it does this properly, but doesn't change the effects of all the commands I've tried.
When I run
Code:
adb shell
it enters shell and gives me # by default, so seemingly it is giving me su permission by default?
*** Oddly, when I enter "su" while in shell, it tells me "/sbin/sh: su: not found" which seems odd to me. I think it's possibly that SuperSU is installed as systemless root, or there's something else screwy here, so I guess I'm not sure how to proceed. Still, if that were case, why would adb already be running as root, and why would shell automatically give me the #?
Any help is appreciated!!
Thanks!
@Heisenberg I figured I'd tag you because of your extensive experience with the Nexus 6P in particular (and rooting.) Not sure if you may be able to shed some light on the issue here?

Categories

Resources