Properly fixing Oreo + Magisk camera lag - Xiaomi Mi A1 Questions & Answers

I've seen people recommending to set selinux to permissive to solve camera lag on Oreo rooted with Magisk.
I think that's a pretty bad idea since it completely defeats having selinux at all. Permissive selinux + root is an especially dangerous combination, as explained here by @Jman420.
Now I'm no selinux expert, but I think what would be much better is to explicitly only enable the required permissions.
While looking for this I came across this commit on the sony sepolicy, which explicitly enables some selinux policies to fix camera denials.
Magisk supports modifying selinux policies at runtime using the `magiskpolicy` command. To make this work we should make a magisk module that runs some `magiskpolicy` commands, so effectively we need to translate the granted policies from the linked commit to `magiskpolicy` commands.
This is where I got stuck a little and could use some help.
I tried this:
Code:
magiskpolicy --live "allow hal_camera_default vndbinder_device chr_file { read write }”
magiskpolicy --live "allow hal_camera_default camera_prop file { read }”
magiskpolicy --live "allow hal_camera_default property_socket sock_file { write }”
magiskpolicy --live "allow hal_camera_default gpu_device chr_file { read write }”
magiskpolicy --live "allow hal_camera_default sysfs file { read }”
magiskpolicy --live "allow hal_camera_default hal_graphics_mapper_hwservice hwservice_manager { find }”
magiskpolicy --live "allow hal_camera_default qdisplay_service service_manager { find }”
magiskpolicy --live "allow vndservicemanager hal_camera_default dir { search }”
magiskpolicy --live "allow vndservicemanager hal_camera_default file { read }”
magiskpolicy --live "allow vndservicemanager hal_camera_default process { getattr }”
But that didn't fix the camera lag.
This does fix it (largely):
Code:
magiskpolicy --live "permissive camera_prop"
magiskpolicy --live "permissive hal_camera_default"
But obviously this is also shotgun surgery. Anyone with more selinux knowledge willing to chime in here? Perhaps @topjohnwu or @Jman420?

From your quoted article it sounds like It does seem to not matter too, too much though.. Basically once a malicious app has root priviliges it can circumvent selinux anyways..
Anyways, I hope you get this solved. I'm on permissive & root and more security is always better!

The post mentions that running rooted at all is a liability and that's true, but with selinux permissive mode it's even worse.
It might not make a huge difference, but if we can have a good camera experience with selinux enabled I'd prefer that.
I haven't had time to look into this further, but for now I'm running with permissive camera_prop and hal_camera_default only and it's working fine.

Hi. I use Magisk and I have been facing the camera lag issue as well after upgrading to Oreo. Now I am not a dev in any way and this may sound like an insanely noob question but where and how exactly do I enter the magiskpolicy commands to fix the camera issue? I am willing to try OP's solution. Do I have to download a terminal emulator or something like that?

Yes, you can do it in Terminal emulator.
Type in "su", then grant root-priliviges and then type in the two line of code mentioned above.
For me it works till the next reboot.

Pyrb said:
I've seen people recommending to set selinux to permissive to solve camera lag on Oreo rooted with Magisk.
I think that's a pretty bad idea since it completely defeats having selinux at all. Permissive selinux + root is an especially dangerous combination, as explained here by @Jman420.
Now I'm no selinux expert, but I think what would be much better is to explicitly only enable the required permissions.
While looking for this I came across this commit on the sony sepolicy, which explicitly enables some selinux policies to fix camera denials.
Magisk supports modifying selinux policies at runtime using the `magiskpolicy` command. To make this work we should make a magisk module that runs some `magiskpolicy` commands, so effectively we need to translate the granted policies from the linked commit to `magiskpolicy` commands.
This is where I got stuck a little and could use some help.
I tried this:
Code:
magiskpolicy --live "allow hal_camera_default vndbinder_device chr_file { read write }”
magiskpolicy --live "allow hal_camera_default camera_prop file { read }”
magiskpolicy --live "allow hal_camera_default property_socket sock_file { write }”
magiskpolicy --live "allow hal_camera_default gpu_device chr_file { read write }”
magiskpolicy --live "allow hal_camera_default sysfs file { read }”
magiskpolicy --live "allow hal_camera_default hal_graphics_mapper_hwservice hwservice_manager { find }”
magiskpolicy --live "allow hal_camera_default qdisplay_service service_manager { find }”
magiskpolicy --live "allow vndservicemanager hal_camera_default dir { search }”
magiskpolicy --live "allow vndservicemanager hal_camera_default file { read }”
magiskpolicy --live "allow vndservicemanager hal_camera_default process { getattr }”
But that didn't fix the camera lag.
This does fix it (largely):
Code:
magiskpolicy --live "permissive camera_prop"
magiskpolicy --live "permissive hal_camera_default"
But obviously this is also shotgun surgery. Anyone with more selinux knowledge willing to chime in here? Perhaps @topjohnwu or @Jman420?
Click to expand...
Click to collapse
Thanks! Those two lines worked for me too using terminal emulator. Did you finally make a Magisk module that do this at start up? If you did may you upload here until a better solution is found? Thanks. Best regards.

I have made it into an app.
Here: https://forum.xda-developers.com/mi-a1/themes/fix-camera-delay-boot-t3742022
Give it root permission after installing. It will run the code every time the device reboots.

Thanks for that fix. I made a magisk module that'll run this on startup, feel free to use this (at your own risk)
Code:
magiskpolicy --live "permissive camera_prop"
magiskpolicy --live "permissive hal_camera_default"
Credit for the fix goes to @Pyrb - I only put his fix into a magisk module
EDIT: taken offline for now. Gonna need to investigate something first.
File reuploaded. I had a bootloop after a second reboot but it worked without any issues since. So use at your own risk:

arnabJ said:
I have made it into an app.
Here: https://forum.xda-developers.com/mi-a1/themes/fix-camera-delay-boot-t3742022
Give it root permission after installing. It will run the code every time the device reboots.
Click to expand...
Click to collapse
Thanksssssss

Pyrb said:
I've seen people recommending to set selinux to permissive to solve camera lag on Oreo rooted with Magisk.
I think that's a pretty bad idea since it completely defeats having selinux at all. Permissive selinux + root is an especially dangerous combination, as explained here by @Jman420.
Now I'm no selinux expert, but I think what would be much better is to explicitly only enable the required permissions.
While looking for this I came across this commit on the sony sepolicy, which explicitly enables some selinux policies to fix camera denials.
Magisk supports modifying selinux policies at runtime using the `magiskpolicy` command. To make this work we should make a magisk module that runs some `magiskpolicy` commands, so effectively we need to translate the granted policies from the linked commit to `magiskpolicy` commands.
This is where I got stuck a little and could use some help.
I tried this:
Code:
magiskpolicy --live "allow hal_camera_default vndbinder_device chr_file { read write }”
magiskpolicy --live "allow hal_camera_default camera_prop file { read }”
magiskpolicy --live "allow hal_camera_default property_socket sock_file { write }”
magiskpolicy --live "allow hal_camera_default gpu_device chr_file { read write }”
magiskpolicy --live "allow hal_camera_default sysfs file { read }”
magiskpolicy --live "allow hal_camera_default hal_graphics_mapper_hwservice hwservice_manager { find }”
magiskpolicy --live "allow hal_camera_default qdisplay_service service_manager { find }”
magiskpolicy --live "allow vndservicemanager hal_camera_default dir { search }”
magiskpolicy --live "allow vndservicemanager hal_camera_default file { read }”
magiskpolicy --live "allow vndservicemanager hal_camera_default process { getattr }”
But that didn't fix the camera lag.
This does fix it (largely):
Code:
magiskpolicy --live "permissive camera_prop"
magiskpolicy --live "permissive hal_camera_default"
But obviously this is also shotgun surgery. Anyone with more selinux knowledge willing to chime in here? Perhaps @topjohnwu or @Jman420?
Click to expand...
Click to collapse
I've discovered that only this line is required:
Code:
magiskpolicy --live "permissive hal_camera_default"
or
Code:
magiskpolicy --live "allow hal_camera_default * * *"
I wasn't able to narrow it down further to which target needed to be allowed. dmesg and kmsg only had one target for hal_camera_default but allowing that didn't fix it.

Localhorst86 said:
Thanks for that fix. I made a magisk module that'll run this on startup, feel free to use this (at your own risk)
Credit for the fix goes to @Pyrb - I only put his fix into a magisk module
EDIT: taken offline for now. Gonna need to investigate something first.
File reuploaded. I had a bootloop after a second reboot but it worked without any issues since. So use at your own risk:
Click to expand...
Click to collapse
Thanks. This works well and no bootloops.

Google camera doesn't seem to work for me if i don't install permissive script. Will this eliminate the need of permissive script for google camera?

ashu.mkb said:
Google camera doesn't seem to work for me if i don't install permissive script. Will this eliminate the need of permissive script for google camera?
Click to expand...
Click to collapse
yes it will.. but u will need camera2 api enabled for gcam to work
---------- Post added at 12:42 PM ---------- Previous post was at 11:55 AM ----------
justin97530 said:
I've discovered that only this line is required:
Code:
magiskpolicy --live "permissive hal_camera_default"
or
Code:
magiskpolicy --live "allow hal_camera_default * * *"
I wasn't able to narrow it down further to which target needed to be allowed. dmesg and kmsg only had one target for hal_camera_default but allowing that didn't fix it.
Click to expand...
Click to collapse
which target was it? can you tell me?

coolkoushik07 said:
yes it will.. but u will need camera2 api enabled for gcam to work
---------- Post added at 12:42 PM ---------- Previous post was at 11:55 AM ----------
which target was it? can you tell me?
Click to expand...
Click to collapse
It was `search` for`qti_debugfs` of type `dir`, but allowing that didn't fix it.

BlackoutOl said:
Yes, you can do it in Terminal emulator.
Type in "su", then grant root-priliviges and then type in the two line of code mentioned above.
For me it works till the next reboot.
Click to expand...
Click to collapse
Where is the magiskpolicy binary meant to be? I'm using Termux that I downloaded from F-Droid and it doesn't seem to be on the path
edit: sorry, it's just in /sbin. not sure why that wasn't on my path.

Localhorst86 said:
Thanks for that fix. I made a magisk module that'll run this on startup, feel free to use this (at your own risk)
Code:
magiskpolicy --live "permissive camera_prop"
magiskpolicy --live "permissive hal_camera_default"
Credit for the fix goes to @Pyrb - I only put his fix into a magisk module
EDIT: taken offline for now. Gonna need to investigate something first.
File reuploaded. I had a bootloop after a second reboot but it worked without any issues since. So use at your own risk:
Click to expand...
Click to collapse
Thank you so much. Both of you guys. Yesterday I unlocked and rooted my phone and after I completed my new setup (I did a factory reset too) I came up to this camera lag issue.
Lucky us, xda is here.
Installed that module in Magisk and worked. Only thing to mention is a bootloop οn firtst boot. After that everything was ok.

start time of camera didn't reduce after applying fix in my case.(both in stock camera & Gcam).
I clean flashed & rooted. Then when i applied cam2 API, & start using Gcam or stock, i saw lag in starting. Even i see lag when i click setting in both camera.
Code:
magiskpolicy --live "permissive camera_prop"
magiskpolicy --live "permissive hal_camera_default"
Both didn't fix any lag.
Also tried
Code:
magiskpolicy --live "allow hal_camera_default surfaceflinger_service service_manager find"
That also didn't fix any lag.

Code:
magiskpolicy --live "allow hal_camera_default * * *"
Above fixed Camera Lag for me. I made a Magisk Module for that.

.:Addicted:. said:
Code:
magiskpolicy --live "allow hal_camera_default * * *"
Above fixed Camera Lag for me. I made a Magisk Module for that.
Click to expand...
Click to collapse
I downloaded directly from Magisk's downloads.
Have you created it?
https://github.com/Magisk-Modules-Repo/MI-A1-Camera-Startup-Lag-Oreo

My camera lag fixed after watching this video
Watch this video:

Related

NTFS on your android with full read write support

How to install this:
1. put copymodulecrc to the /data/local/tmp folder and chmod them to 755
(adb shell chmod 755 /data/local/tmp/copymodulecrc)
2. put ntfs-3g and ntfsmount to the folder /system/bin and chmod them to 755
(adb shell chmod 755 /system/bin/ntfs-3g)
(adb shell chmod 755 /system/bin/ntfsmount)
3. put sdcardfs.ko to the folder /system/lib/modules and chmod them to 644
(adb shell chmod 644 /system/lib/modules/sdcardfs.ko)
What is next? Next:
1. in order to get it working, sdcardfs.ko must be patched to match your kernel version since every kernel modules is paired with kernel by version string, so if version string not match module version it will not work! So you must patch sdcardfs.ko module using tool called copymodulecrc! Copymodulecrc will extract version string from any module of the your stockrom kernel modules and copy them directly to the sdcardfs.ko (patch them). First of all you need to look into your /system/lib/modules folder and use any .ko file NAME for referencie in next commands:
Code:
adb shell /data/local/tmp/copymodulecrc /system/lib/modules/PUT_NAME_OF_THE_KO_YOU_FOUND_IN_STOCK_ROM_KERNEL_MODULES /system/lib/modules/sdcardfs.ko
So replace PUT_NAME_OF_THE_KO_YOU_FOUND_IN_STOCK_ROM_KERNEL_MODULES with the name of the any module you found in modules folder! Done.
2. if you completed step 1 without errors you are ready for this step. You need to locate script called install-recovery.sh (on most devices it is in folder /system/etc) and add next lines:
Code:
insmod /system/lib/modules/sdcardfs.ko
Done. On every next reboot sdcardfs kernel module will be automatically included in your kernel.
3. if you get error in patching sdcardfs.ko whole thing will not work! So these step is important! You can verify success by command: (su -c "insmod /system/lib/modules/sdcardfs.ko") , if you see error than sdcardfs is not working, if you see nothing than it is working
Since you completed these 3 things, you are ready to use NTFS volumes on your device! To understand these things:
1. first of all, you can not mount ntfs volume regulary trought settings menu since android not support ntfs by default! You must mount/umount your ntfs volume manually (you can use for example android terminal emulator when you need to mount/umount ntfs). You will not see any details about ntfs volume in settings menu since android not support ntfs by default, you can see details in most file managers only.
How to mount and unmount:
1. to mount (first connect your usb ntfs volume to your device usb port) :
Code:
su -c "ntfsmount mount"
Done! Your ntfs volume by these command is mounted and you are ready to read/write them using your faworite file manager
2. To umount (do in mind - every time before you going to remove ntfs volume from your device you must unmount it!):
Code:
su -c "ntfsmount umount"
Done! You are ready to remove ntfs volume from your usb port.
NTFS on sdcard? Yes but you need to modify a bit ntfsnount script! Don't ask me how ypu can modify them, do it byself!
Since somebody complain here about gpl licence, I am not ready ready to share sdcardfs source code with you since it is not gpl licenced, instead it is apache 2.0 licenced by Samsung guys @ 2013 and I no need to share it with you since you wanted to see them forced! I not like when somebody forcing me for something! Find it, patch them, make module of them byself
ntfs-3g is not compiled by me, it is used from here -> http://forum.xda-developers.com/showthread.php?t=1724078
ntfsmount script is created by me.
Copymodulecrc I do not know where I found them but here is source code:
Code:
/* copymodulecrc */
/*
* Copyright (C) 2014 CUBE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
int main(int argc, char **argv) {
struct stat st;
off_t filesize;
int fd;
char *data, *pos;
unsigned int i;
int bFound;
unsigned long crcval;
if (argc != 3) {
printf("usage: copymodulecrc [modulename(src)] [modulename(dst)]\n");
return -1;
}
if (stat(argv[1], &st) != 0) {
fprintf(stderr, "module1 stat failed.\n");
return -1;
}
filesize = st.st_size;
fd = open(argv[1], O_RDONLY);
if (fd < 0) {
fprintf(stderr, "module1 open failed.\n");
return -1;
}
data = mmap(NULL, filesize, PROT_READ, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
fprintf(stderr, "module1 mmap failed.\n");
close(fd);
return -1;
}
pos = data;
bFound = 0;
for (i = 0; i < (filesize - 12); ++i) {
if (memcmp((void *)pos, (void *)"module_layout", 13) == 0) {
bFound = 1;
break;
}
pos++;
}
if (bFound == 0) {
fprintf(stderr, "module1 crc not found.\n");
munmap(data, filesize);
close(fd);
return -1;
}
pos -= 4;
memcpy((void *)&crcval, (void *)pos, 4);
munmap(data, filesize);
close(fd);
printf("module crc=%08x\n", (unsigned int)crcval);
if (stat(argv[2], &st) != 0) {
fprintf(stderr, "module2 stat failed.\n");
return -1;
}
filesize = st.st_size;
fd = open(argv[2], O_RDWR);
if (fd < 0) {
fprintf(stderr, "module2 open failed.\n");
return -1;
}
data = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
fprintf(stderr, "module2 mmap failed.\n");
close(fd);
return -1;
}
pos = data;
bFound = 0;
for (i = 0; i < (filesize - 12); ++i) {
if (memcmp((void *)pos, (void *)"module_layout", 13) == 0) {
bFound = 1;
break;
}
pos++;
}
if (bFound == 0) {
fprintf(stderr, "module2 crc not found.\n");
munmap(data, filesize);
close(fd);
return -1;
}
pos -= 4;
memcpy((void *)pos, (void *)&crcval, 4);
munmap(data, filesize);
close(fd);
printf("module crc copied.\n");
return 0;
}
And finaly, files you need to install is in attachment, enjoy!
Will try late-night. Just asking, will it work on Galaxy S3-GTi9300?
Just need some clarification, when you say NTFS support, do you mean read and write or just read-only?
munjeni said:
Not going to explain in details, here is my tool which will add ntfs support to your android, run them and folow instructions! If you unable to patch sdcardfs.ko kernel module (giving you error when you doing insmod) than the whole things will not work on your device Curntly tested device is Xperia Z1 Compact on android version 14.4.A.0.108! Important thing is having sdcardfs installable, the rest is easy.
In order to have sdcardfs module insmoded on every reboot, you need to add one line into /system/etc/install-recovery.sh :
The rest of the tutorial you can see under application. Enjoy if you find this usefull!
Click to expand...
Click to collapse
/system/etc/install-recovery.sh :-
- install-recovery.sh file is not available at /system/etc/.
- Is it possible to create the file and then we can insert the line?
Am using AOSP - Carbon ROM on Xperia Z..
Thank you!!
'A Munjeni Work' again!
Thanks a lot! :victory:
Looking forward for what all can I do with it.
Wow this will be amazing, cant wait to try...
anonyo said:
Just need some clarification, when you say NTFS support, do you mean read and write or just read-only?
Click to expand...
Click to collapse
+1
anonyo said:
Just need some clarification, when you say NTFS support, do you mean read and write or just read-only?
Click to expand...
Click to collapse
Quote!
Just a heads up..
On Xperia Z2 tablet with 4.4.2, connected to 1tb NTFS drive.
After modding the ko and setting all permissions, rebooting, will only "half-mount" the drive. It sees it, recognizes it, but claims drive is empty (wants to format it).
Status bar displays "Empty USB Storage"
In settings, when selecting Mount USB Storage, it briefly acts like it will mount. for a split second.
Any files I can get that can possibly help?
UPDATE: After running the mount commands via terminal, now it seems to mount it via ES File explorer. Although it sometimes still gives me the message in statusbar.
But seems to be working well.
Seeing as this patches a kernel module will it work on rooted phones with a locked bootloader?
Aborto said:
Seeing as this patches a kernel module will it work on rooted phones with a locked bootloader?
Click to expand...
Click to collapse
My Z2 Tablet has a locked bootloader. So yes, it should. There's nothing going on that warrants an unlocked bootloader. Just the addition of some files and permission changes, which are normal with a rooted device.
Also note, that in the Settings\Storage, it will not show up as being "mounted". At least not in my case. However, ES File Explorer has no issue with it, and shows as a USB 1052 drive under the "Local" menu. Navigation seems normal within the drive.
I get the "USB Drive Empty or Unsupported" message in the status bar, for a few seconds, but the ES FE displays the drive contents, and the message goes away after it reads drive contents. Note that it may assign a different drive identifier each time you use it.
In testing I have found apps from the market;
StickMount does not work at all on my Stock OS.
Paragon NTFS mount works, but it runs as a system process using memory and probably battery.
This mod seems to work, for the most part, as long as you use ES File Explorer.
OP - you must provide the source for any modified code covered by the GPL that you are distributing - that includes the sdcardfs kernel module, and the ntfs-3g binary. Packing them in an encrypted Windows executable does not help.
spoidar said:
OP - you must provide the source for any modified code covered by the GPL that you are distributing - that includes the sdcardfs kernel module, and the ntfs-3g binary. Packing them in an encrypted Windows executable does not help.
Click to expand...
Click to collapse
No he doesn't. Only the zimage (kernel) is covered under GPL.
UPDATE: Just to clarify, the matter "Has" been brought to the Developers Committee to address any possible GPL violations. The DC is more informed on GPL.
Moscow Desire said:
No he doesn't. Only the zimage (kernel) is covered under GPL.
Click to expand...
Click to collapse
What? No. The ntfs-3g project is licensed under the GPL. And so is the sdcardfs driver. You can't generate binaries from GPL code and distribute them without providing the source.
Need help here
After i Copy copymodulecrc and sdcardfs.ko to /data/local/tmp and gave the permission as rwx-r-r to copymodulecrc. how to run it? can anybody help me here to patch sdcardfs.ko
coolrevi said:
After i Copy copymodulecrc and sdcardfs.ko to /data/local/tmp and gave the permission as rwx-r-r to copymodulecrc. how to run it? can anybody help me here to patch sdcardfs.ko
Click to expand...
Click to collapse
First off, permissions must be set to 755 (rwx-rx-rx) if I'm not mistaken. Root Explorer converts it to the numerical format when you change permissions.
Next, use a terminal program (available from the play store) Make sure you run it as SU. (type SU + Enter, you will get the # sign) Then type in the commands and paths as indicated. (I copied and pasted my paths)
Moscow Desire said:
First off, permissions must be set to 755 (rwx-rx-rx) if I'm not mistaken. Root Explorer converts it to the numerical format when you change permissions.
Next, use a terminal program (available from the play store) Make sure you run it as SU. (type SU + Enter, you will get the # sign) Then type in the commands and paths as indicated. (I copied and pasted my paths)
Click to expand...
Click to collapse
I got it till replacing a line in install-recovery.sh but i am stuck there as there is no line called ntfs.ko to replace with
Thanks for posting this up, can't wait to get home and test this out.
I am recieving the error in the screenshot
The device that i am using is Lenovo A3500HV which contains a Jellybean 4.2.2 AOSP ROM (Hardly any modification)
Please Help
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}

Make Viper4Android 2.4.0.1 work on Android 6.0

I had some trouble trying to make Viper4Android v2.4.0.1 work on my Honor 5C running Android 6.0. This could be helpful…
Viper4Android didn't work after installation and reboot, the driver status showing as "abnormal". It seems related to a change in default SELinux policy.
I read that changing globally the SELlinux policy to "permissive" can solve the problem but it may be an extreme solution (SELinux is a security feature to restrict what an application can do, I don't know the potential edge effects).
I found another solution on the web, which consists in patching the SELinux policies at boot, just enough for Viper4Android to work.
If you did not make a systemless installation of SuperSU, open an adb shell and use these commands (courtesy of androiding.how):
Code:
su
mount -o rw,remount /system
cd /system/su.d
echo '#! /system/bin/sh' > 50viper.sh
echo '/system/xbin/supolicy --live "allow mediaserver mediaserver_tmpfs:file { read write execute };"' >> 50viper.sh
chmod 755 50viper.sh
cd /
mount -o ro,remount /system
And reboot.
If you did make a systemless installation of SuperSU, open an adb shell and use this instead:
Code:
su
mount -o rw,remount /su
cd /su/su.d
echo '#! /system/bin/sh' > 50viper.sh
echo '/su/bin/supolicy --live "allow mediaserver mediaserver_tmpfs:file { read write execute };"' >> 50viper.sh
chmod 755 50viper.sh
cd /
mount -o ro,remount /su
exit
And reboot.
Didn't work for me, tried the 2nd method as the first one gave an error at the 3rd step, completed everything, rebooted, still no luck
imrock said:
Didn't work for me, tried the 2nd method as the first one gave an error at the 3rd step, completed everything, rebooted, still no luck
Click to expand...
Click to collapse
I just noticed that in my 2nd block the characters ’ and ” were used instead of ' and ". I'm not a POSIX shell expert but since these are not the same characters it can make a difference.
I've updated the 2nd method, you can give it a try — you can use it "as it is", it will overwrite the previously created file.
This trick didn't work for me.
I ended up installing SELinuxModeChanger and now Viper is rockin' :good:

Request: A910F permissive mode kernel

Hi everyone. The reason i make this thread is to ask for helping. If anybody willingly to build permissive mode kernel for A910F. Very appreciate. If there is somewhere exist, where to find it. I already try to make my own kernel for this model but ive failed at part build the zimage.img. i try to bash script "build_kernel.sh" but fail. I follow all tutorial 100% but still fail. Really appreciate if somebody want to help me
Not a permissive kernel, but in most use cases granting the required selinux permission in an enforcing kernel might be enough, in a terminal emulator use cat /proc/avc_msg or logcat -s audit
For example
type=1400 audit(...): avc: denied { execute } for pid=22889 comm="HwBinder:22882_" path=... dev="tmpfs" ino=... scontext=u:r:hal_audio_default:s0 tcontext=ubject_r:hal_audio_default_tmpfs:s0 tclass=file
In a terminal emulator,
/sbin/magiskpolicy --live "allow hal_audio_default hal_audio_default_tmpfs file execute"
The format is
/sbin/magiskpolicy --live "allow scontext tcontext tclass permission"
The permission "ioctl" uses allowxperm instead.
If it says not found then one of these
su -c /sbin/magiskpolicy
/sbin/supolicy
/system/xbin/supolicy
/su/xbin/supolicy
/su/bin/supolicy
/su/xbin_bind/supolicy
/system/bin/supolicy
/system/bin/magiskpolicy
supolicy
If if says permission denied type su first.
Restart the software that required the permission, and the software that it requires, should revert after restarting the device.

[FIX] Magisk avc denials

A few weeks ago I noticed some avc denials spamming my logcat (several times a second), that seemed to be related to Magisk. The entries looked like this:
Code:
W/magisk.bin( 3464): type=1400 audit(0.0:369437): avc: denied { connectto } for path=006F7548376267326B594870356668695237506A33326741706137314A456F6871 scontext=u:r:qti_init_shell:s0
tcontext=u:r:magisk:s0 tclass=unix_stream_socket permissive=0 ppid=1 pcomm="init" pgid=1 pgcomm="init"
I don't know if this warning arose because of how I installed Magisk (IIRC a direct install from within Magisk Manager), or if it even affects anyone else, but I will note how I fixed it here - by adding a magiskpolicy rule to my boot script in service.d:
Code:
magiskpolicy --live "allow qti_init_shell magisk unix_stream_socket { connectto }"
Another site had a little more detail about this denial but I may not be allowed to link to it
There are still some different avc denials but they are not as frequent, don't seem important, and aren't related to Magisk so I left them. An example:
Code:
W/main (21651): type=1400 audit(0.0:347370): avc: denied { read } for name="u:object_r:sys_usb_tethering_prop:s0" dev="tmpfs" ino=11750 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:sys_usb_tethering_prop:s0 tclass=file permissive=0 ppid=746 pcomm="main" pgid=746 pgcomm="main"
+-
Good find, I am also certain that magisk cause more issues.
Envoyé de mon G8142 en utilisant Tapatalk

[v4a] Install Viper4Android on Pixel 3a Android Pie

This guide is about installing v4a on factory ROM viper4Android. Your mileage may vary with other versions of Android/OSs. I'm not responsible if your device bricks. I'm only writing this guide because I miss the golden days of using V4A on my personal device to enhance audio quality.
1. Get the earliest version of Android from Google's website. Make sure you have fastboot and adb installed on your system.
https://developers.google.com/android/images#sargo > get Android 9 from here
2. Enable Developer options. Go to developer options and enable bootloader unlocking.
3. Reboot the phone by holding down Power + Vol Down button to boot into fastboot.
4. With the phone in fastboot mode, connect it to your PC and execute the following. WARNING: This will wipe all data on the phone, I mean ALL.
Code:
fastboot flashing unlock
Then confirm on the phone that you want to unlock the bootloader.
5. Go into the zip file you've downloaded from Google and find the other zip file from within it. Extract the boot.img from that second zip.
6. Boot the phone into Android 9 but DO NOT connect it to any network.
7. Enable developer options again and disable automatic system updates from developer options.
8. Download Magisk from Github (from the releases) https://github.com/topjohnwu/Magisk
9. Clone the v4a repo from https://github.com/Magisk-Modules-Repo/ViPER4Android-FX and put the contents in a zip file. The top folder should contain the repo's folders, so when you open the zip file it should be exactly the same as the repo. On Linux you can use the following commands to do the job:
Code:
git clone https://github.com/Magisk-Modules-Repo/ViPER4Android-FX.git v4a
zip -r viper.zip v4a
Do the same thing with this repo to download Audio Modification Library : https://github.com/Zackptg5/Audio-Modification-Library
10. Transfer the boot.img, magisk apk and the compiled zips to the phone storage. Install Magisk.apk
11. Open Magisk and select install from top and select and patch a file. Choose the boot.img. This will give you another file called magisk_boot_random.img. Transfer this file to your desktop.
12. Boot the phone in fastboot mode and flash this magisk patched boot image onto the boot partition with the following:
Code:
fastboot flash boot magisk_patched_random.img
13. Boot the phone and open Magisk. Choose Modules> install from storage and install viper.zip and then AML's zip files. DO NOT REBOOT.
14. Open the v4a application and allow it to install the drivers. This will reboot the phone automatically.
15. Install a file explorer that allows root access to the system, add the following code to the /data/adb/modules/ViPER4AndroidFX/post-fs-data.sh
Code:
magiskpolicy --live 'allow audioserver audioserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow audioserver system_file file { execmod }'
magiskpolicy --live 'allow mediaserver mediaserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow mediaserver system_file file { execmod }'
magiskpolicy --live 'allow audioserver unlabeled file { read write execute open getattr }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default process { execmem }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default_tmpfs file { execute }'
magiskpolicy --live 'allow hal_audio_default audio_data_file dir { search }'
magiskpolicy --live 'allow app app_data_file file { execute_no_trans }'
magiskpolicy --live 'allow mtk_hal_audio mtk_hal_audio_tmpfs file { execute }'
16. Reboot and open v4a app, if it's not working, in the settings toggle the Legacy option on & off. This should be working now.
Thank you, confirmed working on a Pixel 3a XL.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
marstonpear said:
This guide is about installing v4a on factory ROM viper4Android. Your mileage may vary with other versions of Android/OSs. I'm not responsible if your device bricks. I'm only writing this guide because I miss the golden days of using V4A on my personal device to enhance audio quality.
1. Get the earliest version of Android from Google's website. Make sure you have fastboot and adb installed on your system.
https://developers.google.com/android/images#sargo > get Android 9 from here
2. Enable Developer options. Go to developer options and enable bootloader unlocking.
3. Reboot the phone by holding down Power + Vol Down button to boot into fastboot.
4. With the phone in fastboot mode, connect it to your PC and execute the following. WARNING: This will wipe all data on the phone, I mean ALL.
Code:
fastboot flashing unlock
Then confirm on the phone that you want to unlock the bootloader.
5. Go into the zip file you've downloaded from Google and find the other zip file from within it. Extract the boot.img from that second zip.
6. Boot the phone into Android 9 but DO NOT connect it to any network.
7. Enable developer options again and disable automatic system updates from developer options.
8. Download Magisk from Github (from the releases) https://github.com/topjohnwu/Magisk
9. Clone the v4a repo from https://github.com/Magisk-Modules-Repo/ViPER4Android-FX and put the contents in a zip file. The top folder should contain the repo's folders, so when you open the zip file it should be exactly the same as the repo. On Linux you can use the following commands to do the job:
Code:
git clone https://github.com/Magisk-Modules-Repo/ViPER4Android-FX.git v4a
zip -r viper.zip v4a
Do the same thing with this repo to download Audio Modification Library : https://github.com/Zackptg5/Audio-Modification-Library
10. Transfer the boot.img, magisk apk and the compiled zips to the phone storage. Install Magisk.apk
11. Open Magisk and select install from top and select and patch a file. Choose the boot.img. This will give you another file called magisk_boot_random.img. Transfer this file to your desktop.
12. Boot the phone in fastboot mode and flash this magisk patched boot image onto the boot partition with the following:
Code:
fastboot flash boot magisk_patched_random.img
13. Boot the phone and open Magisk. Choose Modules> install from storage and install viper.zip and then AML's zip files. DO NOT REBOOT.
14. Open the v4a application and allow it to install the drivers. This will reboot the phone automatically.
15. Install a file explorer that allows root access to the system, add the following code to the /data/adb/modules/ViPER4AndroidFX/post-fs-data.sh
Code:
magiskpolicy --live 'allow audioserver audioserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow audioserver system_file file { execmod }'
magiskpolicy --live 'allow mediaserver mediaserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow mediaserver system_file file { execmod }'
magiskpolicy --live 'allow audioserver unlabeled file { read write execute open getattr }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default process { execmem }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default_tmpfs file { execute }'
magiskpolicy --live 'allow hal_audio_default audio_data_file dir { search }'
magiskpolicy --live 'allow app app_data_file file { execute_no_trans }'
magiskpolicy --live 'allow mtk_hal_audio mtk_hal_audio_tmpfs file { execute }'
16. Reboot and open v4a app, if it's not working, in the settings toggle the Legacy option on & off. This should be working now.
Click to expand...
Click to collapse
I am on android 11, unlocked bootloader, rooted with Magisk (patched boot.img). I want to roll back to Android 9. I'm not concerned about losing data as this is not my daily driver. Do I need to relock the bootloader before attempting this downgrade? I am doing this is to successfully install Viper4Android, so I figured this question might belong in this thread. Thank you in advance!
The Optimizer said:
I am on android 11, unlocked bootloader, rooted with Magisk (patched boot.img). I want to roll back to Android 9. I'm not concerned about losing data as this is not my daily driver. Do I need to relock the bootloader before attempting this downgrade? I am doing this is to successfully install Viper4Android, so I figured this question might belong in this thread. Thank you in advance!
Click to expand...
Click to collapse
Hi, no. You don't need to relock your bootloader to downgrade your OS.
marstonpear said:
Hi, no. You don't need to relock your bootloader to downgrade your OS.
Click to expand...
Click to collapse
Thank you so much for your quick reply! I really miss having v4a on all of my phones. Cheers!
marstonpear said:
This guide is about installing v4a on factory ROM viper4Android. Your mileage may vary with other versions of Android/OSs. I'm not responsible if your device bricks. I'm only writing this guide because I miss the golden days of using V4A on my personal device to enhance audio quality.
1. Get the earliest version of Android from Google's website. Make sure you have fastboot and adb installed on your system.
https://developers.google.com/android/images#sargo > get Android 9 from here
2. Enable Developer options. Go to developer options and enable bootloader unlocking.
3. Reboot the phone by holding down Power + Vol Down button to boot into fastboot.
4. With the phone in fastboot mode, connect it to your PC and execute the following. WARNING: This will wipe all data on the phone, I mean ALL.
Code:
fastboot flashing unlock
Then confirm on the phone that you want to unlock the bootloader.
5. Go into the zip file you've downloaded from Google and find the other zip file from within it. Extract the boot.img from that second zip.
6. Boot the phone into Android 9 but DO NOT connect it to any network.
7. Enable developer options again and disable automatic system updates from developer options.
8. Download Magisk from Github (from the releases) https://github.com/topjohnwu/Magisk
9. Clone the v4a repo from https://github.com/Magisk-Modules-Repo/ViPER4Android-FX and put the contents in a zip file. The top folder should contain the repo's folders, so when you open the zip file it should be exactly the same as the repo. On Linux you can use the following commands to do the job:
Code:
git clone https://github.com/Magisk-Modules-Repo/ViPER4Android-FX.git v4a
zip -r viper.zip v4a
Do the same thing with this repo to download Audio Modification Library : https://github.com/Zackptg5/Audio-Modification-Library
10. Transfer the boot.img, magisk apk and the compiled zips to the phone storage. Install Magisk.apk
11. Open Magisk and select install from top and select and patch a file. Choose the boot.img. This will give you another file called magisk_boot_random.img. Transfer this file to your desktop.
12. Boot the phone in fastboot mode and flash this magisk patched boot image onto the boot partition with the following:
Code:
fastboot flash boot magisk_patched_random.img
13. Boot the phone and open Magisk. Choose Modules> install from storage and install viper.zip and then AML's zip files. DO NOT REBOOT.
14. Open the v4a application and allow it to install the drivers. This will reboot the phone automatically.
15. Install a file explorer that allows root access to the system, add the following code to the /data/adb/modules/ViPER4AndroidFX/post-fs-data.sh
Code:
magiskpolicy --live 'allow audioserver audioserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow audioserver system_file file { execmod }'
magiskpolicy --live 'allow mediaserver mediaserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow mediaserver system_file file { execmod }'
magiskpolicy --live 'allow audioserver unlabeled file { read write execute open getattr }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default process { execmem }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default_tmpfs file { execute }'
magiskpolicy --live 'allow hal_audio_default audio_data_file dir { search }'
magiskpolicy --live 'allow app app_data_file file { execute_no_trans }'
magiskpolicy --live 'allow mtk_hal_audio mtk_hal_audio_tmpfs file { execute }'
16. Reboot and open v4a app, if it's not working, in the settings toggle the Legacy option on & off. This should be working now.
Click to expand...
Click to collapse
I've flashed Android 9, Rooted successfully (Magisk v25.2 boot.img patch), when I try to install the v4a/modules zips I made, the terminal outputs an error:
- Copying zip to temp directory
! Unzip error
Do these files need to be compressed in a certain way to be able to flash them correctly? I cloned both repo's and just compressed them into .zip files. Am I doing this correctly?
The Optimizer said:
I've flashed Android 9, Rooted successfully (Magisk v25.2 boot.img patch), when I try to install the v4a/modules zips I made, the terminal outputs an error:
- Copying zip to temp directory
! Unzip error
Do these files need to be compressed in a certain way to be able to flash them correctly? I cloned both repo's and just compressed them into .zip files. Am I doing this correctly?
Click to expand...
Click to collapse
I encountered the same issue when I zipped the repos wrongly. Just ensure all the files in the repo are in the top directory of the zip. So basically META-INF directory needs to be there when you open the zip on desktop.
marstonpear said:
I encountered the same issue when I zipped the repos wrongly. Just ensure all the files in the repo are in the top directory of the zip. So basically META-INF directory needs to be there when you open the zip on desktop.
Click to expand...
Click to collapse
I was thinking that this may be the issue. Thank you for confirming!

Categories

Resources