Copy data from Android phone with broken screen

The screen of the phone broke and you want to retrieve your contacts / files… Quite typical story. While getting your photos / files is quite trivial, plugging your phone to computer and copying necessary files would be enough.
The situation with getting out your contacts (if you happened not to sync them with Google) is slightly more complicated. Here is what I did in the case of Samsung S4 mini with broken screen. Note, the digitizer (touch screen) worked, but the USB debugging was OFF. Also, S4 mini has no video output. If your phone happens to have HDMI or MDL, just get the cable and plug it to your TV / monitor 😉

  1. Enable USB debugging
  2. This is hard part and can be done only manually! But it’s quite complicated with broken screen. You need to repeat 3 steps until you reach what you want: make a screenshot (HOME + POWER button in S4 mini), see what’s on the screen (navigate to you Phone storage > Pictures > Screenshots), do some action and repeat… This is extremely tedious, but proved to work with me.
    In Android 4.4 which my phone had, you need to enter Settings > About, scroll down and press many times (~7 should work) Build Number. This will enable `Developer options` in Settings. You need to enter it and tick `USB Debugging` and press OK (here I needed to rotate the screen, as the right side of my digitizer didn’t work…).
    I recommend clicking `Revoke access` and OK, as my computer couldn’t connect till I pressed it.
    Then unplug the mobile phone and plug it again. New dialog asking for permission to access for your computer will appear on the screen. You should tick `Always allow access` and OK. From now on, the access through ADB is possible. You can check it with:

    # install ADB
    sudo apt-get install android-tools-adb
    
    # connect
    adb devices
    adb shell
    

    Note, if your digitizer is working only partially (my case), it’s usefull to enable autorotation first.

  3. Screencast Android to computer monitor
  4. # install seversquare
    sudo apt-get install qt4-qmake libqt4-dev libqtcore4 libqtgui4
    git clone https://github.com/yangh/sevensquare
    cd sevensquare
    
    # for Ubuntu 16.04 replace 5th line of Makefile with 
    	(cd build && qmake-qt4 -o Makefile ../seven-square.pro)
    
    # compile
    make
    
    # and run
    build/seven-square &
    

    Now, you should see the mobile screen and be able to interact with it your mouse & keyboard. Now exporting contacts should be trivial, right?

I have tried to dump userdata partition, but on original system version there is no root access and getting one would erase the data…

Let me know if there is any simpler solution!

Linux Screen to boost your remote productivity

Working remotely (via SSH) poses numerous challenges:

  • running programs are killed if the session is terminated or connection is lost
  • you need to open many connections if you want to run more things at the same time
  • you cannot resume the session from different machine

All above problems have a simple solution in Linux, called screen. Screen provides virtual terminals that can be disconnected & resumed later.

  1. Install screen
  2. sudo apt-get install screen
  3. Prepare configuration file
  4. Below you can find example configuration file. This will enable changing the windows with F5/F6, scrolling and it will display some useful information in the bottom of your screen terminal. To enable it, just paste below text to file: ~/.screenrc

    #para tener scroll-back
    termcapinfo xterm|xterms|xs|rxvt ti@:te@
    defscrollback 5048
    ##
    ### detach on hangup
    autodetach on
    ##
    ### don't display the copyright page
    startup_message off
    ##
    ### emulate .logout message
    pow_detach_msg "Screen session of $LOGNAME $:cr:$:nl:ended."
    ##
    #
    # BARRA DE ESTADO v1
    #### alternative caption, gives window list, LOGNAME and current date:
    caption always "%u%{wk}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wk}%?%+Lw %=  %{mk}host:%H Load:%l  %{ck}%M%{wk} %{ck}%d %{gk}%c"
    
    # BARRA DE ESTADO v2
    #hardstatus alwayslastline
    #hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a Load: %l"
    #caption always "%3n %t%? @%u%?%? [%h]%?"a
    #
    termcapinfo xterm ti@:te@
    
    defscrollback 1000
    
    # Scroll up
    bindkey -d "^[[5S" eval copy "stuff 5\025"
    bindkey -m "^[[5S" stuff 5\025
    
    # Scroll down
    bindkey -d "^[[5T" eval copy "stuff 5\004"
    bindkey -m "^[[5T" stuff 5\004
    
    # Scroll up more
    bindkey -d "^[[25S" eval copy "stuff \025"
    bindkey -m "^[[25S" stuff \025
    
    # Scroll down more
    bindkey -d "^[[25T" eval copy "stuff \004"
    bindkey -m "^[[25T" stuff \004
    
    
    bindkey -k k5 prev # F5 for previous window
    bindkey -k k6 next # F6 for next window
    
  5. Create new virtual terminal
  6. screen -S sessionName
    # create new window: Ctlr-A and C
    # detach session:    Ctrl-A and D
    
  7. Reattach to previous session
  8. screen -dr sessionName
    # list existing session: screen -dr