Add hide Magisk Manager feature

This commit is contained in:
topjohnwu
2017-08-22 03:01:54 +08:00
parent ea6552615d
commit 657f4ab303
24 changed files with 296 additions and 14 deletions

1
unhide/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

25
unhide/build.gradle Normal file
View File

@@ -0,0 +1,25 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.topjohnwu.unhide"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':resource')
}

25
unhide/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/topjohnwu/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.topjohnwu.unhide">
<application
android:icon="@mipmap/ic_launcher"
android:label="Unhide Magisk Manager"
android:theme="@android:style/Theme.NoDisplay">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,33 @@
package com.topjohnwu.unhide;
import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Locale;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String command = String.format(
"pm unhide com.topjohnwu.magisk\n" +
"am start -n com.topjohnwu.magisk/.SplashActivity\n" +
"pm uninstall %s\n" +
"exit\n",
getApplicationInfo().packageName);
Process process;
try {
process = Runtime.getRuntime().exec("su");
OutputStream in = process.getOutputStream();
in.write(command.getBytes("UTF-8"));
in.flush();
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
finish();
}
}