Android 12 Developer Preview 1 Changelog: Google Finally Restricts the Power of “adb backup”

And they possibly have a plan to remove this feature in the future.

Lam Pham
4 min readMar 1, 2021

--

Photo by Markus Spiske on Unsplash

A few months ago, I wrote a blog explaining the power of the command line

adb backup

To summarize, “adb backup” is an official way to leak private data in certain apps. I said “official” because it’s designed and allowed by Android’s creator and there are also other unofficial ways to do it such as rooting a device.

With the Android 12 preview release, Google has announced a strong restriction (even a permanent removal in the future) of this command. It says that:

To help protect private app data, Android 12 changes the default behavior of the adb backup command. For apps that target Android 12, when a user runs the adb backup command, app data is excluded from any other system data that is exported from the device.

The statement is pretty clear: app data could no longer be extracted using adb backupcommand. Let’s go check the change.

I have created a simple app which stores a token in a SharePreference :

val sp = getSharedPreferences("SharePreferenceApp", MODE_PRIVATE)
sp.edit {
putString("token","132s1f4156ze41fae51a4f5ez1af51ze5f5a1ze5f")
}

Don’t forget to set android:allowBackup="true".

At first, I check the command with targetSdkVersion 30 to see whether it works. Indeed, with the command

adb backup com.example.backup

, I get the SharePreference file in both Debug/Release mode.

If you don’t know how to use adb backupcommand, feel free to refer to my previous blog.

Now, I change targetSdkVersion to "S" and compileSdkVersion to "android-S" and try the command again.

--

--