From bb2467d2ac7ca29cf9970ed82e4ce66ec858f5be Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Tue, 3 Jan 2017 18:01:57 +0800 Subject: [PATCH] Handle Google API Connection Problems --- .../main/java/com/topjohnwu/magisk/StatusFragment.java | 10 ++++++++++ .../com/topjohnwu/magisk/utils/SafetyNetHelper.java | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 14 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java index 8692aaf86..8b4269367 100644 --- a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java @@ -221,6 +221,16 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis int image, color; safetyNetProgress.setVisibility(View.GONE); switch (SNCheckResult) { + case -3: + color = colorNeutral; + image = R.drawable.ic_help; + safetyNetStatusText.setText(R.string.safetyNet_connection_suspended); + break; + case -2: + color = colorNeutral; + image = R.drawable.ic_help; + safetyNetStatusText.setText(R.string.safetyNet_connection_failed); + break; case -1: color = colorNeutral; image = R.drawable.ic_help; diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/SafetyNetHelper.java b/app/src/main/java/com/topjohnwu/magisk/utils/SafetyNetHelper.java index 33a087981..32895f494 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/SafetyNetHelper.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/SafetyNetHelper.java @@ -32,6 +32,7 @@ public abstract class SafetyNetHelper @Override public void onConnectionFailed(@NonNull ConnectionResult result) { Logger.dev("SN: Google API fail"); + handleResults(-2); } @Override @@ -43,6 +44,7 @@ public abstract class SafetyNetHelper @Override public void onConnectionSuspended(int i) { Logger.dev("SN: Google API Suspended"); + handleResults(-3); } public void requestTest() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 98901425d..99bad1219 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,6 +26,8 @@ Not rooted Properly rooted Checking SafetyNet status… + Cannot connect to Google API + Connection to Google API was suspended Cannot check SafetyNet, no Internet? SafetyNet Failed: CTS profile mismatch SafetyNet Passed