mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 06:27:39 +00:00
Fix issues in stub APK
This commit is contained in:
parent
f3d7f85063
commit
b05b688267
@ -3,6 +3,7 @@
|
|||||||
package="com.topjohnwu.magisk">
|
package="com.topjohnwu.magisk">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
<application tools:ignore="GoogleAppIndexingWarning"
|
<application tools:ignore="GoogleAppIndexingWarning"
|
||||||
android:allowBackup="true">
|
android:allowBackup="true">
|
||||||
@ -16,11 +17,5 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<receiver android:name=".BootLauncher">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package com.topjohnwu.magisk;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
public class BootLauncher extends BroadcastReceiver {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (TextUtils.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED)) {
|
|
||||||
Intent i = new Intent(context, MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
context.startActivity(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.APKInstall;
|
import com.topjohnwu.magisk.utils.APKInstall;
|
||||||
import com.topjohnwu.magisk.net.Networking;
|
import com.topjohnwu.magisk.net.Networking;
|
||||||
@ -16,16 +17,19 @@ import java.io.File;
|
|||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
|
|
||||||
|
private static final String TAG = "MMStub";
|
||||||
|
private static final boolean IS_CANARY = BuildConfig.VERSION_NAME.contains("-");
|
||||||
private static final String URL =
|
private static final String URL =
|
||||||
"https://raw.githubusercontent.com/topjohnwu/magisk_files/master/" +
|
"https://raw.githubusercontent.com/topjohnwu/magisk_files/" +
|
||||||
(BuildConfig.VERSION_NAME.contains("-") ? "canary_builds/release.json" : "stable.json");
|
(IS_CANARY ? "canary/release.json" : "master/stable.json");
|
||||||
|
|
||||||
private String apkLink;
|
private String apkLink;
|
||||||
|
|
||||||
private void dlAPK() {
|
private void dlAPK() {
|
||||||
Application app = getApplication();
|
Application app = getApplication();
|
||||||
Networking.get(apkLink)
|
Networking.get(apkLink)
|
||||||
.getAsFile(new File(getFilesDir(), "manager.apk"), apk -> APKInstall.install(app, apk));
|
.getAsFile(new File(getFilesDir(), "manager.apk"),
|
||||||
|
apk -> APKInstall.install(app, apk));
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,10 +39,13 @@ public class MainActivity extends Activity {
|
|||||||
Networking.init(this);
|
Networking.init(this);
|
||||||
if (Networking.checkNetworkStatus(this)) {
|
if (Networking.checkNetworkStatus(this)) {
|
||||||
Networking.get(URL)
|
Networking.get(URL)
|
||||||
.setErrorHandler(((conn, e) -> finish()))
|
.setErrorHandler(((conn, e) -> {
|
||||||
|
Log.d(TAG, "network error", e);
|
||||||
|
finish();
|
||||||
|
}))
|
||||||
.getAsJSONObject(new JSONLoader());
|
.getAsJSONObject(new JSONLoader());
|
||||||
} else {
|
} else {
|
||||||
new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)
|
new AlertDialog.Builder(this)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setTitle(R.string.app_name)
|
.setTitle(R.string.app_name)
|
||||||
.setMessage(R.string.no_internet_msg)
|
.setMessage(R.string.no_internet_msg)
|
||||||
@ -54,7 +61,7 @@ public class MainActivity extends Activity {
|
|||||||
try {
|
try {
|
||||||
JSONObject manager = json.getJSONObject("app");
|
JSONObject manager = json.getJSONObject("app");
|
||||||
apkLink = manager.getString("link");
|
apkLink = manager.getString("link");
|
||||||
new AlertDialog.Builder(MainActivity.this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)
|
new AlertDialog.Builder(MainActivity.this)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setTitle(R.string.app_name)
|
.setTitle(R.string.app_name)
|
||||||
.setMessage(R.string.upgrade_msg)
|
.setMessage(R.string.upgrade_msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user