Using the front camera to login to WhatsApp Web on a rooted Android device
If you need to use your front camera to login to WhatsApp Web, for example because your rear camera doesn't work, the App will leave you hanging. But if you're rooted, there might be a workaround.
Disclaimer: As always in these tutorials, I'm not responsible for any damage to your phone. Be smart, be informed, we're messing with the system here and that includes the possibility of breaking it! You're doing this at your own risk and I will not be responsible for any harm or damage that comes of it.
This was tested on a Oneplus 3. For other phones it may not be possible or you'll have to adapt to a different file system.
As mentioned before, your phone needs to be rooted. Apart from that, all you need is a shell session on it, or a root file explorer like "ES". If you're not experienced using the shell just get yourself a root explorer and you'll be fine.
If you do want to use the shell you can try a terminal emulator from the Playstore, or login to the shell using ADB. To do that activate USB-Debugging on your phone, connect to the computer, open a terminal (where adb.exe is located, if necessary) and type adb shell. Done.
Okay, let me tell you what we're about to do. So there is absolutely no way of making WhatsApp use the front camera, except apparently to dismantle the phone and remove the rear cam. According to some people that worked. But we don't want to do that. So instead, we are going to make WhatsApp (and the rest of the phone) believe that your rear cam actually is the front cam and that the front cam is the rear cam. Doing that is surprisingly easy, at least on the Oneplus 3.
What we need to do is to manipulate a certain configuration file. On the Oneplus 3 it is located under /etc/camera/camera_config.xml. To be on the save side we are going to make a copy of it and save it under a different name, for example /etc/camera/camera_config.xml.bk. This way, if we screw something up, we will be able roll back all the changes we are going to make. Afterwards we open the .xml file using any text editor (needs root). On the Oneplus, it contains a lot of XML-code, most of which does not seem to be important to us. But as you scroll down, you'll see a lot of entries like this:
<CameraModuleConfig><CameraId>0</CameraId>
The numbers in between the <CameraId>-tags can go much higher than the amount of cameras you have on the phone. Underneath these two tags are a number of different ones, describing the properties of your camera. There will probably be several blocks of this code, each describing a different camera, some of which seem to be virtual ones. Interesting to us is the following tag in each of these blocks:
<Position>BACK</Position>
or
<Position>FRONT</Position>
All we are going to do is to replace every single BACK with a FRONT and the other way around. We'll save the changes and reboot the phone. Now we open WhatsApp. If this works for your phone like it did for mine, the login screen for WhatsApp Web should now use the front camera. Note that if you open your camera app now, orientations might be completely mixed up. I don't know why they weren't on WhatsApp.
All we need to do now is to login to WhatsApp Web and then revert all the changes we've made back to original. The easiest way to do this is to rename the file we've just modified to something like /etc/camera/camera_config.xml.switch and rename our backup file back to the original file name. This way, if we ever need to do this again, we can just change the file names accordingly. I am not sure if our backup file will survive a software update, though. So now, reboot again and your phone should be all back to normal!
As mentioned before, you can do all this from the terminal. I'm not going to describe this in detail, but here is roughly how it works:
First, you need root. Simply type
su
You may be asked to give root permissions. Do it.
Now we need to remount /system in order to be able to modify files:
mount -o rw,remount /system
To navigate, use the cd command. In our case probably
cd /etc/camera
Now we have to check if there is a file that might configure the camera. Use
ls
If there is no file that seems suspicious, look directly under /etc, appearantly it is right there, sometimes.
Now we want to create the backup. Assuming the file has the same name as it did on my phone and you are in the directory where it is located, we can now use relative file paths and do the follwing:
cp camera_config.xml camera_config.xml.bk
That created a backup. To check if it was successfull use ls again.
Now we have to make those modifications. The command-line editor vi should be installed. It was on my phone. You can open the file using
vi camera_config.xml
There are a number of commands necessary to work with vi. Please use google to find out how it works. Then you can make those modifications and reboot. You should now know all the commands to change everything back to normal as well. Hope I could help.
In case you ever need to come back to this I'll summarize what you need to do:
- Have root
- Find the file that configures your camera, can be under
/etcor/etc/cameraor anything similar. - Make a backup of this file.
- Change
<Position>FRONT</Position>to<Position>BACK</Position>and the other way around. Save the file. - Reboot the phone. WhatsApp should now use the front camera on the login screen.
- Login to WhatsApp Web.
- Change everything back to normal, possibly make a backup of the modified file for easy access the next time, and reboot. All normal again. Cheers!