0

My screen on my Galaxy S3 broke and I need to transfer an app that's on my phone to my computer. I have developer mode enabled on the phone and I want to be able to transfer the app without opening up the motherboard. But I can't physically unlock the phone because of the broken screen, so how do I do this?

(When I say I have developer mode on, I mean that I can install apps that I wrote in Eclipse onto my phone and run it. If this isn't what that means, then my mistake. But if it is, how do I access my stuff with a locked screen)

2
  • When you say transfer an app, do you mean just apk or including datas? Commented Jul 1, 2014 at 3:13
  • @MinNaingOo just the APK
    – user65271
    Commented Jul 1, 2014 at 3:20

4 Answers 4

2

You can pull the apk from the android device using adb pull.

  1. adb shell pm list packages

This will list the package name for all the apks. See the package name of your app. The app name may vary from the package name. It will be mostly in /data/app

If not get the path using adb shell pm path com.the app you need to.transfer

2 a.adb pull /data/app/com.the app you need to.transfer.apk. This will transfer the apk from whichever drive you executed. Eg: D:

(or)

2.b. adb backup -apk com.the app you need to .transfer

This will create backup.ab. You can make it a tar and extract using winrar

dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar

If there is no zlib support you can try

dd if=data.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -

Note : Dont setup a password for encrypt backup

9
  • Wow – nice one-liner to convert an ADB backup to .tar, deserves an extra point :) Guess I'm wrong assuming I could skip the zlib part, and get a backup.tar.gz then – as otherwise you'd used that here yourself? // Side-note: It probably doesn't work with encrypted ADB backups (i.e. when created using a password), right?
    – Izzy
    Commented Jul 1, 2014 at 8:44
  • @Izzy yes it wont work with encrypted backup
    – samnaction
    Commented Jul 1, 2014 at 9:07
  • Thought so (maybe you should point this out in your answer, to NOT put a password?). Will try out the "zlib vs. .gz myself at home then :)
    – Izzy
    Commented Jul 1, 2014 at 9:10
  • 1
    I tried. Format not compatible to gzip or bzip2. Nevertheless, very helpful! I made it a tiny little shell-script named ab2tar, with a little addition: dd if=$1 bs=24 skip=1 | openssl zlib -d >${1%%.ab}.tar && gzip -9 ${1%%.ab}.tar. Simply pass it the .ab file as first argument, and the result is a .tar.gz :)
    – Izzy
    Commented Jul 2, 2014 at 7:16
  • 1
    @Izzy I managed to do an adb backup with a broken screen, without root, but with USB debugging enabled. I had to use the TouchControl app (the linux version) and some help from this answer. I used the TouchControl app to see my phone screen on my PC with a combination of "input keyevent" 61 and 66 (TAB and ENTER) and "input swipe" (based on the code of the tool) to be able to unlock the screen and press the OK button. Awesome answer and awesome script, thanks!
    – jadkik94
    Commented Dec 19, 2015 at 22:42
1

I managed to do an adb backup of my phone based on @sameer's answer. However, as noted in the comments there, you need to confirm the backup using the screen after running the adb backup command.

So first, you need to have adb installed. Make sure your device shows up and is authorized:

# adb devices                                                                                                                                    
List of devices attached                                                                                                                                                
EP732284Z8      device 

Then run adb shell input to make sure the commands we're going to be using are there. You should see something like that:

# adb shell input
Usage: input [<source>] <command> [<arg>...]                                                                                                                 

The sources are:                                                                                                                                             
      mouse                                                                                                                                                  
      keyboard                                                                                                                                               
      joystick                                                                                                                                               
      touchnavigation                                                                                                                                        
      touchpad                                                                                                                                               
      trackball                                                                                                                                              
      stylus                                                                                                                                                 
      dpad                                                                                                                                                   
      touchscreen                                                                                                                                            
      gamepad                                                                                                                                                

The commands and default sources are:                                                                                                                        
      text <string> (Default: touchscreen)                                                                                                                   
      keyevent [--longpress] <key code number or name> ... (Default: keyboard)                                                                               
      tap <x> <y> (Default: touchscreen)                                                                                                                     
      swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)                                                                                        
      press (Default: trackball)                                                                                                                             
      roll <dx> <dy> (Default: trackball)  

Next, we'll install TouchControl to be able to see what is happening on screen. This won't work if your device is not already in USB debugging mode and authorized already (i.e. if you see "unauthorized" or "offline" after running the first command). I installed the Linux version. I had to install boost to make it work. It should work on Windows too.

We need to unlock the device. For that, we will use "adb shell input swipe [x1] [y1] [x2] [y2] [duration]" with (x1, y1, x2, y2) depending on your device and duration could be 250 (in ms). For reference, you can look at the numbers in this file (look for "shell input swipe"). In my case the resolution of my device is "1920x1080" so I looked at the part that said " if (i.toStdString() == "1080x1920") {. That code does a swipe from left to right. I need to unlock my device by swiping from bottom to top, so I used (300, 1100, 300, 950) with a duration 300, i.e. "adb shell input swipe 300 1100 300 950 300". You'll need to experiment with the values and see what changes on the "virtual" screen to get it right. In my case (0, 0) was the top left and (300, 1100) was towards the bottom middle.

If you have a password or PIN you can input it using adb shell input text "<yourpasswordhere>". If you have a pattern, then you'll have to figure out the coordinates of every dot and make your pattern using adb shell swipe commands. (Good luck with that, it'll take some time). Otherwise, you could try some screenlock bypass apps and install them via adb install. I didn't have any of that, so I'm not sure what will work for you.

Now run the adb backup command:

# adb backup -apk -shared -obb -all -system -f ./android-backup.ab
Now unlock your device and confirm the backup operation.

Next, you'll have a screen like that one (click image for full size):

backup screen

So now, we will press "TAB" twice to get to the "BACKUP MY DATA" button, then press "ENTER" to confirm. Basically, based on the numbers in that answer:

adb shell input keyevent 61
adb shell input keyevent 61
adb shell input keyevent 66

Now your backup has started. Yey!

P.S. To see the progress of your update, you can watch the file size grow. On linux, you can run a command like that one: watch -n 5 "du -h ./*.ab" or watch -n 5 "du --time -m ./*.ab"

P.P.S. You can use a command like adb shell input swipe 300 0 300 950 300 to open your notification drawer and abd shell input tap [x1] [y1] to press on notifications then adb shell text [sometext] to write. And you can use adb shell input keyevent [61|66] to press on practically anything without knowing their coordinates.

P.P.P.S. I'm on an Xpreria ZR running "10.7.A.0.222" android version 5.1.1. Your exact commands may vary depending on your screen resolution and android version (e.g. different way to unlock, different number of times to press TAB, etc.).

Hope this helps!

3
  • Thanks a lot for this detailed answer (+1)! I didn't manage to install TouchControl (didn't compile from the sources, obviously due to dependencies, and the binary didn't work – again due to dependencies). Reading your answer reminds me of a recent addition to my Adebar, which now can do the same (remotely confirm ADB backup/restore calls, but automatically without the user having to manually input keyevents) – and has less dependencies ;)
    – Izzy
    Commented Dec 20, 2015 at 11:19
  • 1
    Haha that's the script I wrote to make this whole process easier (I cleaned it up a bit before putting it online, but it's still a mess). Adebar sounds sweet. I'll give it a try!
    – jadkik94
    Commented Dec 20, 2015 at 12:15
  • I've made Adebar a separate answer, if you wish to check. Feeback welcome if you try it :)
    – Izzy
    Commented Dec 20, 2015 at 12:54
1

With turned on (which you describe as "developer mode"), you can use e.g. Adebar to create an ADB Backup. Recently, automatic approval of backups as well as automatic unlock (experimental, and only working with "slide to unlock" – not with PIN/password/pattern lock) was added. In its config, set AUTO_CONFIRM=1 (to automatically confirm backups on the device), and optionally AUTO_UNLOCK=1 (might or might not work, not widely tested yet). Adjust the other settings to your wishes, then run it.

Afterwards, you'll find two backup scripts in the output directory: one for "user apps" and one for "system apps". Optionally check them before (and comment out what you don't want to backup), then run them. Separate backup archives (.ab) are created, one per app; for user-apps they include the .apk and data, for system apps data only.

Note that adb backup doesn't work for all apps: apps can opt out of this, setting ALLOW_BACKUP=FALSE in their manifest. On rooted devices with Xposed, a module called Backup All Apps can be used to work around that. But in your case, this might be difficult to install (with a broken screen).

Disclosure: I'm the dev of Adebar.

0

If you can debug your application written in eclipse in your phone, I guess you have already enabled USB debugging.

Moborobo PC Suite can transfer files from your phone including applications with data and it needs USB debugging to be enabled. In the App manager, Right click on the app and there will be Export option. There you can save your app into your PC.

Moborobo PC Suite - App Manager

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .