bmax121 / APatch

The patching of Android kernel and Android system
GNU General Public License v3.0
4.29k stars 322 forks source link

profile not supported - same apps in different profiles treated as one single app #475

Closed xxjoe2 closed 3 months ago

xxjoe2 commented 4 months ago

Please check before submitting an issue/在提交 issue 前请检查

Version requirement/版本要求

Describe the bug/描述 bug

profile is not supported, apatch looks like relies on the package name only as key but appid is not used

Reproduce method/复现方法

install an app in normal profile, then clone it in work profile and set permissions with both apps they will be saved as one single entry in package_config with one of the appid only

Expected behavior/预期行为

expected to have 2 entries saved with both package name and appid as unique key

for example com.whatsapp uid 10130 com.whatsapp uid 90130

Actual behaviour /实际行为

only one is saved

although both should have same permissions normally, it is not unusual to have a file explorer with root access in normal profile but without root access in work profile

Screenshots/截图

Screenshot_20240528_034304 Screenshot_20240528_034419_Terminal Emulator

Logs/日志

No response

Device Name/设备名称

samsung note9

OS Version/系统版本

a13

APatch Version/APatch 版本

10740 (i have problems with newer versions so i rolled back to a previous one)

Kernel Version/内核版本

4.9

KernelPatch Version/KernelPatch 版本

0.10.6

Additional context/其他信息

also i found that changes in ap app does not reflected in package_config sometimes, ie, changes not saved to the config file but in memory only

ps if this has been solved in recent updates, pls ignore thus issue

pomelohan commented 4 months ago

You are right, it’s a logical bug that manager only treat package name as symbol. I will solve it when I am free.

also i found that changes in ap app does not reflected in package_config sometimes, ie, changes not saved to the config file but in memory only ALWAYS remember do not manually edit the package_config except using manager, we didn’t listen this file change from kernel side. It won’t work immediately if you changed it manually, you need a syscall to notify kernel config changed or simply reboot your device to make it worked.

pomelohan commented 4 months ago

Hi @xxjoe2: Can you try this build and tell me whether fixed?

https://github.com/bmax121/APatch/actions/runs/9270690789/artifacts/1544454228

You need to remove package_config manually before opening this build.

xxjoe2 commented 4 months ago

hi

thanks for your prompt reply and quick action

i have just tested it but i found that i couldnt check the results by reading the package_config file, it was not updated at all. so i cloned the root explorer to another profile for checking root access

and i can say, for the root access, it works without any problem. i can set an app in different profile with different root access. good work

however there are some minor issues. i can understand that, dont worry. and actually it doesnt worry me neither coz i dont need such function atm but there might be some users who want this

okay the problems are: 1 the uids were incorrectly shown between to two profile apps once in the ap app. for example: ` root explorer uid 100300 (main profile) root explorer uid 950321 (work profile)

were shown as root explorer uid 950321 (main profile) root explorer uid 100300 (work profile) `

2 the exclude switch didnt work properly. i switched one of them to on, then back to the main page or exited the app, the exclude switch turned back to off

3 i also tried to switch on exclude for both of them, but when i revisted the page they were off

so the exclude function for different profile might need to be reviewed again, but the root access is good so far

pomelohan commented 4 months ago

i found that i couldnt check the results by reading the package_config file, it was not updated at all

i found that i couldnt check the results by reading the package_config file, it was not updated at all

Sorry I couldn’t understand this, can you describe it again? Thank you!

xxjoe2 commented 4 months ago

with my 10740, when i change anything in the ap mgr, eg switch on exclude for whatsapp , i can see corresponding changes in package_config (changes will be saved in the file) like whatsapp 100289 0 1 and thats why i was able to find profile app is not supported

but after installing your build, changes were not saved in the config file. after i changed root access or exclude option for root explorer in both normal and work profile, i went to check the config file to see if there were 2 entries for root explorer. however no changes were saved: eg grep rootexplorer package_config

nothing returned. i opened the file and confirmed there was no entry for root explorer

xxjoe2 commented 4 months ago

just updated to 10763, 1064fb8 and here's an example of what i meant by incorrect uid problems with different profile apps. in this case, same uids for 2 different profiles

Screenshot_20240530_040252

pomelohan commented 4 months ago

just updated to 10763, 1064fb8 and here's an example of what i meant by incorrect uid problems with different profile apps. in this case, same uids for 2 different profiles

Screenshot_20240530_040252

I will fix when I am free as soon as possible.

pomelohan commented 4 months ago

just updated to 10763, 1064fb8 and here's an example of what i meant by incorrect uid problems with different profile apps. in this case, same uids for 2 different profiles

Screenshot_20240530_040252

https://github.com/bmax121/APatch/actions/runs/9296784882/artifacts/1550942931

try this build

You need to remove package_config manually and reboot before opening this build.

xxjoe2 commented 4 months ago

does this one write the "rules" to package_config correctly? the last one you gave me didnt write anything and after a few attempts and reboots, it showed only the header but nothing else

pomelohan commented 4 months ago

does this one write the "rules" to package_config correctly? the last one you gave me didnt write anything and after a few attempts and reboots, it showed only the header but nothing else

Yes I fixed, try it

xxjoe2 commented 4 months ago

installed new apk, removed config, rebooted unfortunately, didnt work properly, missing incorrect rules

Screenshot_20240601_034638 Screenshot_20240601_034618_Root Explorer

missing shell in config whatsapp should be 0,1 (main) and 1,0 (work profile) in config, ie the first 2 lines should be: `9510337 1,0

10337 0,1 `

Screenshot_20240601_034857 Screenshot_20240601_034848_Root Explorer

shell appeared in config but not in app didnt change whatsapp but it became both allowed with root

pomelohan commented 4 months ago

installed new apk, removed config, rebooted unfortunately, didnt work properly, missing incorrect rules

Screenshot_20240601_034638 Screenshot_20240601_034618_Root Explorer

missing shell in config whatsapp should be 0,1 (main) and 1,0 (work profile) in config, ie the first 2 lines should be: `9510337 1,0

10337 0,1 `

Screenshot_20240601_034857 Screenshot_20240601_034848_Root Explorer

shell appeared in config but not in app didnt change whatsapp but it became both allowed with root

  1. com.android.shell is always in allow list from kernel, it doesn't matter if not displayed in manager or package_config
  2. I'm trying my best to fix this bug since I can't reproduce it very exactly (I don't use work profile at all), so please be patient.
  3. Try this and tell me result: https://github.com/bmax121/APatch/actions/runs/9331066388/artifacts/1558930023 (same operation as I mentioned before)
  4. Thank you. 🌹
Admirepowered commented 4 months ago

can you provide /data/system/packages.list file

xxjoe2 commented 4 months ago

i am backing up my data partition rn so cant test it until the backup is finished

but i can tell u there is no difference, ie only one single entry for the apps installed in the list, and no uids for different user profiles

btw i have some suggestions regarding this issue. actually i had a very difficult time after installing the first test build. for some reasons, after i restored the ap manager, the lsposed had some problems. it simply didnt load or active and a reinstall didnt help neither. i had to uninstall and reinstall the ap mgr and the modules, as well as lsposed.

i didnt know what happen but it seems there are some compatibility issues like other users, and that's why i had to install an older version since once the new version was installed, my phone would not boot 3 out of 4 times

so i would like to ask if it is possible , how hard would it be, to sperate the ap mgr's app selection together with the write to config part so that i can test it easily? i mean just a fake app with a different package name and without actual granting them root accesses and write the result to a different file like config_test? i guess this would be quite easy, by just skipping the grant access process will do

if that will take you quite a lot of time, you may try to append some fake profile apps to the app list you get, for example com.taobao 100001 and com.taobao 950001, just for testing the result since you dont have dual profile

anyway these are just my 2 cents. what do you think?

xxjoe2 commented 4 months ago

hi

just tested, uids and root access worked properly

however there was one bug left. steps: 1 set both with root access, correctly done 2 set one of them to exclude only, ie 1,0 and 0,1 3 config correctly written 4 close ap and reopen 5 ui and config file entry mismatch, ie both shows 0,1 in config

Screenshot_20240603_165229 Screenshot_20240603_165140_Terminal Emulator

pomelohan commented 4 months ago

hi

just tested, uids and root access worked properly

however there was one bug left. steps: 1 set both with root access, correctly done 2 set one of them to exclude only, ie 1,0 and 0,1 3 config correctly written 4 close ap and reopen 5 ui and config file entry mismatch, ie both shows 0,1 in config

Screenshot_20240603_165229 Screenshot_20240603_165140_Terminal Emulator

Can you confirm whether step 3 is executed successfully?

Did you do anything else after opening ap manager in step 4 and it changed without any manual operation?

xxjoe2 commented 3 months ago

yes, i read the config file after changes every time to see if they are saved correctly

no i never edit the config file manually

pomelohan commented 3 months ago

Maybe fixed in https://github.com/bmax121/APatch/actions/runs/9528468081/artifacts/1604807636

xxjoe2 commented 3 months ago

couldnt get root access after installing this