topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
47.6k stars 12.08k forks source link

Hide props from certain apps? #1471

Closed moetayuko closed 5 years ago

moetayuko commented 5 years ago

Some games check USB debugging status and refuse to launch if enabled. Concretely, Kirara Fantasia requires persist.sys.usb.config ≠ adb.

Currently, Magisk implements a "global" prop override mechanism which maintains a list of sensitive props and sets them to fixed value. Apparently we can't apply the same thing to persist.sys.usb.config since the hacked value is exposed to everything including the Settings app itself.

Is it possible for Magisk to implement a "local" prop override mechanism so that a list of props could be hidden from certain apps i.e. the ones inside the hidelist table only?

RikkaW commented 5 years ago

Magisk's "hide" is implemented by really modifying the prop values, so it's impossible to implement "local prop override" with the current method.

https://github.com/topjohnwu/Magisk/blob/515f346dcc21209de414032d8390b189fd893a40/native/jni/magiskhide/hide_utils.cpp#L46-L55 https://github.com/topjohnwu/Magisk/blob/515f346dcc21209de414032d8390b189fd893a40/native/jni/resetprop/resetprop.cpp#L171-L186

What you need is a method like https://github.com/RikkaApps/Riru-LocationReportEnabler (but Riru-LocationReportEnabler itself does not support custom prop now).

topjohnwu commented 5 years ago

@dianlujitao just like what @RikkaW said, Magisk is actually modifying the property data in memory, so unfortunately it will not be possible

moetayuko commented 5 years ago

@RikkaW @topjohnwu Thanks so much for clarification, the Riru solution is a bit too overkill to me tbh, I'll investigate if there're better solutions taking advantage of being able to build Android from scratch.