7

I'd like to know if it's possible to change android wallpaper from ADB using my laptop. I don't know if exist any command for it or if I need to copy a picture into a folfer or edit a text file. I need resolve this problem with ADB if it could be.

Thanks for all

user5217197
  • 89
  • 1
  • 1
  • 2

7 Answers7

5

You just need to launch the proper wallpaper-setting intent, handled by one of the (several likely) installed apps that have registered to receive it:

adb shell am start \
    -a android.intent.action.ATTACH_DATA \
    -c android.intent.category.DEFAULT \
    -d file:///path/to/my/image/on/device.jpg \
    -t 'image/*' \
    -e mimeType 'image/*'

If you need to upload it to your device first (bash syntax):

file=/tmp/test.jpg
dest=/sdcard/Download/"${file##*/}"
adb push "$file" "$dest"
adb shell am start \
    -a android.intent.action.ATTACH_DATA \
    -c android.intent.category.DEFAULT \
    -d file://"$dest" \
    -t 'image/*' \
    -e mimeType 'image/*'
Stephen Talley
  • 1,130
  • 15
  • 15
2

Wallpapers are setup via your Home application. This could be literally any app and thus no general adb command exists.

I know apps like Trebuchet (old launcher used by default in Cyanogenmod) loads information from XML/JSON files so you might be able to push images/configuration files and trigger a reboot, but it'll be specific to the home app you are using. So you'll have to figure out which app you are using and if any external configuration files exists that you can modify.

EDIT

I would write a small Android app that uses a BroadcastReceiver or deeplink to an activity that listens for a specialized Intent. The intent would include data with a location to a file to use as the wallpaper. Then write code within the app that sets the wallpaper programatically. See Programmatically set android phone's background for help on that part. You can then send an intent via adb (see Sending intent to BroadcastReceiver from adb) that your code will be listening for and that would trigger updating the wallpaper. I'm not going to go into detail on how to implement that, but hopefully provide you with enough search terms to know how to implement it yourself.

Community
  • 1
  • 1
zerobasedindex
  • 1,291
  • 9
  • 5
  • It's ok but I'll tell what I'm trying to build. I working in a script for Raspberry Pi for personalize a phone when it connects but I can access previusly to the phone and install an app to communicate to the raspberry. Thanks guys! (Sorry for my bad english) – user5217197 Aug 12 '15 at 01:14
2

Wallpaper is stored in /data/system/users/USER_ID/wallpaper_info.xml file:

~ # cat /data/system/users/0/wallpaper_info.xml 
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<wp width="1080" height="960" name="" component="net.rocboronat.android.wallpaper.npe/.NPEWallpaper" />

Mount /data in CWM, then use adb shell. To edit a file use cat > file/to/change, paste the content, hit ^D. New content just landed to the file.

Nowaker
  • 12,154
  • 4
  • 56
  • 62
1

This works for me on Android 5.1

am start -d file:////data/local/tmp/black_white.png -a android.service.wallpaper.CROP_AND_SET_WALLPAPER -f 0x1 com.android.launcher3/.WallpaperCropActivity`
Rusty
  • 1,095
  • 9
  • 15
0

The bitmap file is in /data/system/users/0/wallpaper

alexislg
  • 1,018
  • 13
  • 20
0

If you are using the Amazon fire tablet HD 8 (Gen 8)

Fire OS 6.3.0.0

The Batch code to change just the unlocked wallpaper is:

set file=wallpaper.jpg
set dest=/sdcard/Download/%file%
adb push %file% %dest%

adb shell am start -d file://%dest% -a android.service.wallpaper.CROP_AND_SET_WALLPAPER -f 0x1 com.amazon.photos/com.android.launcher3.WallpaperCropActivity

Source

The way I found what command to use was with the recent command. Perform the action then dump the information:

adb shell dumpsys activity recents   # for Android 4.4 and above
adb shell dumpsys activity activities # for Android 4.2.1

Source

Or you could record try to record actions but I think this only works with inputs:

adb shell getevent

Source

Ender Wiggin
  • 95
  • 1
  • 5
0

I wrote an app to do it, so that it can be done by ADB with no need to touch the device:

adb install the-app.apk
adb shell am broadcast -a com.blundell.app.SET_WALLPAPER -n com.blundell.app/.SetWallpaper
adb uninstall com.blundell.app

The app:

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.blundell.app"
    >

    <uses-permission android:name="android.permission.SET_WALLPAPER"/>

    <application
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        tools:ignore="GoogleAppIndexingWarning"
        >
        <receiver
            android:name=".SetWallpaper"
            tools:ignore="ExportedReceiver"
            >
            <intent-filter>
                <action android:name="com.blundell.app.SET_WALLPAPER"/>
            </intent-filter>

        </receiver>
    </application>

</manifest>

No Activities.

Broadcast Receiver:

class SetWallpaper : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        WallpaperManager.getInstance(context).setResource(R.raw.wallpaper)
    }
}

That's it!

And the wallpaper itself lives in the /res/raw/ directory. You could also pass the wallpaper location through the broadcast intent if you wanted.

Blundell
  • 75,855
  • 30
  • 208
  • 233