Support SDK 17 for stub APK

This commit is contained in:
topjohnwu
2018-12-27 14:35:55 +08:00
parent 523e66294b
commit 920b60da19
17 changed files with 455 additions and 31 deletions
@@ -20,7 +20,7 @@ import com.topjohnwu.magisk.fragments.ModulesFragment;
import com.topjohnwu.magisk.fragments.ReposFragment;
import com.topjohnwu.magisk.fragments.SettingsFragment;
import com.topjohnwu.magisk.fragments.SuperuserFragment;
import com.topjohnwu.magisk.utils.Download;
import com.topjohnwu.net.Networking;
import com.topjohnwu.superuser.Shell;
import androidx.annotation.NonNull;
@@ -124,7 +124,7 @@ public class MainActivity extends BaseActivity
menu.findItem(R.id.magiskhide).setVisible(Shell.rootAccess() &&
app.prefs.getBoolean(Const.Key.MAGISKHIDE, false));
menu.findItem(R.id.modules).setVisible(Shell.rootAccess() && Data.magiskVersionCode >= 0);
menu.findItem(R.id.downloads).setVisible(Download.checkNetworkStatus(this)
menu.findItem(R.id.downloads).setVisible(Networking.checkNetworkStatus(this)
&& Shell.rootAccess() && Data.magiskVersionCode >= 0);
menu.findItem(R.id.log).setVisible(Shell.rootAccess());
menu.findItem(R.id.superuser).setVisible(Utils.showSuperUser());
@@ -15,7 +15,7 @@ import com.topjohnwu.magisk.components.BaseActivity;
import com.topjohnwu.magisk.components.Notifications;
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
import com.topjohnwu.magisk.utils.AppUtils;
import com.topjohnwu.magisk.utils.Download;
import com.topjohnwu.net.Networking;
import com.topjohnwu.superuser.Shell;
public class SplashActivity extends BaseActivity {
@@ -56,7 +56,7 @@ public class SplashActivity extends BaseActivity {
// Setup shortcuts
sendBroadcast(new Intent(this, ClassMap.get(ShortcutReceiver.class)));
if (Download.checkNetworkStatus(this)) {
if (Networking.checkNetworkStatus(this)) {
// Fire update check
CheckUpdates.check();
// Repo update check
@@ -32,7 +32,7 @@ import com.topjohnwu.magisk.components.ExpandableView;
import com.topjohnwu.magisk.components.MagiskInstallDialog;
import com.topjohnwu.magisk.components.ManagerInstallDialog;
import com.topjohnwu.magisk.components.UninstallDialog;
import com.topjohnwu.magisk.utils.Download;
import com.topjohnwu.net.Networking;
import com.topjohnwu.superuser.Shell;
import com.topjohnwu.superuser.ShellUtils;
@@ -169,7 +169,7 @@ public class MagiskFragment extends BaseFragment
shownDialog = false;
// Trigger state check
if (Download.checkNetworkStatus(app)) {
if (Networking.checkNetworkStatus(app)) {
CheckUpdates.check();
} else {
mSwipeRefreshLayout.setRefreshing(false);
@@ -212,7 +212,7 @@ public class MagiskFragment extends BaseFragment
private void updateUI() {
((MainActivity) requireActivity()).checkHideSection();
boolean hasNetwork = Download.checkNetworkStatus(app);
boolean hasNetwork = Networking.checkNetworkStatus(app);
boolean hasRoot = Shell.rootAccess();
magiskUpdate.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
@@ -20,10 +20,10 @@ import com.topjohnwu.core.utils.Utils;
import com.topjohnwu.magisk.BuildConfig;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.AppUtils;
import com.topjohnwu.magisk.utils.Download;
import com.topjohnwu.magisk.utils.DownloadApp;
import com.topjohnwu.magisk.utils.FingerprintHelper;
import com.topjohnwu.magisk.utils.PatchAPK;
import com.topjohnwu.net.Networking;
import com.topjohnwu.superuser.Shell;
import java.io.IOException;
@@ -155,7 +155,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
if (app.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
generalCatagory.removePreference(restoreManager);
} else {
if (!Download.checkNetworkStatus(app))
if (!Networking.checkNetworkStatus(app))
generalCatagory.removePreference(restoreManager);
generalCatagory.removePreference(hideManager);
}
-2
View File
@@ -4,8 +4,6 @@
package="com.topjohnwu.magisk">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
@@ -1,15 +0,0 @@
package com.topjohnwu.magisk.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class Download {
public static boolean checkNetworkStatus(Context context) {
ConnectivityManager manager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = manager.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnected();
}
}
@@ -6,7 +6,6 @@ import android.app.Application;
import android.os.Bundle;
import com.topjohnwu.magisk.utils.APKInstall;
import com.topjohnwu.magisk.utils.Download;
import com.topjohnwu.net.Networking;
import com.topjohnwu.net.ResponseListener;
@@ -32,7 +31,8 @@ public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Download.checkNetworkStatus(this)) {
Networking.init(this);
if (Networking.checkNetworkStatus(this)) {
Networking.get(URL)
.setErrorHandler(((conn, e) -> finish()))
.getAsJSONObject(new JSONLoader());
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="ic_launcher">@android:drawable/sym_def_app_icon</drawable>
</resources>