Skip to content

Commit

Permalink
Log output to logcat
Browse files Browse the repository at this point in the history
This makes it possible to run from an init script without losing the
output. There is no impact to the module scripts since the logcat output
is captured there anyway.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
  • Loading branch information
chenxiaolong committed Jun 23, 2024
1 parent 0da29fe commit ac1f6f9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/com/chiller3/oemunlockonboot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import android.os.IInterface;
import android.os.Process;
import android.system.ErrnoException;
import android.util.Log;

import java.lang.reflect.Method;

@SuppressLint({"DiscouragedPrivateApi", "PrivateApi", "SoonBlockedPrivateApi"})
public class Main {
private static final String TAG = "OEMUnlockOnBoot";

private static final int GET_SERVICE_ATTEMPTS = 30;

@SuppressWarnings("SameParameterValue")
Expand Down Expand Up @@ -47,11 +50,11 @@ private static void unlock() throws Exception {

Boolean unlockAllowed = (Boolean) isOemUnlockAllowedByUser.invoke(iFace);
if (unlockAllowed) {
System.out.println("OEM unlocking already enabled");
Log.i(TAG, "OEM unlocking already enabled");
return;
}

System.out.println("Enabling OEM unlocking");
Log.i(TAG, "Enabling OEM unlocking");
setOemUnlockAllowedByUser.invoke(iFace, true);
}

Expand All @@ -77,8 +80,7 @@ public static void main(String[] args) {
switchToSystemUid();
unlock();
} catch (Exception e) {
System.err.println("Failed to enable OEM unlocking");
e.printStackTrace();
Log.e(TAG, "Failed to enable OEM unlocking", e);
System.exit(1);
}
}
Expand Down

0 comments on commit ac1f6f9

Please sign in to comment.