Remove snet version checkpoint, always check by code

This commit is contained in:
topjohnwu 2017-12-26 18:24:43 +08:00
parent de2285d5e9
commit 0e109ef979
8 changed files with 14 additions and 17 deletions

View File

@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 27 compileSdkVersion 27
buildToolsVersion "27.0.2" buildToolsVersion "27.0.3"
defaultConfig { defaultConfig {
applicationId "com.topjohnwu.magisk" applicationId "com.topjohnwu.magisk"

View File

@ -91,7 +91,7 @@ public class MagiskFragment extends Fragment
new CheckSafetyNet(getActivity()).exec(); new CheckSafetyNet(getActivity()).exec();
collapse(); collapse();
}; };
if (mm.snetVersion < 0) { if (!CheckSafetyNet.dexPath.exists()) {
// Show dialog // Show dialog
new AlertDialogBuilder(getActivity()) new AlertDialogBuilder(getActivity())
.setTitle(R.string.proprietary_title) .setTitle(R.string.proprietary_title)

View File

@ -49,7 +49,6 @@ public class MagiskManager extends Application {
public int remoteManagerVersionCode = -1; public int remoteManagerVersionCode = -1;
public String managerLink; public String managerLink;
public String bootBlock = null; public String bootBlock = null;
public int snetVersion;
public boolean keepVerity = false; public boolean keepVerity = false;
public boolean keepEnc = false; public boolean keepEnc = false;
@ -145,7 +144,6 @@ public class MagiskManager extends Application {
updateNotification = prefs.getBoolean(Const.Key.UPDATE_NOTIFICATION, true); updateNotification = prefs.getBoolean(Const.Key.UPDATE_NOTIFICATION, true);
updateChannel = Utils.getPrefsInt(prefs, Const.Key.UPDATE_CHANNEL, Const.Value.STABLE_CHANNEL); updateChannel = Utils.getPrefsInt(prefs, Const.Key.UPDATE_CHANNEL, Const.Value.STABLE_CHANNEL);
bootFormat = prefs.getString(Const.Key.BOOT_FORMAT, ".img"); bootFormat = prefs.getString(Const.Key.BOOT_FORMAT, ".img");
snetVersion = prefs.getInt(Const.Key.SNET_VER, -1);
customChannelUrl = prefs.getString(Const.Key.CUSTOM_CHANNEL, ""); customChannelUrl = prefs.getString(Const.Key.CUSTOM_CHANNEL, "");
} }

View File

@ -61,7 +61,7 @@ public class SplashActivity extends Activity {
if (Shell.rootAccess() && mm.magiskVersionCode > 0) { if (Shell.rootAccess() && mm.magiskVersionCode > 0) {
// Add update checking service // Add update checking service
if (Const.Value.UPDATE_SERVICE_VER > mm.prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1)) { if (Const.UPDATE_SERVICE_VER > mm.prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1)) {
ComponentName service = new ComponentName(this, UpdateCheckService.class); ComponentName service = new ComponentName(this, UpdateCheckService.class);
JobInfo info = new JobInfo.Builder(Const.ID.UPDATE_SERVICE_ID, service) JobInfo info = new JobInfo.Builder(Const.ID.UPDATE_SERVICE_ID, service)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
@ -95,7 +95,7 @@ public class SplashActivity extends Activity {
.putString(Const.Key.UPDATE_CHANNEL, String.valueOf(mm.updateChannel)) .putString(Const.Key.UPDATE_CHANNEL, String.valueOf(mm.updateChannel))
.putString(Const.Key.LOCALE, mm.localeConfig) .putString(Const.Key.LOCALE, mm.localeConfig)
.putString(Const.Key.BOOT_FORMAT, mm.bootFormat) .putString(Const.Key.BOOT_FORMAT, mm.bootFormat)
.putInt(Const.Key.UPDATE_SERVICE_VER, Const.Value.UPDATE_SERVICE_VER) .putInt(Const.Key.UPDATE_SERVICE_VER, Const.UPDATE_SERVICE_VER)
.apply(); .apply();
mm.hasInit = true; mm.hasInit = true;

View File

@ -22,13 +22,13 @@ import dalvik.system.DexClassLoader;
public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> { public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
private File dexPath; public static final File dexPath =
new File(MagiskManager.get().getFilesDir().getParent() + "/snet", "snet.apk");
private DexClassLoader loader; private DexClassLoader loader;
private Class<?> helperClazz, callbackClazz; private Class<?> helperClazz, callbackClazz;
public CheckSafetyNet(Activity activity) { public CheckSafetyNet(Activity activity) {
super(activity); super(activity);
dexPath = new File(activity.getCacheDir().getParent() + "/snet", "snet.apk");
} }
private void dlSnet() throws IOException { private void dlSnet() throws IOException {
@ -65,7 +65,7 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
e.printStackTrace(); e.printStackTrace();
} }
if (snet_ver != Const.Value.SNET_VER) { if (snet_ver != Const.SNET_VER) {
dlSnet(); dlSnet();
loadClasses(); loadClasses();
} }
@ -79,8 +79,6 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
@Override @Override
protected void onPostExecute(Exception err) { protected void onPostExecute(Exception err) {
MagiskManager mm = MagiskManager.get(); MagiskManager mm = MagiskManager.get();
mm.snetVersion = Const.Value.SNET_VER;
mm.prefs.edit().putInt(Const.Key.SNET_VER, Const.Value.SNET_VER).apply();
try { try {
if (err != null) throw err; if (err != null) throw err;
Object helper = helperClazz.getConstructors()[0].newInstance( Object helper = helperClazz.getConstructors()[0].newInstance(

View File

@ -40,7 +40,7 @@ public class Repo extends BaseModule {
if (getVersionCode() < 0) { if (getVersionCode() < 0) {
throw new IllegalRepoException("Repo [" + repoName + "] does not contain versionCode"); throw new IllegalRepoException("Repo [" + repoName + "] does not contain versionCode");
} }
if (getMinMagiskVersion() < Const.Value.MIN_MODULE_VER) { if (getMinMagiskVersion() < Const.MIN_MODULE_VER) {
throw new IllegalRepoException("Repo [" + repoName + "] is outdated"); throw new IllegalRepoException("Repo [" + repoName + "] is outdated");
} }
} }

View File

@ -28,7 +28,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
// Clear bad repos // Clear bad repos
mDb.delete(TABLE_NAME, "minMagisk<?", mDb.delete(TABLE_NAME, "minMagisk<?",
new String[] { String.valueOf(Const.Value.MIN_MODULE_VER) }); new String[] { String.valueOf(Const.MIN_MODULE_VER) });
} }
@Override @Override

View File

@ -30,6 +30,11 @@ public class Const {
public static final File EXTERNAL_PATH = new File(Environment.getExternalStorageDirectory(), "MagiskManager"); public static final File EXTERNAL_PATH = new File(Environment.getExternalStorageDirectory(), "MagiskManager");
public static final String MANAGER_CONFIGS = ".tmp.magisk.config"; public static final String MANAGER_CONFIGS = ".tmp.magisk.config";
// Versions
public static final int UPDATE_SERVICE_VER = 1;
public static final int SNET_VER = 7;
public static final int MIN_MODULE_VER = 1400;
public static String BUSYBOX_PATH() { public static String BUSYBOX_PATH() {
if (Utils.itemExist("/sbin/.core/busybox/busybox")) { if (Utils.itemExist("/sbin/.core/busybox/busybox")) {
return "/sbin/.core/busybox"; return "/sbin/.core/busybox";
@ -118,7 +123,6 @@ public class Const {
public static final String UPDATE_CHANNEL = "update_channel"; public static final String UPDATE_CHANNEL = "update_channel";
public static final String CUSTOM_CHANNEL = "custom_channel"; public static final String CUSTOM_CHANNEL = "custom_channel";
public static final String BOOT_FORMAT = "boot_format"; public static final String BOOT_FORMAT = "boot_format";
public static final String SNET_VER = "snet_version";
public static final String UPDATE_SERVICE_VER = "update_service_version"; public static final String UPDATE_SERVICE_VER = "update_service_version";
public static final String APP_VER = "app_version"; public static final String APP_VER = "app_version";
public static final String MAGISKHIDE = "magiskhide"; public static final String MAGISKHIDE = "magiskhide";
@ -158,8 +162,5 @@ public class Const {
public static final String PATCH_BOOT = "patch"; public static final String PATCH_BOOT = "patch";
public static final String FLASH_MAGISK = "magisk"; public static final String FLASH_MAGISK = "magisk";
public static final int[] timeoutList = {0, -1, 10, 20, 30, 60}; public static final int[] timeoutList = {0, -1, 10, 20, 30, 60};
public static final int UPDATE_SERVICE_VER = 1;
public static final int SNET_VER = 7;
public static final int MIN_MODULE_VER = 1400;
} }
} }