salvogiangri / KnoxPatch

LSPosed module to get Samsung apps/features working again in your rooted Galaxy device.
GNU General Public License v3.0
688 stars 31 forks source link

[Suggestion] Add hooks for PersonaManagerService #36

Closed naxitoo closed 12 months ago

naxitoo commented 12 months ago

The same way removing KnoxGuard locks your device, removing SecAppSeparation throws a FATAL EXCEPTION IN SYSTEM PROCESS on every boot, making the device unusable as well.

I believe these hooks would make sense as SecAppSeparation is also a Knox app which causes issues when deleted, and there may be users who don't use this app at all and want to get rid of it.

The class is located in services.jar.

Here the logs:

<6>[   57.985629]  [4:PersonaManagerS: 1918] !@*** FATAL EXCEPTION IN SYSTEM PROCESS: PersonaManagerService
<6>[   57.985629]  [4:PersonaManagerS: 1918] java.lang.IllegalArgumentException: Unknown component: ComponentInfo{com.samsung.android.appseparation/com.samsung.android.appseparation.view.launcher.LauncherActivity}
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at com.android.server.pm.ComputerEngine.getComponentEnabledSettingInternal(ComputerEngine.java:5802)
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at com.android.server.pm.ComputerEngine.getComponentEnabledSetting(ComputerEngine.java:5784)
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at com.android.server.pm.IPackageManagerBase.getComponentEnabledSetting(IPackageManagerBase.java:387)
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at com.android.server.pm.PersonaManagerService$PersonaHandler.handleMessage(PersonaManagerService.java:1207)
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at android.os.Handler.dispatchMessage(Handler.java:106)
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at android.os.Looper.loopOnce(Looper.java:226)
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at android.os.Looper.loop(Looper.java:313)
<6>[   57.985629]  [4:PersonaManagerS: 1918]    at android.os.HandlerThread.run(HandlerThread.java:67)
salvogiangri commented 12 months ago

From what I can see there's nothing to hook or fix in frameworks:

int state;
try {
    state = getIPackageManager().getComponentEnabledSetting(new ComponentName("com.samsung.android.appseparation", "com.samsung.android.appseparation.view.launcher.LauncherActivity"), 0);
} catch (RemoteException e) {
    e.printStackTrace();
    state = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
}

if (userInfo.isUserTypeAppSeparation() && state != PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
    enforceAppSeparationDeletion();
}

This code already handles the case where that app is uninstalled from system, it'll only print the stack trace in case an exception is thrown. If this app does cause major issues when uninstalled then do not uninstall it, you can't remove all the system apps since they might be necessary for the OS to function normally.