mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 21:45:27 +00:00
Change SafetyNet check to manual start
This commit is contained in:
parent
fb0923f3ab
commit
442fcf921c
@ -19,12 +19,9 @@ import com.topjohnwu.magisk.adapters.ApplicationAdapter;
|
|||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
|
@ -34,7 +34,6 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
// Start all async tasks
|
// Start all async tasks
|
||||||
new Async.GetBootBlocks().exec();
|
new Async.GetBootBlocks().exec();
|
||||||
new Async.CheckUpdates().exec();
|
new Async.CheckUpdates().exec();
|
||||||
Async.checkSafetyNet(getApplicationContext());
|
|
||||||
new Async.LoadModules() {
|
new Async.LoadModules() {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
|
@ -56,6 +56,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
@BindColor(R.color.grey500) int colorNeutral;
|
@BindColor(R.color.grey500) int colorNeutral;
|
||||||
@BindColor(R.color.blue500) int colorInfo;
|
@BindColor(R.color.blue500) int colorInfo;
|
||||||
@BindColor(android.R.color.transparent) int trans;
|
@BindColor(android.R.color.transparent) int trans;
|
||||||
|
int defaultColor;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
checkMagiskInfo();
|
checkMagiskInfo();
|
||||||
@ -67,30 +68,37 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
View v = inflater.inflate(R.layout.status_fragment, container, false);
|
View v = inflater.inflate(R.layout.status_fragment, container, false);
|
||||||
ButterKnife.bind(this, v);
|
ButterKnife.bind(this, v);
|
||||||
|
|
||||||
|
defaultColor = magiskUpdateText.getCurrentTextColor();
|
||||||
|
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
magiskStatusContainer.setBackgroundColor(trans);
|
magiskStatusContainer.setBackgroundColor(trans);
|
||||||
magiskStatusIcon.setImageResource(0);
|
magiskStatusIcon.setImageResource(0);
|
||||||
magiskUpdateText.setText(R.string.checking_for_updates);
|
magiskUpdateText.setText(R.string.checking_for_updates);
|
||||||
magiskCheckUpdatesProgress.setVisibility(View.VISIBLE);
|
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);
|
safetyNetProgress.setVisibility(View.VISIBLE);
|
||||||
safetyNetContainer.setBackgroundColor(trans);
|
safetyNetContainer.setBackgroundColor(trans);
|
||||||
safetyNetIcon.setImageResource(0);
|
safetyNetIcon.setImageResource(0);
|
||||||
safetyNetStatusText.setText(R.string.checking_safetyNet_status);
|
safetyNetStatusText.setText(R.string.checking_safetyNet_status);
|
||||||
|
|
||||||
updateUI();
|
|
||||||
new Async.CheckUpdates().exec();
|
|
||||||
Async.checkSafetyNet(getActivity());
|
Async.checkSafetyNet(getActivity());
|
||||||
});
|
});
|
||||||
|
|
||||||
updateUI();
|
|
||||||
if (updateCheckDone.isTriggered) {
|
|
||||||
updateCheckUI();
|
|
||||||
}
|
|
||||||
if (safetyNetDone.isTriggered) {
|
|
||||||
updateSafetyNetUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (magiskVersion < 0 && Shell.rootAccess()) {
|
if (magiskVersion < 0 && Shell.rootAccess()) {
|
||||||
MainActivity.alertBuilder
|
MainActivity.alertBuilder
|
||||||
.setTitle(R.string.no_magisk_title)
|
.setTitle(R.string.no_magisk_title)
|
||||||
@ -127,12 +135,18 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
CallbackHandler.register(updateCheckDone, this);
|
CallbackHandler.register(updateCheckDone, this);
|
||||||
CallbackHandler.register(safetyNetDone, this);
|
CallbackHandler.register(safetyNetDone, this);
|
||||||
|
if (updateCheckDone.isTriggered) {
|
||||||
|
updateCheckUI();
|
||||||
|
}
|
||||||
|
if (safetyNetDone.isTriggered) {
|
||||||
|
updateSafetyNetUI();
|
||||||
|
}
|
||||||
getActivity().setTitle(R.string.status);
|
getActivity().setTitle(R.string.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onPause() {
|
||||||
super.onDestroy();
|
super.onPause();
|
||||||
CallbackHandler.unRegister(updateCheckDone, this);
|
CallbackHandler.unRegister(updateCheckDone, this);
|
||||||
CallbackHandler.unRegister(safetyNetDone, this);
|
CallbackHandler.unRegister(safetyNetDone, this);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import android.widget.TextView;
|
|||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
|
9
app/src/main/res/drawable/ic_safetynet.xml
Normal file
9
app/src/main/res/drawable/ic_safetynet.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#fff"
|
||||||
|
android:pathData="M10,16h4c0.55,0 1,-0.45 1,-1v-3c0,-0.55 -0.45,-1 -1,-1v-1c0,-1.11 -0.9,-2 -2,-2 -1.11,0 -2,0.9 -2,2v1c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1zM10.8,10c0,-0.66 0.54,-1.2 1.2,-1.2 0.66,0 1.2,0.54 1.2,1.2v1h-2.4v-1zM17,1L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2L19,3c0,-1.1 -0.9,-2 -2,-2zM17,19L7,19L7,5h10v14z"/>
|
||||||
|
</vector>
|
@ -157,19 +157,22 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:foregroundGravity="center"
|
android:foregroundGravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:background="@color/grey500">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/safetyNet_icon"
|
android:id="@+id/safetyNet_icon"
|
||||||
android:layout_width="84dp"
|
android:layout_width="84dp"
|
||||||
android:layout_height="84dp"
|
android:layout_height="84dp"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_safetynet"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/safetyNet_check_progress"
|
android:id="@+id/safetyNet_check_progress"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
@ -181,7 +184,7 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="6dp"
|
android:padding="6dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="@string/checking_safetyNet_status" />
|
android:text="@string/safetyNet_check_text" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<string name="root_error">Rooted but no root permission, not allowed?</string>
|
<string name="root_error">Rooted but no root permission, not allowed?</string>
|
||||||
<string name="not_rooted">Not rooted</string>
|
<string name="not_rooted">Not rooted</string>
|
||||||
<string name="proper_root">Properly rooted</string>
|
<string name="proper_root">Properly rooted</string>
|
||||||
|
<string name="safetyNet_check_text">Tap to start SafetyNet check</string>
|
||||||
<string name="checking_safetyNet_status">Checking SafetyNet status…</string>
|
<string name="checking_safetyNet_status">Checking SafetyNet status…</string>
|
||||||
<string name="safetyNet_connection_failed">Cannot connect to Google API</string>
|
<string name="safetyNet_connection_failed">Cannot connect to Google API</string>
|
||||||
<string name="safetyNet_connection_suspended">Connection to Google API was suspended</string>
|
<string name="safetyNet_connection_suspended">Connection to Google API was suspended</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user