Change SafetyNet check to manual start

This commit is contained in:
topjohnwu
2017-01-07 01:19:18 +08:00
parent fb0923f3ab
commit 442fcf921c
7 changed files with 44 additions and 22 deletions

View File

@ -19,12 +19,9 @@ import com.topjohnwu.magisk.adapters.ApplicationAdapter;
import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.CallbackHandler;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Shell;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import butterknife.BindView;

View File

@ -34,7 +34,6 @@ public class SplashActivity extends AppCompatActivity {
// Start all async tasks
new Async.GetBootBlocks().exec();
new Async.CheckUpdates().exec();
Async.checkSafetyNet(getApplicationContext());
new Async.LoadModules() {
@Override
protected void onPostExecute(Void v) {

View File

@ -56,6 +56,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@BindColor(R.color.grey500) int colorNeutral;
@BindColor(R.color.blue500) int colorInfo;
@BindColor(android.R.color.transparent) int trans;
int defaultColor;
static {
checkMagiskInfo();
@ -67,30 +68,37 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
View v = inflater.inflate(R.layout.status_fragment, container, false);
ButterKnife.bind(this, v);
defaultColor = magiskUpdateText.getCurrentTextColor();
mSwipeRefreshLayout.setOnRefreshListener(() -> {
magiskStatusContainer.setBackgroundColor(trans);
magiskStatusIcon.setImageResource(0);
magiskUpdateText.setText(R.string.checking_for_updates);
magiskCheckUpdatesProgress.setVisibility(View.VISIBLE);
magiskUpdateText.setTextColor(defaultColor);
safetyNetProgress.setVisibility(View.GONE);
safetyNetContainer.setBackgroundColor(colorNeutral);
safetyNetIcon.setImageResource(R.drawable.ic_safetynet);
safetyNetStatusText.setText(R.string.safetyNet_check_text);
safetyNetStatusText.setTextColor(defaultColor);
safetyNetDone.isTriggered = false;
updateUI();
new Async.CheckUpdates().exec();
});
updateUI();
safetyNetContainer.setOnClickListener(view -> {
safetyNetProgress.setVisibility(View.VISIBLE);
safetyNetContainer.setBackgroundColor(trans);
safetyNetIcon.setImageResource(0);
safetyNetStatusText.setText(R.string.checking_safetyNet_status);
updateUI();
new Async.CheckUpdates().exec();
Async.checkSafetyNet(getActivity());
});
updateUI();
if (updateCheckDone.isTriggered) {
updateCheckUI();
}
if (safetyNetDone.isTriggered) {
updateSafetyNetUI();
}
if (magiskVersion < 0 && Shell.rootAccess()) {
MainActivity.alertBuilder
.setTitle(R.string.no_magisk_title)
@ -127,12 +135,18 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
super.onResume();
CallbackHandler.register(updateCheckDone, this);
CallbackHandler.register(safetyNetDone, this);
if (updateCheckDone.isTriggered) {
updateCheckUI();
}
if (safetyNetDone.isTriggered) {
updateSafetyNetUI();
}
getActivity().setTitle(R.string.status);
}
@Override
public void onDestroy() {
super.onDestroy();
public void onPause() {
super.onPause();
CallbackHandler.unRegister(updateCheckDone, this);
CallbackHandler.unRegister(safetyNetDone, this);
}

View File

@ -16,7 +16,6 @@ import android.widget.TextView;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Async;
import java.util.Arrays;
import java.util.List;
import butterknife.BindView;