yashsingh1/xdaforums huggingface dataset:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] maverick6664:
Camera problem

Everyone, be careful about camera behavior after rooting!!

After I got root on my xz2, I found a strange camera problem; I can't see through camera at all, even though this camera can take any pictures/videos very clearly as before. Somehow in video mode, scene can be seen (:D) through the camera. In still camera mode, no scene is on the screen, but I can take excellent still pictures with this camera. As a matter of course, this happens with selfie mode also.

I have applied the two camera fix patches in the first message as a matter of course.

I tried some applications, but everything failed. This happens with QR code readers also. QR code readers can't read QR code at all even if the code is in the (supposed) field. What can I do? I suspect DRM is corrupt. So I decided to use xperfix....:eek: I need to set up Windows...(until now, I've been using Linux only.) XperiFIX isn't usable in VirtualBOX, because of usb connection problem. I ordered a secondhand notebook (yes, it's a Sony!:good:) only for xperiFIX and maybe xperia companion.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Oh, a rare XZ2 compact with TCM touch chip :(

(The mentioned & fixed touch bug was only in the stock twrp)

https://github.com/sonyxperiadev/bug_tracker/issues/351

There we're trying to locate and fix the root of the problem. :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Please ignore the bootctrl module error :)

You can fix it by mounting the vendor partition first, but the bootctrl is only needed to switch the slots on A/B devices.

You tried to install normal apps via TWRP?

Did you decrypt your userdata with your pincode/password/Swipe?

If not it can't access the userdata place where your apps are stored.

And [MENTION=8489563]maverick6664[/MENTION]

There is a FAQ on the first page about the black camera preview on stock. [emoji14]

Please read the entire post carefully.

I fixed the problem on my phone with this instructions.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] holychelsea:
Yes, i tried to install normal apps to system via TWRP.

I don't use any lock screen method, i tried to install from both Internal Storage and SD Card, all success with no error but when i reboot into system, no app installed. When i install magisk, i stuck with bootloop at sony screen
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] dhacke:
Which Magisk Version did you install? 19.1, 19.2, 19.3 makes boot problems.

Stay on 18.1 until 19.4 is released.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] holychelsea:
i tried magisk 18.1 and 19.3
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] maverick6664:
Oh......but I saw these camera patches were intended for older version. So I reinstalled the current firmware, 52.0.A.8.131 US version, then, as long as unrooted, camera preview worked, but once rooted, camera preview was black. I don't know why. And somehow the patched 6 files were still there (they had today's timestamp). Why aren't they overwritten? Anyway I started from scratch; flashed vbmeta.img, launched twrp, advanced-wiped all data and system partitions except for SD card (ie, all the working partitions), and flashed the current firmware, then as usual patched the latest magisk. Now I have working a camera preview!! :highfive: When I had rooted for the first time, I read much enough to patch for camera, but not enough to dodge black camera preview :p:p

Fortunately I had backed up all the apps and data in SD card with TitaniumBackup (and they were synced with my desktop PC via sftp using foldersync, just in case), so recovering was easy .

Anyway thanks! Now I'm looking inside of magisk.zip and found many tricks. To tell the truth, until now I had wondered why magisk.zip can be used in any of arm/arm64/x86 architectures, but now I understood. And a lot of stuff is in this zip file. Especially, util_functions.sh is interesting. I am satisfied to know camera patches (and maybe any other patches, if any) are written with these functions.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Can you try the newest magisk canary ? :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Hồ Ly Tiên Sinh:
Can you give me a link to download newest magisk, i only find magisk 19.3
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
https://xdaforums.com/apps/magisk/dev-magisk-canary-channel-bleeding-edge-t3839337

Here you go [emoji14]
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] depeche76:
Mr Martin you are perfect!twrp firmware 131 for xz2p successfully installed.! :good::fingers-crossed:I didn't forget my promise to you.! thnak you [MENTION=6031898]MartinX3[/MENTION]
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
As an update, I re-flashed the stock UK Customized .131 firmware, and executed `fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img` and `fastboot boot twrp-xz2c.img` and it boots into TWRP just fine. It asked for my password, I entered my unlock pin, and it said it successfully decrypted my system. I can browse files just fine. I can even overwrite system files.

Installing TWRP via Advanced/Install Recovery Ramdisk fails with "Failed to mount /vendor (invalid argument)"

Flashing Magisk via Install fails the same.

If I go into "mount" it doesn't let me check the box next to /vendor.

I've attached my dmesg. It looks like stuff shows up around 2.8s, 5.4-5.6s, and 37s to the end

Also attached recovery.log. Decryption starts after line 50. Looks like /vendor mounts at line 133. Looks like it's trying vendor_a. Maybe an issue with the bootctrl not letting it access the proper a/b for vendor?

Line 514 says ro.modversion=OmniROM-9-20190810-apollo-HOMEMADE, but I flashed stock firmware with newflasher and unpacked/booted the stock twrp for .131.

TWRP install starts around line 803

A bunch of errors after that:

I:Actual block device: '/dev/block/bootdevice/by-name/vendor_b', current file system: 'ext4'
I:Cannot find file /sys/class/timed_output/vibrator/enable
I:Can't probe device /dev/block/bootdevice/by-name/vendor_b
Failed to mount '/vendor' (Invalid argument)

Magisk fails the same way at line 1171

LIne 1315 I successfully overwrite some Waze map files in /data/data.

Try camerafix at line 1410, similar errors.

It appears related to bootctrl (ref: line 864-866) attempting to set the partitions for /vendor.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] holychelsea:
Thanks, i installed magisk successfully, but i can't installed apps through twrp with zip file. I tried to fix black camera with two zip files "camera fix" i downloaded at first page but failed.

All zip files i installed through twrp show successful message with no error, but not install to my phone.

My phone version: 52.0.A.8.131. Model H8266
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Can you move through your userdata I'm twrp?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
And you didn't mixed the stock and aosp twrp?

And never flashed a custom ROM?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
I had previously attempted to flash OmniROM, but I ran into the touchscreen bug. So I re flashed the stock firmware and started over again. Is there something extra I need to do? These are the same issues I had the first time I tried, before I ever tried to go to OmniROM, but I didn't check logs that time.

Timeline:

Unlock bootloader

Boot and configure stock

Flash .131 with newflasher

Boot and configure

Attempt to install stock twrp.131

Get bootctrl and /vendor error

Download and flash OmniROM

Flash custom ROM twrp, get touchscreen bug

Force reboot into bootloader, re flash stock 131

Boot and configure

Post threads threads Sunday night

Attempt to flash stock twrp again, this time take logs

Post logs
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
You probably need to redownload twrp and install the stock twrp file via "install ramdisk"
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Hồ Ly Tiên Sinh:
I can't understand. Can you explain clearly ?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Can you in twrp use the file Browser and view your userdata in your internal storage?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] duffy64:
i tried all of them for my xz2 compact, but touchscreen is not working?

any solution how to fix it?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
https://github.com/sonyxperiadev/bug_tracker/issues/351 :(
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
I don't know why, but this worked. I now have Magisk root.

As for the black camera preview, from the github link in OP it looks like I need to be on Oreo and run XperiFix. The XperiFix thread suggests the dev hasn't responded to inquiry in a while, so people aren't able to get license. I haven't tried it myself yet, and 19 lb isn't a whole lot of money to blow if it's the only option, but I figured I'd ask first if that's the only way to fix the camera.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Yes, that's the only way

Pm me, if he doesn't response on your xperifix buy.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
It looks like the license key is auto generated now, and the program took it. I haven't used it yet, but I downloaded CE1 Oreo firmware from xperifirm and I'll try it this evening. I'll update in the xperifirm threads if it still works
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] shoey63:
So you unlocked on Oreo, then upgraded to Pie? If so, that's unfortunate. If you upgraded to Pie first, then unlocked you wouldn't need drm fix or camera fix. The camera would just work.

New users please note....
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
Yeah, I unlocked on Oreo, then flashed Pie, and got black camera preview. I didn't think I could flash with non standard tools (newflasher) with the locked bootloader. I'll downgrade this afternoon and try the process with xperifix
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
Ok, I downgraded to Oreo, 11.51_R1A, configured, phone works.

`fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img` works, but `fastboot boot twrp.img` doesn't work, just reboots, looks like it's going to do something, then reboots into system.

If I `fastboot flash boot twrp.img` I can boot into TWRP and Xperifix says it's successful, but I get a boot loop and eventually it says device is corrupt.

Re-flash Oreo, boot and configure.

Trying again with a fresh start, but with Magisk 17.1 as included in the TWRP.tgz

Same steps as before, same results (boot loop at sony logo) :(

I additionally went back to stock Oreo, flashed `fastboot --disable-verity --disable-verification flash vbmeta vbmeta-xz2c.img` and `fastboot flash boot twrp-xz2c.img` and booted to TWRP just fine. Then I pushed Magisk18.1 and the stock kernel included in the twrp zip, and installed those in twrp. after reboot to system, bootloop at sony logo again. I'm done for tonight, but I can play around more tomorrow if anyone has ideas. If not, I'll try to just install twrp with no other scripts and see what happens.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Woops

The old Oreo twrp is different

First flash twrp.IMG

"fastboot flash boot twrp.IMG"

In twrp please flash the kernel.zip and then the twrp.zip.

If there is only one installer.zip, flash only this and restart into the now persistent twrp. There you need to flash magisk 18.1

And don't forget the vbmeta stuff before :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Hồ Ly Tiên Sinh:
Yes, maybe
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
If not, that's the cause for your not installed apps.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
Same same :(

installed stock Oreo, configured it, etc

`fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img` success

` fastboot flash boot twrp.img` success

boot into twrp, success

install kernelinstall.zip, success

clear davlik, success

install kernelinstall.zip, success

clear davlik, success

reboot into system, bootloop at sony logo
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
And where is your flash of twrp, reboot into twrp and flash magisk I mentioned?
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
I'll try it again, because at the moment I can't remember if I rebooted back to twrp after installing the zips before installing magisk, or if I missed installing magisk altogether to see if the system will boot without magisk.

I appreciate your patience with everyone in this thread and will report back
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
I'm sure you'll be successful :)

The vbmeta stuff and magisk are both important for a booting system on Oreo.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
I got Oreo working, with magisk root, but I think xperifix needs an internet connection. I'm running a Hotspot on my phone so it can validate the license key, but it hangs at "pushing magisk." I'm commuting right now, so I can try it once I get home on wifi.

Update:

I got home, and XperiaFix seems to have worked fine (said it was good, no errors in logs, /vendor/lib/drmfix.so and /vendor/lib/drm****.so are present), flashed permissive.zip, magisk shows it installed, root checker app says se linux mode is permissive, but I still have a black camera preview. I'm going to try again and see what happens, but that's where I stand right now

Edit 2: After trying again, it works in oreo! Camera preview back! Now on to Pie!

Edit 3: I now have a rooted Pie with working camera! Hooray! If I'm ever in Germany, I will buy you a litre of altbier
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Beer beer beeeeeeeer muahahaha :D
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] quan.kb:
Please help!

Hi MartinX3,

I have my sony XZ2, yesterday I tried to install TWRP following your instructions. I managed to get in TWRP but I also get bootloop in TWRP again and again. I have flashed the device several times now, and now it gets black camera preview screen. Here's what I did:

1. Get in fastboot mode by adb reboot bootloader

2. fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

3. fastboot boot twrp.img

4. Advanced menu -> "Install recovery ramdisk" -> Choose twrp.img

From there I tried to install Magisk, then reboot but it get bootloop, and the code dd if=/dev/zero of=/dev/block/bootdevice/by-name/misc doesn't work. I have to flash the device by Emma to get back in system.

After that I tried to install only TWRP but I still get bootloop.

I know you have explain this for many ppl, but Im a real noob and not so good at English too, so I usually get lost. Plis help this poor soul :crying:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Try to flash the .131 august firmware with newflasher

Emma has old versions.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] quan.kb:
Will it fix the black camera? Tks for quick reply
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] dhacke:
Black camera can only be fixed via XperiaFix or the switch to a custom rom of MartinX3.

[MENTION=6031898]MartinX3[/MENTION]

Mayby it is good idea to add a big hint on the first page of this thread (not only a github link) that unlocking on oreo break the camera.

I have the feeling many people oversee that problematic.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Hmm, that would be that, I put it on my to do list :(

Thank you!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] quan.kb:
Tks for sharing. I did unlock on Pie actually, February update.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Um, same problem on the first 2 or 3 firmwares

You will need to downgrade, use xperifix, shoot a photo, upgrade, apply camerafix.

Or you have luck and a newer firmware magically repairs your firmware.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] quan.kb:
Thanks a bunch!

One more thing, Im trying to get Gcam and I still really want to, so I need camera2api from Magisk. But I cant get rid of the bootloop. I get stuck at TWRP. So can you give me instruction how to pull this off? Or direct me to the thread that I need.

Thanks for your time.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] voilsb:
I'm going to do a comprehensive write up of my adventures in a few days, to help clear it up too
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Hồ Ly Tiên Sinh:
If not, how can i do to resolve it
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Gcam needs one of my custom Roms and installed GAPPS.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Your twrp needs to match your firmware if the google rollback protection kicks in.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] quan.kb:
Well today I did try to flash .131 aug firmware with the newflasher, and it did magically repair my camera, somehow.

Just wanna let you guys know. Thanks a lot for your help!
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
26.08.2019
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] Klaus N.:
Although I guess you have learned like crazy, good look :fingers-crossed:
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] apaxtc:
if I do exactly what he writes here I get an xz2 with root ????????

Update to newest stock firmware before unlocking!!!

FASTBOOT

fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

fastboot boot twrp.img

TWRP

Advanced menu -> "Install recovery ramdisk" -> Choose twrp.img

Reboot into installed TWRP

TWRP

(Optional) Flash Magisk

Reboot into SYSTEM

(Optional) Install the official Magisk App to gain root.

(Optional) Switch SELinux to permissive (with my permissive.zip)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] dhacke:
Be sure that you use the right twrp (regarding version/variant and date) and Magisk 18.1 or canary build 19.4 .

Other versions make boot problems.

Then, when you follow the instructions,you should get root.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] apaxtc:
ok man ....that's what I'm talking about ... respect exactly what's in the zip...
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] longshenaizhong:
MTP does not work for xz3 with win7
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
what says the /tmp/recovery.log and the dmesg?

Did you tried to use a different PC/OS/usb cable?

Did you used the MTP button in the mount menu?

Windows 7 usb mtp driver are installed?

you're the first reporting it and it works here.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] apaxtc:
something strange

fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img its ok

fastboot boot twrp.img ..can't find doesn't see img ?

what happens ...vbmeta and twrp-xz2 they are in the same folder
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] apaxtc:
I solved, delete -xz2 , just leave only twrp

after flashing let the phone enter in twrp alone.......then flash magisk zip

now i have root sistem with magisk 18.1 :)

thx Martin :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] bibibabi:
I report an error in the installation of TWRP, which DOES NOT COMPROMISE INSTALLATION.

I write only to help other people. if see this error.

TECHNICAL DATA PHONE:

XZ3 ( H8416)

BUILD 52.0.A.8.131 (August 2019)

Mobile phone unlocked bootloader

Installation package for TWRP: 2019-08-10_17-11-50_twrp_stock_xz3_52.0.A.8.131 .

In point 3.1 of the installation (which you can find on the first page of this post).

Advanced menu -> "Install recovery ramdisk" -> Choose twrp.img

When I run the command on TWRP (started by flashboot from pc)

Installation marks this error:

after the words [IMAGE FLASH COMPLETED]
E: Error getting bootctrl module.
Updating partitio details....
...done
Backing up Boot...
cd /tmp/repackorig/ && /sbin/magiskboot --unpack -h
'/tmp/repackoring/boot.img' process ended with ERROR:
Error unpacking image.

This error in red, does not block the flash of the TWRP image, in fact if you restart in recovery mode TWRP starts. So the Root is feasible by following the other points.

Except that I found that starting TWRP in recovery mode is very slow, we get to 3 minutes in which the SONY screen remains white without any colored led on.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] apaxtc:
you just have to write rom stock with Newflasher or flashtools and try again instal twrp

try to follow the "exact" procedure from the tutorial , .......after you install "vbmeta" and "twrp" does not remove cable from phone in 10/15 seconds the phone goes into twrp alone then remove the cable and install and Advanced menu -> "Install recovery ramdisk" -> Choose twrp.img

(get in fastboot whit "adb reboot bootloader" ) not use button combination )( not use flashtools for flash img)(I used it and it didn't work)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] 64801965:
Should I first unlock the bootloader and later wipe the internal storage?(AFAIK wiping internal storage would delete all partition including bootloader partition, which support fastboot mode and downlaod green light mode. So fastboot mode and the download mode would fail?)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] apaxtc:
why delete :)
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] dhacke:
Unlocking BL only deletes the data partition so you will loose your data. And I haven't delete my internal storage ever since i own the phone.

My phone is unlocked and all modes still working (fastboot, flashmode) .
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] apaxtc:
1.any changes in the phone you make at your own risk, nobody obliges you :)

2.if you want to "benefit" from a "free" phone (root) and all the cookies it offers you must also take the risks :)

3.I personally rooted for xz2 and I have no problem with the phone -

due to the fact that I strictly adhered to everything he writes in the tutorial

""Martin""

(personally I have little experience gained over time(root samsung and sony xperia ) since 2012) (when I make root for a new phone i read 10-15 hours about this ! )
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] zarbix:
Having some issues getting the new procedure (fastboot boot twrp.img) to work against Android 8 (to fix the xz2c with xperifix). I have read the FAQ thingie saying to enter blue mode by either doing "adb reboot bootloader" or "fastboot boot bootloader" before flashing vbmeta, followed by fastboot boot twrp.img, however that still doesnt seem to work.

I also remember the procedure used to be different before. I dont recall what it used to be, but the old procedure did work fine, this new one seemingly doesnt.

fastboot boot bootloader

fastboot --disable-verity --disable-verification flash vbmeta vbmeta-xz2c.img

fastboot boot twrp-3.2.3-0-xz2c.img

causes phone to reboot with blue LED still on, then show sony logo, then RED led flashes.. I think 3 times? Then it boots into normal system ("stock" (as in: Sony) android 8) instead of twrp.
[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
Didn't you unlock the device on android P?

If you did, you don't need O and xperifix.

I removed the TWRP O installation instructions.

I thought that xperias with Oreo getting unlocked are rare or zero now one year after PIE came.

Please flash the twrp.img on the boot partition, boot twrp and install the zips for kernel and for twrp, then the magisk 18.1 and the permissive.zip.

If the permissive throws an error, boot the system, install the magisk app and install the permissive.zip in this app as magisk module.

Then install xperifix.