Mirror android mobile screen on laptop

There are many situations that leads to such a requirement. If the internet connectivity at home is of less speed and you have access to a higher bandwidth wifi internet at the place of work. If you want to search and download favourite series on mobile phone and later watch the same on laptop at home.


Direct approach
~~~~~~~~~~~~
Just mirror the mobile phone on laptop screen. The downloaded videos on mobile can be played and accessed from laptop after screen mirroring. This will give provision to control (play, pause, navigate etc.) the same from laptop.


Tested platform
~~~~~~~~~~~~
Phone with android OS
Laptop with ubuntu OS


To do
~~~~
1. Get SCRCPY(There are enough resources available in internet to help in installation of SCRCPY on windows/linux/mac OS). For ubuntu, type in terminal
sudo apt-get install scrcpy

2.  After successful installation, connect android mobile phone using USB to laptop in FILE TRANSFER mode. Now the android USB DEBUGGING needs to be enabled. For that go to 

Settings > Additional Settings > Developer Options > USB Debugging

Enable it. You will get a prompt to allow RSA key matching. Allow the same. In same screen go to 

Select USB Configuration > PTP(Picture Transfer Protocol)

Enable it. You will get a prompt to allow RSA key matching. Allow the same. 

3. Open terminal in ubuntu and run

sudo scrcpy

This will do mirroring of your mobile on laptop. Keep the turn off timeout for USB Debugging off. Footnote gives the way around on a fault scenario that occurs when this connection is disconnected with a timeout, or during mirroring the screen next time..


Footnote
~~~~~~~
I)    Sometimes due to mismatch in RSA keys, subsequent connections between mobile and laptop may fail due to previously stored keys. To avoid this, run the following cleanup code prior to connections.
Create a file called cleanup.sh
Put the following lines into the file:-

!/bin/bash
rm ~/.android/adbkey.pub
rm ~/.android/adbkey
adb kill-server
adb start-server

Open terminal and navigate to folder with this file. Type

sudo chmod 777 cleanup.sh

This gives execution permissions for the file. Now whenever the mirroring connection is disconnected, run this file before connecting from terminal as

sudo ./cleanup.sh

Now connect the mobile phone to laptop using USB and continue the steps from step 2 in 'To Do' section above. The prompts for accepting RSA keys will appear again during connection.

II)    Keeping the developer options enabled on your mobile phone continuously is not good for its cyber security. It is a good practice to disable the same after your work is done.

Comments

Popular from this site

How to set static IP address for Raspberry pi in headless setup?

Exception: Please shut down the controller which is running on port 6653: Mininet

Send and Capture icmp packets with type&code using hping