Several small snet fixes

This commit is contained in:
topjohnwu 2017-10-07 20:47:44 +08:00
parent 48f9b27381
commit e986332bf2
3 changed files with 8 additions and 6 deletions

View File

@ -96,8 +96,6 @@ public class MagiskFragment extends Fragment
@OnClick(R.id.safetyNet_title) @OnClick(R.id.safetyNet_title)
void safetyNet() { void safetyNet() {
Runnable task = () -> { Runnable task = () -> {
mm.snet_version = CheckSafetyNet.SNET_VER;
mm.prefs.edit().putInt("snet_version", CheckSafetyNet.SNET_VER).apply();
safetyNetProgress.setVisibility(View.VISIBLE); safetyNetProgress.setVisibility(View.VISIBLE);
safetyNetRefreshIcon.setVisibility(View.GONE); safetyNetRefreshIcon.setVisibility(View.GONE);
safetyNetStatusText.setText(R.string.checking_safetyNet_status); safetyNetStatusText.setText(R.string.checking_safetyNet_status);

View File

@ -3,6 +3,7 @@ package com.topjohnwu.magisk.asyncs;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import com.topjohnwu.jarsigner.ByteArrayStream; import com.topjohnwu.jarsigner.ByteArrayStream;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.utils.WebService; import com.topjohnwu.magisk.utils.WebService;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
@ -32,9 +33,12 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
if (getMagiskManager().snet_version < CheckSafetyNet.SNET_VER) { MagiskManager mm = getMagiskManager();
if (mm.snet_version != CheckSafetyNet.SNET_VER) {
getShell().sh("rm -rf " + dexPath.getParent()); getShell().sh("rm -rf " + dexPath.getParent());
} }
mm.snet_version = CheckSafetyNet.SNET_VER;
mm.prefs.edit().putInt("snet_version", CheckSafetyNet.SNET_VER).apply();
} }
@Override @Override
@ -71,7 +75,7 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
getMagiskManager().safetyNetDone.publish(false, args[0]); getMagiskManager().safetyNetDone.publish(false, args[0]);
return null; return null;
})); }));
helperClazz.getMethod("requestTest").invoke(helper); helperClazz.getMethod("attest").invoke(helper);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
getMagiskManager().safetyNetDone.publish(false, -1); getMagiskManager().safetyNetDone.publish(false, -1);

View File

@ -43,7 +43,7 @@ public class SafetyNetHelper
} }
// Entry point to start test // Entry point to start test
public void requestTest() { public void attest() {
// Connect Google Service // Connect Google Service
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mActivity); GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mActivity);
try { try {
@ -92,7 +92,7 @@ public class SafetyNetHelper
responseCode |= decoded.getBoolean("ctsProfileMatch") ? CTS_PASS : 0; responseCode |= decoded.getBoolean("ctsProfileMatch") ? CTS_PASS : 0;
responseCode |= decoded.getBoolean("basicIntegrity") ? BASIC_PASS : 0; responseCode |= decoded.getBoolean("basicIntegrity") ? BASIC_PASS : 0;
} catch (JSONException e) { } catch (JSONException e) {
responseCode |= RESPONSE_ERR; cb.onResponse(RESPONSE_ERR);
return; return;
} }
// Disconnect // Disconnect