66import android .content .SharedPreferences ;
77import android .content .pm .ApplicationInfo ;
88import android .content .pm .PackageManager ;
9+ import android .os .Build ;
910import android .preference .PreferenceManager ;
1011
1112import java .io .File ;
@@ -40,6 +41,7 @@ public void onReceive(Context context, Intent intent) {
4041 if (Common .REFRESH_APPS_INTENT .equals (intent .getAction ())) {
4142 resetNativeHooks (context );
4243 }
44+
4345 applyNativeHooks (context );
4446 }
4547
@@ -56,10 +58,16 @@ private void applyNativeHooks(Context context) {
5658 mRootShell .runCommand ("am force-stop " + app );
5759 }
5860
59- if (libraryInstalled ) {
61+ if (libraryInstalled && ! nativeHookingApps . isEmpty () ) {
6062 mRootShell .runCommand ("chmod 755 /data/local/" );
6163 mRootShell .runCommand ("chmod 755 /data/local/librootcloak.so" );
6264 mRootShell .runCommand ("chmod 755 /data/local/rootcloak-wrapper.sh" );
65+
66+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
67+ // Allowing wrapping on Lollipop and newer
68+ WrappingSELinuxPolicy policy = new WrappingSELinuxPolicy ();
69+ policy .inject ();
70+ }
6371 }
6472 }
6573
@@ -105,6 +113,13 @@ private void upgradeLibrary(Context context) {
105113 mRootShell .runCommand ("cp '" + library + "' /data/local/" );
106114 mRootShell .runCommand ("chmod 755 /data/local/librootcloak.so" );
107115 }
108-
109-
116+
117+ private class WrappingSELinuxPolicy extends eu .chainfire .libsuperuser .Policy {
118+ @ Override
119+ protected String [] getPolicies () {
120+ return new String []{
121+ "allow untrusted_app zygote fifo_file { write }"
122+ };
123+ }
124+ }
110125}
0 commit comments