-
Notifications
You must be signed in to change notification settings - Fork 663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Redmi K20 Pro] Front cam pops up on first boot and won't retract #539
Comments
Log excerpt from under MIUI, switching to and out of front camera for 3 times. The log is filled with a ton of other error messages, but there are keywords like "PopupCameraManagerService" and "motor_impl" which might be of interest. |
Have you got the kernel sources?
Please grep for motor_impl and PopupCameraManagerService in /system:
`grep -r -e PopupCameraManagerService -e motor_impl /system`
And paste the result here
If there are some files that matches in /system/framework, please attach
the whole /system/framework here
Le dim. 2 juin 2019 à 02:08, Andy Yan <notifications@github.com> a écrit :
… Log excerpt from under MIUI, switching to and out of front camera for 3
times. The log is filled with a ton of other error messages, but there are
keywords like "PopupCameraManagerService" and "motor_impl" which might be
of interest.
log.txt
<https://github.com/phhusson/treble_experimentations/files/3244314/log.txt>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#539?email_source=notifications&email_token=AAAA4OTPWY2PWN7QRCRQPWLPYMFOZA5CNFSM4HSA47L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWXK4QQ#issuecomment-497987138>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAA4OUBTF5IEUYOIQ6WES3PYMFOZANCNFSM4HSA47LQ>
.
|
|
In the meantime, since I don't care that much about a working front cam, is it possible to forcefully disable it somehow, so the OS doesn't even try to initialize it (which I guess causes it to pop up)? I tried deleting |
Ok cool, sounds like we just need to reverse engineer vendor.xiaomi.hardware.motor from services.vdex. I dont really know how you'd disable that though. Reversing the HAL sounds easier. Hopefully I'll have time to do that today or tomorrow On stock ROM does camera pop at boot and then hide, or it never pops until camera starts? |
Maybe too early to ask, but will the motor be triggered on calling front cam, or a separate app that summons the cam beforehand and hides it after? Personally I'm okay with both, front cam only gets used maybe weekly.
You da man... Thanks!
It never pops. Also, if for some reason the camera is already out (e.g. after flashing and booting the GSI), then at the end of the bootanimation it will be automatically retracted. |
Oh yeah, forgot to mention that the regular K20 (davinci - not on the market yet) has the same pop-up mechanism, please add it into the device filter as well when you're ready to commit. |
Here is the reverse-engineered hal: types.hal
IMotor.hal
IMotorCallback.hal
|
Can I test it out on my side? I assume this goes somewhere into vendor/interfaces? Sorry, not familiar with actual hardware stuff... EDIT: Gonna read how other HALs were added and do it similarly, hope it works... |
I recommend you to wait, but if you want to try it yourself, you need a
"phh" AOSP tree, put the files I've mentioned in it a vendor/interfaces
(it's Java like tree with folders matching package name), call hidl-gen -L
androidbp on it, then do a little program to call that HAL, you can see
samples in device/phh/treble/cmds/
Le dim. 2 juin 2019 à 16:30, Andy Yan <notifications@github.com> a écrit :
… Here is the reverse-engineered hal:
Can I test it out on my side? I assume this goes somewhere into
vendor/interfaces? Sorry, not familiar with actual hardware stuff...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#539?email_source=notifications&email_token=AAAA4OUFDCYOUYSWVZOSCTLPYPKRNA5CNFSM4HSA47L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWXW5IA#issuecomment-498036384>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAA4OXSHEPNA44ZDJP2KGDPYPKRNANCNFSM4HSA47LQ>
.
|
Well seems I'm the only guy who's after running GSI on this device right now, so of course I'll have to test somehow. Are you going to make a separate fork which I can sync from? |
So uh, I got impatient, and after looking up some stuff and reading your codes, I wrote this:
The binary was built just fine, but when I called it in adb shell, it simply returns "Failed getting IMotor", meaning I don't even get to test how it works... |
Helper pushed in phhusson/device_phh_treble@819cbe3 Here are prebuilts: Now, push those two files in /data/local/tmp, then in adb do: where command can be:
the "42" here are placeholders for integers. I don't know the meaning of those integers (it's called cookie in Xiaomi HAL), but my guess is that you're supposed to use incrementing value at every command. So please test those various commands and answer what happens when doing what. |
Liked that "42" there :D As for the test result:
Looking great so far! P.S. I've already created a Wiki page for this device, will submit some other not-so-glaring issues as well while I have your attention. |
I don't really understand why the attempt you pasted here didn't work (sorry i missed it when i wrote mine -_-') Ok it's good news it works. My guess for I guess next step is to integrate that into cameraservice. Or we could have an intermediate version where it's crudely integrated into treble app. |
Hope you could sort out the former solution (it should pop-up/retract automatically then, right?), and also take care of the double action issue in the process.
When writing the |
Well it's possible to have popup/retract automatically in both cases. cameraservice is less flexible but most likely more stable. treble_app would probably do it on camera app launch though
You should rather push the
no group, leave default ( = root) |
Good to know, either is good enough for me then.
Yeah I made a build with your latest commits, and now the /system lib works as well. For now I've paired it with the app "Terminal Shortcut" that can execute the command for me one-tap (well, 2-tap).
I wrote this
...which doesn't work (I tried both |
When the device is in offline charging does the camera pop up? |
You're missing the LD_LIBRARY_PATH |
|
The device doesn't offline charge - it flashes a weird cyan-colored screen. But yeah, in that case it doesn't pop up.
I tried with both LD_LIBRARY_PATH present and absent...
Doesn't work... |
Oh ok. Sounds like it's the kernel or even the bootloader that decides to
do that. There isn't much we can do.
Just call take back instead of init then
Le lun. 3 juin 2019 à 17:31, Andy Yan <notifications@github.com> a écrit :
… When the device is in offline charging does the camera pop up?
The device doesn't offline charge - it flashes a weird cyan-colored
screen. But yeah, in that case it doesn't pop up.
You're missing the LD_LIBRARY_PATH
Try using sh -c as the service setting
Where command includes LD settings i.e. is the one you run in terminal
And if it's in a class, no need to start on boot.
I tried with both LD_LIBRARY_PATH present and absent...
service xiaomi-motor-init /system/bin/xiaomi-motor init
class main
seclabel u:r:phhsu_daemon:s0
oneshot
on boot
start xiaomi-motor-start
Doesn't work...
I should mention that the front cam pops up *really* early - right before
the "Redmi" logo disappears.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#539?email_source=notifications&email_token=AAAA4OXMVO5HYA3EBQ5RRATPYU2OLA5CNFSM4HSA47L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZY6ZI#issuecomment-498306917>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAA4OSWFJJ42H5WUAOMGSDPYU2OLANCNFSM4HSA47LQ>
.
|
I thought of this as well, but then how come MIUI doesn't pop it up...? Kinda confused there. |
K, first thing to try is remove the on boot and the line after it Then, if it still doesn't work, please provide kernel logs ( |
Yeah, still nada. dmesg (60 secs long - should be enough) here. |
At what bootstage does the camera pop up? Right as the boot anim begins? Or just as the lockscreen shows? Or before the boot animation? |
As said earlier...
|
oh damn that makes very little sense. |
Camera doesn't pop up after a hot reboot from |
That's really weird. I guess the kernel has some kind of state machine that the HAL reads to decide whether to pop up? |
Probably. At this point I guess we'd have to wait for the international release of this device, so that the kernel source can be made available. |
@phhusson Is it considered OK if I make a pull request to device_phh_treble that enables building |
Yup, go ahead. I already have multiple debug tools included.
Le mer. 5 juin 2019 à 20:19, Andy Yan <notifications@github.com> a écrit :
… @phhusson <https://github.com/phhusson> Is it considered OK if I make a
pull request to device_phh_treble that enables building xiaomi_motor,
given that it's ultimately a debug command? I'm thinking about pushing the
audio fix along with this as well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#539?email_source=notifications&email_token=AAAA4OQHFILW5NWETQ6UCDTPZB65XA5CNFSM4HSA47L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXBTQDA#issuecomment-499333132>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAA4OU6SFVSYEIBTRB6UCLPZB65XANCNFSM4HSA47LQ>
.
|
Serves as a manual/intermediate solution to phhusson/treble_experimentations#539 Change-Id: Ia334f7d106b121014c791b0edb06b59a0eef3580
@phhusson Somewhat off-topic, but where can I ask you about something that probably doesn't qualify as an issue here? |
Kernel source just dropped: https://github.com/MiCode/Xiaomi_Kernel_OpenSource/tree/raphael-p-oss - hopefully something helpful inside. |
I also had the same error. Can you show me how to fix it most easily? Thanks for the help. |
Can't tackback after I run ./xiaomi-motor tackbackShortly 1 |
It works again after I reboot several times, and I notice |
I remember back when we testing it did, but now that you mentioned it I tested again and you're right. Updated wiki page accordingly. Also, the takebackShortly command is pretty much useless, ignore it. |
Well, today I got some free time and tried my hands at auto popup/takeback, and after an afternoon/night of attempts, I think I've written the dirtiest hack I've ever did... |
I think doing a PR is better so I can comment directly on it?
As for HAL integration, I can do that (and if it's a PR I can push directly
to the PR :P)
Le lun. 1 juil. 2019 à 18:10, Andy Yan <notifications@github.com> a écrit :
… Well, today I got some free time and tried my hands at auto
popup/takeback, and after an afternoon/night of attempts, I think I've
written the dirtiest hack I've ever did...
***@***.***
<AndyCGYan/device_phh_treble@b738dcd>
***@***.***
<LineageOS/android_frameworks_av@9896cab>
I don't know how to call HAL functions from within CameraService (or if
that's even possible), so I had to rely on xiaomi-motor. In the end it
worked out fine, and no double popup/takeback issues (since I always check
for motorStatus).
Can you please review this @phhusson <https://github.com/phhusson> - I
hesitate to even submit this hack as a PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#539?email_source=notifications&email_token=AAAA4OSX5RYDSPAD6UKTUGDP5IT6RA5CNFSM4HSA47L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY6TYNI#issuecomment-507329589>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAA4OT5GMQCKK34E7Q7243P5IT6RANCNFSM4HSA47LQ>
.
|
Except for SELinux policy, this should do the trick:
|
Oh shoot, no wonder I couldn't include the necessary header. |
I don't know, I guess you'll see :P
Ah my bad, that was a poor copy/translate/paste, I read your code as |
Indeed:
It does work well when I use a permissive kernel, so I'll be submitting that part of the solution as a PR shortly. I also tried to write sepolicy, but since I've never done it before, I could only imitate what I read, and for now I couldn't get it working - it builds but summoning the cam doesn't work, with this spit out in log:
|
So after more swimming in codes, this here is what I wrote... 0001-sepolicy-Grant-cameraserver-permission-to-access-mot.patch.txt Meanwhile I'll shift my focus to running |
So in trying to figure out running The irony is, this ended up achieving auto popup/takeback, but running |
Now that there are proper ROMs, I've moved on from GSIs. It's been a wild ride... |
Serves as a manual/intermediate solution to phhusson/treble_experimentations#539 Change-Id: Ia334f7d106b121014c791b0edb06b59a0eef3580
Serves as a manual/intermediate solution to phhusson/treble_experimentations#539 Change-Id: Ia334f7d106b121014c791b0edb06b59a0eef3580
Serves as a manual/intermediate solution to phhusson/treble_experimentations#539 Change-Id: Ia334f7d106b121014c791b0edb06b59a0eef3580
Serves as a manual/intermediate solution to phhusson/treble_experimentations#539 Change-Id: Ia334f7d106b121014c791b0edb06b59a0eef3580
Device: Redmi K20 Pro (raphael)
Treble status: Yes, A/B, native
Stock Android version: 9 - stock fastboot ROM here
This device has a pop-up front camera, and I was worried about how it'd work before I got the device. That suspicion turned out to be true, but in an unexpected way - on first boot of the GSI, the front cam motor enables and pops the cam out on its own, and refuses to retract afterwards. This makes the phone unsafe to carry around as a daily driver.
For anyone curious about this device: most other basic functions (except auto brightness, which I don't use) seems to work alright as far as I tested - even in-display FP seems to work out-of-the-box (I still have the factory protection film on so can't test how accurate). Likely is because this device is quite similar to Mi 9 (flashing procedure also nearly the same). Just this front cam issue solved and I can have it as my new primary device.
If you need any logs or dumps, or maybe need info on other aspects of the device, I'll gladly provide them when I can.
The text was updated successfully, but these errors were encountered: