[Android 11+] How to add a virtual/mock camera device internally/externally and set it as the default camera? - Android Q&A, Help & Troubleshooting

I need a virtual camera to override the system camera on android 11+ phone to stream frames that are sourced from an image file. Basically injecting image into the camera device.
I need it to test camera functionality on mobile native apps/webapps. I would have easily done it with a custom camera app before Android 11 but now it isn't possible. See link!
Assume that I have both root access and unlocked bootloader on my phone.
Any Ideas?
Ideas that I was thinking of:
Emulating a external USB camera to feed only an image: But how do I set it as a system camera?
Adding a loopback device as a kernel module and makng it the default camera device. https://github.com/umlaeute/v4l2loopback

Hello sir, can you please tell me a way how can that be done on Android versions other than 11?

did you figure this out?

Have you found any solution?

I finally found one
Its Xposed module
But i didn't understand its documentation so cant install it
com.example.vcam/README_en.md at main · Xposed-Modules-Repo/com.example.vcam
虚拟摄像头 virtual camera. Contribute to Xposed-Modules-Repo/com.example.vcam development by creating an account on GitHub.
github.com
If someone can install and run it successfully please tell me steps

I made this work for some APPS, but not for the one I wanted.
Documentation doesn't explain very well.

MOD Translation:
I can replace with MP4 files. instead of camera images.
我可以用 MP4 文件替换。而不是相机图像。

Related

[Q] Identifying the developer from a kernel module

If I want to write a kernel module on Android to identify a developer in a unique manner, is there any provision do so? One way I have thought of is to look at the key used to sign the app, capture it during installation and create a database of it in the kernel. I do not think this will be effective and hence would like to know any other ways.

[Q] Editing Android Kernel - looking for NFC/HCE Code

Hi,
I'm currently in the process of developing a project for my University course wherein I will be hopefully editing the functionality of the HCE Feature of Android to allow me to set my own UID when emulating a card.
Now, i've downloaded the AOSP source, and built a custom image with no edited code and installed that to my Nexus 7 (This includes downloading and including the Vendor specific hardware drivers), and i'm stuck on the next part.
I physically cannot find the device code that governs the NFC features of Android, and i'm unsure how to go about a) Looking for it, and b) How I should be editing this code.
Is the code for NFC in Android in the base Kernel? and if so how would I edit that before I run "make" again and hope it builds? or is it elsewhere? I've noticed that the files in the Vendor folder i've downloaded and extracted are in a .ncd format, which I don't think is editable.
Any help I can get on this would be greatly appreciated.

Approaches and prerequisites of a cutom factory image

I'm from a startup, that is working on a Smartphone with a preinstalled Android without Google Apps and Services to protect the user's privacy by default. The focus of our development is an improved system user experience with a technology background in NLP, ML and AI. Android offers a straight forward approach with a custom launcher.
The potential ODMs for our device offer a Stock Android Pie with all Google Apps and Services. So we a re looking for the most cost efficient approach of customizing the factory image. In principle, I see two possibilities:
1. Modifying the factory image of the ODM
Maybe the most efficient way would be to remove Google Apps and Serivces and install a custom launcher and some replacement apps with a script. I'm not sure if this doesn't lead to errors or if this possibility also exists for a recovery image.
2. Providing a custom factory image
I found some tutorials, one at XDA developers and another at Android Authority. Finally there is guide of the AOSP.
One challenge are the technical requirements, as far as I have understood, the device drivers. The AOSP documentation says:
Download previews, factory images, drivers, over-the-air (OTA) updates, and other blobs below. For details, see Obtaining proprietary binaries.
Preview binaries (blobs) for AOSP master branch development
Factory images for supported devices running tagged AOSP release branches
Binary hardware support files for devices running tagged AOSP release branches
Click to expand...
Click to collapse
The Android Authority article says something similar:
Obtain proprietary binaries – The binary drivers should be unpacked in your working directory.
Click to expand...
Click to collapse
What do we exactly need from the ODM respectively PCBA board designer beyond the factory image? The hardware support files as proprietary binaries? It's unlikely, that we get the source code for the drivers. Can we take the drivers from the factory image? How can we identify them?
We think to take LineageOS, but we learned from the related Reddit forum, that a port of LineageOS for a new device would take some man years. Would you suggest to use the AOSP? How many man month should we calculate for a custom build?
Further more we need to think about how to provide OTA updates. Unfortunately, I don't know what is necessary to set up an OTA Update Service and prepare a Custom ROM for it. Is it essentially a fileserver with an encrypted connection and signed files?
Which approach would you suggest? Thanks for each suggestion and links for further information.

Google Camera mods doesn't work on Xperia XZ1 and here's why

If you looking for a google camera mod for XZ1 and whatever you already downloaded is crashing while opening the app (except the apks that hasn't HDR+ feature) and you want this gcam so bad that thinking about opening your bootloader and rooting your phone just for that feature don't do it (againg if you rooting just for gcam).
First of all the reason that gcam not working because in your device Camera 2 API isn't enabled so if you made a little research you know that you can enable that with just unlocking your bootloader but here is the catch if you already unlock the bootloader even rooted your phone and you still can't enable Camera 2 API that's because SONY doesn't want you to enable. Now I'm going to talk what I already tried. (If you know how please kindly explain it in the mentions)
DAY 1(Bootloader locked - Non rooted)
Making research from various sites for just getting information about camera 2 api
After research backing up my phone several times with companion app
Looking for tutorials to enable without rooting and unlocking the bootloader
DAY2(Bootloader unlocked - Non rooted)
After realizing that you can't do anything without unlocking your bootloader prepared for unlocking (By the way you need to get a unlocking key from Sony's website with your IMEI)
After unlocking bootloader trying adb shell and fastboot commands I couldn't able to enable then searched for solutions in fastboot mode booting on custom recovery (in my case TWRP) try to flash it and running adb shell commands it didn't enable. (The main problem is I couldn't get RAW checked from camera probe app and gcam needs it for processing.)
DAY3(Bootloader unlocked - Rooted)
I rooted with magisk but with TWRP i didn't use the install section because I couldn't able to find the .zip file so I used the adb sideload thing. After downloading the magisk manager app and access to root I've tried using build.prop, terminal both phone and computer, magisk modules and adb sideload to flash .zip files for enabling camera 2 API (that gave me error while doing) but whatever I've tried to do didn't work out for me.
For who are wanting gcam to work in your Xperia XZ1 for my case and research I couldn't able to enable Camera 2 API and couldn't find a way to enable I think Sony needs to give us RAW processing option. All in all rooting your XZ1 not that bad idea after all because I don't think Sony give this lineup an another android update (Android Q). If you have any questions about the process don't hesitate to ask. Take care of yourselves and be aware of what you're doing with your lifes and your devices.
I think RAW capture is supported on the official AOSP builds. So ,theoretically, Camera2 api should work on the official AOSP.
Suggest rom with working gcam and gcam link
Generic123. said:
I think RAW capture is supported on the official AOSP builds. So ,theoretically, Camera2 api should work on the official AOSP.
Click to expand...
Click to collapse
Before and after root when I looked for camera probe app I couldn't able to check RAW and some other white balance settings XZ1's camera capable to provide most of the Camera 2 API's needings out of the box but if you've any way to enable raw image processing I genuinely want to know how. Thanks for your reply by the way.
deniz_nam said:
Before and after root when I looked for camera probe app I couldn't able to check RAW and some other white balance settings XZ1's camera capable to provide most of the Camera 2 API's needings out of the box but if you've any way to enable raw image processing I genuinely want to know how. Thanks for your reply by the way.
Click to expand...
Click to collapse
Check this and this. These are both AOSP ROMs, which I've heard have full Camera 2 api support(including RAW). Unfortunately, neither are even remotely stable enough for daily use, so it's not really worth it. Besides, the forums seem to show that google cam doesn't work too well(although no photos, so it may be a subjective thing). That's honestly all I know about this kind of stuff; if you want a decent camera experience on a custom ROM, you might want to try LineageOS; the stock camera was ported and works for the most part(except 4K recording, which I heard was fixed in the next version). Other than that, I have no other idea on how to get RAW support on stock firmware, sorry.
Generic123. said:
I think RAW capture is supported on the official AOSP builds. So ,theoretically, Camera2 api should work on the official AOSP.
Click to expand...
Click to collapse
what about this link : https://androidfilehost.com/?fid=6006931924117914458. by SonyAOSP Team are they stable builds and how to flash them? they are updated evey month and have the latest security patch as i think
deniz_nam said:
If you looking for a google camera mod for XZ1 and whatever you already downloaded is crashing while opening the app (except the apks that hasn't HDR+ feature) and you want this gcam so bad that thinking about opening your bootloader and rooting your phone just for that feature don't do it (againg if you rooting just for gcam).
First of all the reason that gcam not working because in your device Camera 2 API isn't enabled so if you made a little research you know that you can enable that with just unlocking your bootloader but here is the catch if you already unlock the bootloader even rooted your phone and you still can't enable Camera 2 API that's because SONY doesn't want you to enable. Now I'm going to talk what I already tried. (If you know how please kindly explain it in the mentions)
DAY 1(Bootloader locked - Non rooted)
Making research from various sites for just getting information about camera 2 api
After research backing up my phone several times with companion app
Looking for tutorials to enable without rooting and unlocking the bootloader
DAY2(Bootloader unlocked - Non rooted)
After realizing that you can't do anything without unlocking your bootloader prepared for unlocking (By the way you need to get a unlocking key from Sony's website with your IMEI)
After unlocking bootloader trying adb shell and fastboot commands I couldn't able to enable then searched for solutions in fastboot mode booting on custom recovery (in my case TWRP) try to flash it and running adb shell commands it didn't enable. (The main problem is I couldn't get RAW checked from camera probe app and gcam needs it for processing.)
DAY3(Bootloader unlocked - Rooted)
I rooted with magisk but with TWRP i didn't use the install section because I couldn't able to find the .zip file so I used the adb sideload thing. After downloading the magisk manager app and access to root I've tried using build.prop, terminal both phone and computer, magisk modules and adb sideload to flash .zip files for enabling camera 2 API (that gave me error while doing) but whatever I've tried to do didn't work out for me.
For who are wanting gcam to work in your Xperia XZ1 for my case and research I couldn't able to enable Camera 2 API and couldn't find a way to enable I think Sony needs to give us RAW processing option. All in all rooting your XZ1 not that bad idea after all because I don't think Sony give this lineup an another android update (Android Q). If you have any questions about the process don't hesitate to ask. Take care of yourselves and be aware of what you're doing with your lifes and your devices.
Click to expand...
Click to collapse
UPDATE: By the way after couple days of use with
device I found out a strange behavior. After many tries to get a working gcam I gave up so while I was looking for how to see device's cameras status I used getprop in adb shell to look for did I enable Camera 2 API or not, actually I was very surprised it looks like it's enabled (persist.camera.HAL3.enabled = 1) then I looked for an alternative to gcam and downloaded the open camera. While in the app tweaking with the settings, found out that there's a Camera 2 API toggle for that supported devices. After tweaking, I take some photos with that I've shocked how good the HDR was I added some sample photos and HDR settings that I used in open camera. I hope I could help you with the journey of yours.
NOTE:In the sample photos when you zoom in there are artifacts on leafs and car that passing away thats because of hdr is 3 stops of dynamic range and shooting 3 different exposed photos so for the best detailed photos you should keep your hands stable and you should be around somewhere has not much moving objects. And in open camera there is a scene mod option, with that if you adjust your camera you can get night sight like photos in near complete dark scenes.
As always take care of yourselves and be aware of what you're doing with your lifes and your devices.
https://drive.google.com/drive/folders/1-4Jc5HIxvzi2T4Zb3Ws_kreCGPHfUBhm?usp=sharing
deniz_nam said:
UPDATE: By the way after couple days of use with
device I found out a strange behavior. After many tries to get a working gcam I gave up so while I was looking for how to see device's cameras status I used getprop in adb shell to look for did I enable Camera 2 API or not, actually I was very surprised it looks like it's enabled (persist.camera.HAL3.enabled = 1) then I looked for an alternative to gcam and downloaded the open camera. While in the app tweaking with the settings, found out that there's a Camera 2 API toggle for that supported devices. After tweaking, I take some photos with that I've shocked how good the HDR was I added some sample photos and HDR settings that I used in open camera. I hope I could help you with the journey of yours.
NOTE:In the sample photos when you zoom in there are artifacts on leafs and car that passing away thats because of hdr is 3 stops of dynamic range and shooting 3 different exposed photos so for the best detailed photos you should keep your hands stable and you should be around somewhere has not much moving objects. And in open camera there is a scene mod option, with that if you adjust your camera you can get night sight like photos in near complete dark scenes.
As always take care of yourselves and be aware of what you're doing with your lifes and your devices.
https://drive.google.com/drive/folders/1-4Jc5HIxvzi2T4Zb3Ws_kreCGPHfUBhm?usp=sharing
Click to expand...
Click to collapse
Can you give instructions to be able to do as you can?
Sent from my Sony G8342 using XDA Labs
haiha2001 said:
Can you give instructions to be able to do as you can?
Sent from my Sony G8342 using XDA Labs
Click to expand...
Click to collapse
If you asking for enabling the Camera 2 API I mentioned it in the original post but basically you need;
bootloader unlocked device (You need to get a key for it from Sony's website)
TWRP .img file
some adb and fastboot commands
newest Magisk .zip file (for root)
Basic Steps You Need To Follow (I'm not giving all the details because there could be a difference between devices from software wise or steps that could damage your performance or device and I'm not taking any responsibility for it.)
First you need to unlock your bootloader there many posts that explain how to in xda.(You need a key from Sony that you can get with your IMEI)
Then you need latest drivers and files for ADB and Fastboot that you can get it from developer.android site.
After that, you have to plug your device to computer with USB debugging on. And reboot in fastboot mode that you can make with adb commands or volume up with power buton (after 3 vibrations release just the power buton until you see a blue indicator from your notification led.).
In fastboot mode boot in recovery that you downloaded into your computer (in my case that was TWRP).
If you can find magisk file in install section you can do it from there but I couldn't find in install section so I use adb sideload to install magisk.(XDA has very nice explanation for how to download magisk on your device you should check that out.)
After installation and reboot I downloaded Magisk Manager apk file to device I used both build.prop and terminal (also both in device's and computer's terminal) to write camera.HAL3 code. ( I couldn't able to check the RAW box in camera prob app)
Finally you should need to look for camera specifications in your terminal that your proccess made it or not. (with getprop method)
I would recommend downloading Open Camera from play store and enabling for Camera 2 API for app and tweaking other settings for your liking. (Especially HDR settings)
If have any other question don't hesitate to ask. And if I skipped any steps or so please inform me about it.
deniz_nam said:
If you looking for a google camera mod for XZ1 and whatever you already downloaded is crashing while opening the app (except the apks that hasn't HDR+ feature) and you want this gcam so bad that ...
Click to expand...
Click to collapse
So, versions without HDR+ works on our devices?
If yes could you please provide the link, thanks.
sohrab1985 said:
So, versions without HDR+ works on our devices?
If yes could you please provide the link, thanks.
Click to expand...
Click to collapse
https://forum.xda-developers.com/xperia-xz1/themes/google-camera-mod-xperia-xz1-t3786993 from this discussion you can get the apk but like I said I tried this apk too, it has photosphere and panorama as features no HDR+ or night sight which you want I believe. I'd download open camera rather than this apk. Open camera hasn't that beautiful ui but it's better capabilities than gcam without HDR+.
deniz_nam said:
https://forum.xda-developers.com/xperia-xz1/themes/google-camera-mod-xperia-xz1-t3786993 from this discussion you can get the apk but like I said I tried this apk too, it has photosphere and panorama as features no HDR+ or night sight which you want I believe. I'd download open camera rather than this apk. Open camera hasn't that beautiful ui but it's better capabilities than gcam without HDR+.
Click to expand...
Click to collapse
Exactly, I'm looking for night sight feature.
I try open camera then.
Thanks for the help.
deniz_nam said:
If you looking for a google camera mod for XZ1 and whatever you already downloaded is crashing while opening the app (except the apks that hasn't HDR+ feature) and you want this gcam so bad that thinking about opening your bootloader and rooting your phone just for that feature don't do it (againg if you rooting just for gcam).
First of all the reason that gcam not working because in your device Camera 2 API isn't enabled so if you made a little research you know that you can enable that with just unlocking your bootloader but here is the catch if you already unlock the bootloader even rooted your phone and you still can't enable Camera 2 API that's because SONY doesn't want you to enable. Now I'm going to talk what I already tried. (If you know how please kindly explain it in the mentions)
DAY 1(Bootloader locked - Non rooted)
Making research from various sites for just getting information about camera 2 api
After research backing up my phone several times with companion app
Looking for tutorials to enable without rooting and unlocking the bootloader
DAY2(Bootloader unlocked - Non rooted)
After realizing that you can't do anything without unlocking your bootloader prepared for unlocking (By the way you need to get a unlocking key from Sony's website with your IMEI)
After unlocking bootloader trying adb shell and fastboot commands I couldn't able to enable then searched for solutions in fastboot mode booting on custom recovery (in my case TWRP) try to flash it and running adb shell commands it didn't enable. (The main problem is I couldn't get RAW checked from camera probe app and gcam needs it for processing.)
DAY3(Bootloader unlocked - Rooted)
I rooted with magisk but with TWRP i didn't use the install section because I couldn't able to find the .zip file so I used the adb sideload thing. After downloading the magisk manager app and access to root I've tried using build.prop, terminal both phone and computer, magisk modules and adb sideload to flash .zip files for enabling camera 2 API (that gave me error while doing) but whatever I've tried to do didn't work out for me.
For who are wanting gcam to work in your Xperia XZ1 for my case and research I couldn't able to enable Camera 2 API and couldn't find a way to enable I think Sony needs to give us RAW processing option. All in all rooting your XZ1 not that bad idea after all because I don't think Sony give this lineup an another android update (Android Q). If you have any questions about the process don't hesitate to ask. Take care of yourselves and be aware of what you're doing with your lifes and your devices.
Click to expand...
Click to collapse
I tried it in a similar way in June,and the results are the same. As far as I know, Sony has no plans to open Camera2 APIs - they are more inclined to force users to use Sony's own cameras,than open APIs to allow users to use Google cameras or others. This brand is just like this, always paying less attention to user feedback. But at least we've tried to do this - it's better than someone who hasn't tried it.
P.S.There's a way to backup TA partition before unlock bootloader: https://forum.xda-developers.com/xp...devonly-exploits-temp-root-to-backup-t3795510 .I know it's too late to tell you...sorry.
TimCrownie said:
I tried it in a similar way in June,and the results are the same. As far as I know, Sony has no plans to open Camera2 APIs - they are more inclined to force users to use Sony's own cameras,than open APIs to allow users to use Google cameras or others. This brand is just like this, always paying less attention to user feedback. But at least we've tried to do this - it's better than someone who hasn't tried it.
P.S.There's a way to backup TA partition before unlock bootloader: https://forum.xda-developers.com/xp...devonly-exploits-temp-root-to-backup-t3795510 .I know it's too late to tell you...sorry.
Click to expand...
Click to collapse
Thanks for your explanation and help, I really appreciate it. Only if Sony listen us their market share can grow and they can compete with others much better.
Hi, thanks for share this tutorials!
I've some questions, sorry before, im like super noob
1. Its seems you still using stock rom, is right? And what version?
2. The image looks very noisy, is that because you lost the drm keys?
Thanks before
Apakah maksudnya kamera terbuka adalah kamera manual?
deniz_nam said:
If you looking for a google camera mod for XZ1 and whatever you already downloaded is crashing while opening the app (except the apks that hasn't HDR+ feature) and you want this gcam so bad that thinking about opening your bootloader and rooting your phone just for that feature don't do it (againg if you rooting just for gcam).
First of all the reason that gcam not working because in your device Camera 2 API isn't enabled so if you made a little research you know that you can enable that with just unlocking your bootloader but here is the catch if you already unlock the bootloader even rooted your phone and you still can't enable Camera 2 API that's because SONY doesn't want you to enable. Now I'm going to talk what I already tried. (If you know how please kindly explain it in the mentions)
DAY 1(Bootloader locked - Non rooted)
Making research from various sites for just getting information about camera 2 api
After research backing up my phone several times with companion app
Looking for tutorials to enable without rooting and unlocking the bootloader
DAY2(Bootloader unlocked - Non rooted)
After realizing that you can't do anything without unlocking your bootloader prepared for unlocking (By the way you need to get a unlocking key from Sony's website with your IMEI)
After unlocking bootloader trying adb shell and fastboot commands I couldn't able to enable then searched for solutions in fastboot mode booting on custom recovery (in my case TWRP) try to flash it and running adb shell commands it didn't enable. (The main problem is I couldn't get RAW checked from camera probe app and gcam needs it for processing.)
DAY3(Bootloader unlocked - Rooted)
I rooted with magisk but with TWRP i didn't use the install section because I couldn't able to find the .zip file so I used the adb sideload thing. After downloading the magisk manager app and access to root I've tried using build.prop, terminal both phone and computer, magisk modules and adb sideload to flash .zip files for enabling camera 2 API (that gave me error while doing) but whatever I've tried to do didn't work out for me.
For who are wanting gcam to work in your Xperia XZ1 for my case and research I couldn't able to enable Camera 2 API and couldn't find a way to enable I think Sony needs to give us RAW processing option. All in all rooting your XZ1 not that bad idea after all because I don't think Sony give this lineup an another android update (Android Q). If you have any questions about the process don't hesitate to ask. Take care of yourselves and be aware of what you're doing with your lifes and your devices.
Click to expand...
Click to collapse
CameraAPI 2 works normally on the XZ1 AOSP10 under development by Sjll, but there is an ISP problem and the pictures taken are not saved.
try and camera super pixel for static themes.
excellent performance!!!
a little edit after just for shadows and hight light and you will have an outstanding results.
Georgerapp said:
try and camera super pixel for static themes.
excellent performance!!! a little edit after just for shadows and highlights and you will have an outstanding results.
Click to expand...
Click to collapse
Outstanding pictures for real! Did you take these pictures with the Open Camera App? Which app you used for the 'little editing' afterwards? Nice church! :good:
SGH-i200 said:
Outstanding pictures for real! Did you take these pictures with the Open Camera App? Which app you used for the 'little editing' afterwards? Nice church! :good:
Click to expand...
Click to collapse
ι shoot them with camera super pixel from playstore .
that app is for stills photos , no people , no pets .
after i edit the large file that gives on photoshop express and reduse the file at 40% quality to give me more comfortable image size.
open the app and at settings put resolution at 32 mp for back and 51.9 for the front.
enable noise reduction edge enhancement debug mode and place jpeg quality at 100.

How to enable camera 2API without root or custom recovery on any android?

Hi I was wondering if there's a way to enable camera 2 api on any android without root or unlocking bootloader/custom recovery please help I have a sharp aquos R2 phone and I really want to install and use Google camera I checked it on a app it's hardware supported but not supported my software please help...
Hey Shayan
Did you find any Gcam port working on Sharp R2?
@Shayan69
If Camera2 API is part of your device's ROM, but not enabled by OEM, then IF device is rooted there is a 50:50 chance to get it enabled.
You simply have to modify Android's system file build.prop as follows
Code:
persist.camera.HAL3.enabled=1
and afterwards re-boot phone. You can then test whether it worked by launching a third-party camera app like Open Camera or Camera FV-5 and checking in the Settings menu if you can enable Camera2 API mode.

Categories

Resources