Finalize 2.0 version

This commit is contained in:
topjohnwu 2016-08-25 18:08:07 +08:00
parent 3e97d29bcf
commit dc06a132bc
11 changed files with 232 additions and 248 deletions

View File

@ -3,7 +3,7 @@ apply plugin: 'android-apt'
android { android {
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion "24.0.1" buildToolsVersion "24.0.2"
defaultConfig { defaultConfig {
applicationId "com.topjohnwu.magisk" applicationId "com.topjohnwu.magisk"

View File

@ -25,6 +25,7 @@ import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import java.io.File; import java.io.File;
@ -201,13 +202,6 @@ public class LogFragment extends Fragment {
@Override @Override
protected String doInBackground(Void... voids) { protected String doInBackground(Void... voids) {
// Ensure initialize is done
try {
Utils.initialize.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
if (readLog) { if (readLog) {
List<String> logList = Utils.readFile(MAGISK_LOG); List<String> logList = Utils.readFile(MAGISK_LOG);
@ -225,8 +219,6 @@ public class LogFragment extends Fragment {
} }
return ""; return "";
} }
} }
@Override @Override

View File

@ -1,15 +1,15 @@
package com.topjohnwu.magisk; package com.topjohnwu.magisk;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Switch; import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
@ -17,7 +17,7 @@ import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import butterknife.BindColor; import butterknife.BindColor;
@ -26,10 +26,16 @@ import butterknife.ButterKnife;
public class MagiskFragment extends Fragment { public class MagiskFragment extends Fragment {
@BindView(R.id.rootSwitchView) View rootToggleView; @BindView(R.id.progressBar) ProgressBar progressBar;
@BindView(R.id.root_toggle) Switch rootToggle;
@BindView(R.id.rootSwitchView) View rootToggleView;
@BindView(R.id.selinuxSwitchView) View selinuxToggleView; @BindView(R.id.selinuxSwitchView) View selinuxToggleView;
@BindView(R.id.magiskStatusView) View magiskStatusView;
@BindView(R.id.rootStatusView) View rootStatusView;
@BindView(R.id.safetynetStatusView) View safetynetStatusView;
@BindView(R.id.selinuxStatusView) View selinuxStatusView;
@BindView(R.id.root_toggle) Switch rootToggle;
@BindView(R.id.selinux_toggle) Switch selinuxToggle; @BindView(R.id.selinux_toggle) Switch selinuxToggle;
@BindView(R.id.magisk_status_container) View magiskStatusContainer; @BindView(R.id.magisk_status_container) View magiskStatusContainer;
@ -50,6 +56,7 @@ public class MagiskFragment extends Fragment {
@BindColor(R.color.red500) int red500; @BindColor(R.color.red500) int red500;
@BindColor(R.color.green500) int green500; @BindColor(R.color.green500) int green500;
@BindColor(R.color.grey500) int grey500; @BindColor(R.color.grey500) int grey500;
@BindColor(R.color.lime500) int lime500;
int statusOK = R.drawable.ic_check_circle; int statusOK = R.drawable.ic_check_circle;
int statusError = R.drawable.ic_error; int statusError = R.drawable.ic_error;
@ -61,19 +68,13 @@ public class MagiskFragment extends Fragment {
View view = inflater.inflate(R.layout.magisk_fragment, container, false); View view = inflater.inflate(R.layout.magisk_fragment, container, false);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
try { new updateUI().execute();
Utils.initialize.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
updateStatus();
rootToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { rootToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) { public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
Shell.su(b ? "setprop magisk.root 1" : "setprop magisk.root 0"); Shell.su(b ? "setprop magisk.root 1" : "setprop magisk.root 0");
updateStatus(); new updateUI().execute();
} }
}); });
@ -81,115 +82,140 @@ public class MagiskFragment extends Fragment {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) { public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
Shell.su(b ? "setenforce 1" : "setenforce 0"); Shell.su(b ? "setenforce 1" : "setenforce 0");
updateStatus(); new updateUI().execute();
} }
}); });
new android.os.Handler().postDelayed(new Runnable() {
@Override
public void run() {
updateStatus(); // update status again
}
}, 1000);
return view; return view;
} }
private void updateStatus() { private class updateUI extends AsyncTask<Void, Void, Void> {
String selinux = Shell.sh("getenforce").get(0);
String version = Shell.sh("getprop magisk.version").get(0);
if (TextUtils.isEmpty(version)) { @Override
magiskStatusContainer.setBackgroundColor(grey500); protected Void doInBackground(Void... voids) {
magiskStatusIcon.setImageResource(statusUnknown); // Make sure static block invoked
Shell.rootAccess();
magiskVersion.setTextColor(grey500); return null;
magiskVersion.setText("?");
} else {
magiskStatusContainer.setBackgroundColor(green500);
magiskStatusIcon.setImageResource(statusOK);
magiskVersion.setTextColor(green500);
magiskVersion.setText(getString(R.string.magisk_version, version));
} }
if (selinux.equals("Enforcing")) { @Override
selinuxStatusContainer.setBackgroundColor(green500); protected void onPostExecute(Void v) {
selinuxStatusIcon.setImageResource(statusOK); super.onPostExecute(v);
selinuxStatus.setText(R.string.selinux_enforcing_info); progressBar.setVisibility(View.GONE);
selinuxStatus.setTextColor(green500);
selinuxToggle.setChecked(true);
} else {
selinuxStatusContainer.setBackgroundColor(red500);
selinuxStatusIcon.setImageResource(statusError);
selinuxStatus.setText(R.string.selinux_permissive_info); magiskStatusView.setVisibility(View.VISIBLE);
selinuxStatus.setTextColor(red500); rootStatusView.setVisibility(View.VISIBLE);
selinuxToggle.setChecked(false); safetynetStatusView.setVisibility(View.VISIBLE);
} selinuxStatusView.setVisibility(View.VISIBLE);
if (new File("/system/framework/twframework.jar").exists()) { if (Shell.rootAccess()) {
selinuxToggleView.setVisibility(View.GONE); rootToggleView.setVisibility(View.VISIBLE);
selinuxStatus.append("\n" + getString(R.string.selinux_samsung)); selinuxToggleView.setVisibility(View.VISIBLE);
}
if (new File("/system/xbin/su").exists()) {
rootStatusContainer.setBackgroundColor(red500);
rootStatusIcon.setImageResource(statusError);
rootStatus.setTextColor(red500);
rootToggle.setChecked(true);
safetyNetStatusIcon.setImageResource(statusError);
if (!Shell.rootAccess()) {
rootStatusContainer.setBackgroundColor(red500);
rootStatusIcon.setImageResource(statusUnknown);
rootStatus.setTextColor(red500);
rootStatus.setText(R.string.root_system);
rootToggleView.setVisibility(View.GONE);
selinuxToggleView.setVisibility(View.GONE);
safetyNetStatus.setText(R.string.root_system_info);
} else {
rootStatusContainer.setBackgroundColor(green500);
rootStatusIcon.setImageResource(statusError);
rootStatus.setTextColor(green500);
rootStatus.setText(R.string.root_mounted);
safetyNetStatus.setText(R.string.root_mounted_info);
} }
} else {
rootStatusContainer.setBackgroundColor(green500);
rootStatusIcon.setImageResource(statusOK);
rootStatus.setTextColor(green500); List<String> selinux = Shell.sh("getenforce");
rootToggle.setChecked(false); List<String> version = Shell.sh("getprop magisk.version");
safetyNetStatusIcon.setImageResource(statusOK); if (version.isEmpty()) {
magiskStatusContainer.setBackgroundColor(grey500);
magiskStatusIcon.setImageResource(statusUnknown);
if (!Shell.rootAccess()) { magiskVersion.setTextColor(grey500);
rootStatusContainer.setBackgroundColor(red500); magiskVersion.setText(R.string.magisk_version_error);
rootStatusIcon.setImageResource(statusError);
rootStatus.setTextColor(red500);
rootStatus.setText(R.string.root_none);
rootToggleView.setVisibility(View.GONE);
selinuxToggleView.setVisibility(View.GONE);
safetyNetStatusIcon.setImageResource(statusError);
safetyNetStatus.setText(R.string.root_none_info);
} else { } else {
rootStatus.setText(R.string.root_unmounted); magiskStatusContainer.setBackgroundColor(green500);
safetyNetStatus.setText(R.string.root_unmounted_info); magiskStatusIcon.setImageResource(statusOK);
magiskVersion.setTextColor(green500);
magiskVersion.setText(getString(R.string.magisk_version, version.get(0)));
}
if (selinux.isEmpty()) {
selinuxStatusContainer.setBackgroundColor(grey500);
selinuxStatusIcon.setImageResource(statusUnknown);
selinuxStatus.setText(R.string.selinux_error_info);
selinuxStatus.setTextColor(grey500);
selinuxToggle.setChecked(false);
} else if (selinux.get(0).equals("Enforcing")) {
selinuxStatusContainer.setBackgroundColor(green500);
selinuxStatusIcon.setImageResource(statusOK);
selinuxStatus.setText(R.string.selinux_enforcing_info);
selinuxStatus.setTextColor(green500);
selinuxToggle.setChecked(true);
} else {
selinuxStatusContainer.setBackgroundColor(red500);
selinuxStatusIcon.setImageResource(statusError);
selinuxStatus.setText(R.string.selinux_permissive_info);
selinuxStatus.setTextColor(red500);
selinuxToggle.setChecked(false);
}
if (new File("/system/framework/twframework.jar").exists()) {
selinuxToggleView.setVisibility(View.GONE);
selinuxStatus.append("\n" + getString(R.string.selinux_samsung_info));
}
switch (Shell.rootStatus) {
case -1:
// Root Error
rootStatusContainer.setBackgroundColor(grey500);
rootStatusIcon.setImageResource(statusUnknown);
rootStatus.setTextColor(grey500);
rootStatus.setText(R.string.root_error);
rootToggle.setChecked(false);
safetyNetStatusIcon.setImageResource(statusUnknown);
safetyNetStatus.setText(R.string.root_error_info);
break;
case 0:
// Not rooted
rootStatusContainer.setBackgroundColor(green500);
rootStatusIcon.setImageResource(statusOK);
rootStatus.setTextColor(green500);
rootStatus.setText(R.string.root_none);
rootToggle.setChecked(false);
safetyNetStatusIcon.setImageResource(statusOK);
safetyNetStatus.setText(R.string.root_none_info);
break;
case 1:
// Proper root
if (new File("/system/xbin/su").exists()) {
// Mounted
rootStatusContainer.setBackgroundColor(lime500);
rootStatusIcon.setImageResource(statusError);
rootStatus.setTextColor(lime500);
rootStatus.setText(R.string.root_mounted);
rootToggle.setChecked(true);
safetyNetStatusIcon.setImageResource(statusError);
safetyNetStatus.setText(R.string.root_mounted_info);
break;
} else {
// Not Mounted
rootStatusContainer.setBackgroundColor(green500);
rootStatusIcon.setImageResource(statusOK);
rootStatus.setTextColor(green500);
rootStatus.setText(R.string.root_unmounted);
rootToggle.setChecked(false);
safetyNetStatusIcon.setImageResource(statusOK);
safetyNetStatus.setText(R.string.root_unmounted_info);
break;
}
case 2:
// Improper root
rootStatusContainer.setBackgroundColor(red500);
rootStatusIcon.setImageResource(statusError);
rootStatus.setTextColor(red500);
rootStatus.setText(R.string.root_system);
rootToggle.setChecked(true);
safetyNetStatusIcon.setImageResource(statusError);
safetyNetStatus.setText(R.string.root_system_info);
rootToggleView.setVisibility(View.GONE);
break;
} }
} }
} }
public void onRootGranted() {
updateStatus();
}
} }

View File

@ -17,10 +17,9 @@ import android.view.ViewGroup;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import com.topjohnwu.magisk.module.Module; import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -33,28 +32,22 @@ public class ModulesFragment extends Fragment {
private static final String MAGISK_PATH = "/magisk"; private static final String MAGISK_PATH = "/magisk";
private static final String MAGISK_CACHE_PATH = "/cache/magisk"; private static final String MAGISK_CACHE_PATH = "/cache/magisk";
// protected static List<Module> listModules = new ArrayList<>(); private static List<Module> listModules = new ArrayList<>();
// protected static List<Module> listModulesCache = new ArrayList<>(); private static List<Module> listModulesCache = new ArrayList<>();
public static loadModules loadMod;
@BindView(R.id.progressBar) ProgressBar progressBar; @BindView(R.id.progressBar) ProgressBar progressBar;
@BindView(R.id.pager) ViewPager viewPager; @BindView(R.id.pager) ViewPager viewPager;
@BindView(R.id.tab_layout) TabLayout tabLayout; @BindView(R.id.tab_layout) TabLayout tabLayout;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// listModules.clear();
// listModulesCache.clear();
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.modules_fragment, container, false); View view = inflater.inflate(R.layout.modules_fragment, container, false);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
new CheckFolders().execute(); new updateUI().execute();
setHasOptionsMenu(true); setHasOptionsMenu(true);
return view; return view;
@ -70,10 +63,9 @@ public class ModulesFragment extends Fragment {
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.force_reload: case R.id.force_reload:
listModules.clear(); loadMod = new loadModules();
listModulesCache.clear(); loadMod.execute();
new updateUI().execute();
new CheckFolders().execute();
break; break;
} }
@ -84,7 +76,7 @@ public class ModulesFragment extends Fragment {
@Override @Override
protected List<Module> listModules() { protected List<Module> listModules() {
return Utils.listModules; return listModules;
} }
} }
@ -93,18 +85,46 @@ public class ModulesFragment extends Fragment {
@Override @Override
protected List<Module> listModules() { protected List<Module> listModules() {
return Utils.listModulesCache; return listModulesCache;
} }
} }
private class CheckFolders extends AsyncTask<Void, Integer, Void> { public static class loadModules extends AsyncTask<Void, Void, Void> {
@Override @Override
protected Void doInBackground(Void... voids) { protected Void doInBackground(Void... voids) {
// Ensure initialize is done
listModules.clear();
listModulesCache.clear();
listModules.clear();
listModulesCache.clear();
List<String> magisk = Utils.getModList(MAGISK_PATH);
List<String> magiskCache = Utils.getModList(MAGISK_CACHE_PATH);
if (!magisk.isEmpty()) {
for (String mod : magisk) {
listModules.add(new Module(mod));
}
}
if (!magiskCache.isEmpty()) {
for (String mod : magiskCache) {
listModulesCache.add(new Module(mod));
}
}
return null;
}
}
private class updateUI extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
// Ensure loadMod is done
try { try {
Utils.initialize.get(); loadMod.get();
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,15 +1,12 @@
package com.topjohnwu.magisk; package com.topjohnwu.magisk;
import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.IdRes; import android.support.annotation.IdRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
@ -17,15 +14,9 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils;
import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -53,9 +44,9 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} }
Utils.initialize = new Utils.Init(); // Load mods in the background
ModulesFragment.loadMod = new ModulesFragment.loadModules();
Utils.initialize.execute(); ModulesFragment.loadMod.execute();
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -158,41 +149,4 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
} }
} }
} }
public static class Init extends AsyncTask<Void, Integer, Void> {
private final AppCompatActivity activity;
private ProgressDialog progress;
public Init(AppCompatActivity activity) {
this.activity = activity;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progress = ProgressDialog.show(activity, null, activity.getString(R.string.loading), true, false);
}
@Override
protected Void doInBackground(Void... voids) {
return null;
}
@Override
protected void onPostExecute(Void v) {
super.onPostExecute(v);
progress.dismiss();
if (!Shell.rootAccess()) {
Snackbar.make(view, R.string.no_root_access, Snackbar.LENGTH_LONG).show();
return;
}
MagiskFragment fragment = (MagiskFragment) activity.getSupportFragmentManager().findFragmentByTag("magisk");
fragment.onRootGranted();
}
}
} }

View File

@ -1,5 +1,7 @@
package com.topjohnwu.magisk.utils; package com.topjohnwu.magisk.utils;
import android.os.AsyncTask;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -23,21 +25,18 @@ public class Shell {
private static List<String> rootOutList = new ArrayList<>(); private static List<String> rootOutList = new ArrayList<>();
static { static {
init();
}
private static void init() {
List<String> ret = sh("getprop magisk.supath"); List<String> ret = sh("getprop magisk.supath");
if(!ret.isEmpty()) { if(!ret.isEmpty()) {
suPath = ret.get(0) + "/su"; suPath = ret.get(0) + "/su";
rootStatus = 1;
} else { } else {
suPath = "su"; suPath = "su";
rootStatus = 2; rootStatus = 2;
} }
}
public static boolean rootAccess() {
return rootStatus > 0;
}
public static void startRoot() {
rootStatus = rootStatus == 0 ? 1 : 2;
try { try {
rootShell = Runtime.getRuntime().exec(suPath); rootShell = Runtime.getRuntime().exec(suPath);
@ -45,15 +44,14 @@ public class Shell {
rootSTDOUT = new StreamGobbler(rootShell.getInputStream(), rootOutList); rootSTDOUT = new StreamGobbler(rootShell.getInputStream(), rootOutList);
rootSTDOUT.start(); rootSTDOUT.start();
} catch (IOException e) { } catch (IOException e) {
// runtime error! No binary found! // runtime error! No binary found! Means no root
rootStatus = 0; rootStatus = 0;
return; return;
} }
ret = su("echo -BOC-", "id");
List<String> ret = su("echo -BOC-", "id");
if (ret == null) { if (ret == null) {
// Something wrong with root install, not enabled? // Something wrong with root, not allowed?
rootStatus = -1; rootStatus = -1;
return; return;
} }
@ -84,6 +82,10 @@ public class Shell {
} }
} }
public static boolean rootAccess() {
return rootStatus > 0;
}
public static List<String> sh(String... commands) { public static List<String> sh(String... commands) {
List<String> res = Collections.synchronizedList(new ArrayList<String>()); List<String> res = Collections.synchronizedList(new ArrayList<String>());

View File

@ -36,7 +36,8 @@ public class StreamGobbler extends Thread {
try { try {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
writer.add(line); if (!line.replaceAll("\\s", "").isEmpty())
writer.add(line);
} }
} catch (IOException e) { } catch (IOException e) {
// reader probably closed, expected exit condition // reader probably closed, expected exit condition

View File

@ -1,45 +1,9 @@
package com.topjohnwu.magisk.utils; package com.topjohnwu.magisk.utils;
import android.os.AsyncTask;
import com.topjohnwu.magisk.module.Module;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Utils { public class Utils {
public static Init initialize;
public static List<Module> listModules = new ArrayList<>();
public static List<Module> listModulesCache = new ArrayList<>();
public static List<String> listLog;
public static class Init extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
Shell.startRoot();
listModules.clear();
listModulesCache.clear();
List<String> magisk = getModList("/magisk");
List<String> magiskCache = getModList("/cache/magisk");
if (!magisk.isEmpty()) {
for (String mod : magisk) {
listModules.add(new Module(mod));
}
}
if (!magiskCache.isEmpty()) {
for (String mod : magiskCache) {
listModulesCache.add(new Module(mod));
}
}
listLog = readFile("/cache/magisk.log");
return null;
}
}
public static boolean fileExist(String path) { public static boolean fileExist(String path) {
List<String> ret; List<String> ret;
ret = Shell.sh("if [ -f " + path + " ]; then echo true; else echo false; fi"); ret = Shell.sh("if [ -f " + path + " ]; then echo true; else echo false; fi");

View File

@ -11,12 +11,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/rootSwitchView" android:id="@+id/rootSwitchView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:elevation="2dp" android:elevation="2dp"
app:cardCornerRadius="0dp"> app:cardCornerRadius="0dp"
android:visibility="gone">
<Switch <Switch
android:id="@+id/root_toggle" android:id="@+id/root_toggle"
@ -35,7 +42,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="1dp" android:layout_marginTop="1dp"
android:elevation="2dp" android:elevation="2dp"
app:cardCornerRadius="0dp"> app:cardCornerRadius="0dp"
android:visibility="gone">
<Switch <Switch
android:id="@+id/selinux_toggle" android:id="@+id/selinux_toggle"
@ -49,13 +57,15 @@
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/magiskStatusView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
app:cardUseCompatPadding="true"> app:cardUseCompatPadding="true"
android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -92,13 +102,15 @@
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/rootStatusView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
app:cardUseCompatPadding="true"> app:cardUseCompatPadding="true"
android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -134,13 +146,15 @@
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/safetynetStatusView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
app:cardUseCompatPadding="true"> app:cardUseCompatPadding="true"
android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -168,13 +182,15 @@
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/selinuxStatusView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
app:cardUseCompatPadding="true"> app:cardUseCompatPadding="true"
android:visibility="gone">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -10,5 +10,6 @@
<color name="red500">#F44336</color> <color name="red500">#F44336</color>
<color name="green500">#4CAF50</color> <color name="green500">#4CAF50</color>
<color name="grey500">#9E9E9E</color> <color name="grey500">#9E9E9E</color>
<color name="lime500">#CDDC39</color>
</resources> </resources>

View File

@ -1,19 +1,27 @@
<resources> <resources>
<string name="app_name">Magisk Manager</string> <string name="app_name">Magisk Manager</string>
<string name="magisk_version">Installed Magisk v%1$s</string>
<string name="magisk_version_error">Have you installed Magisk?</string>
<string name="root_error">Root Error</string>
<string name="root_error_info">Safety Net Status Unknown</string>
<string name="root_none">Not Rooted</string>
<string name="root_none_info">Safety Net (Android Pay) should work</string>
<string name="root_mounted">Root mounted</string> <string name="root_mounted">Root mounted</string>
<string name="root_mounted_info">Root mounted and enabled. Safety Net (Android Pay) will NOT work</string> <string name="root_mounted_info">Root mounted and enabled. Safety Net (Android Pay) will NOT work</string>
<string name="root_unmounted">Root not mounted</string> <string name="root_unmounted">Root not mounted</string>
<string name="root_unmounted_info">Safety Net (Android Pay) should work, but no root temporarily</string> <string name="root_unmounted_info">Safety Net (Android Pay) should work, but no root temporarily</string>
<string name="selinux_enforcing_info">SELinux is enforced</string>
<string name="selinux_permissive_info">SELinux is permissive\nOnly turn off SELinux if necessary!</string>
<string name="root_toggle">Root Toggle</string>
<string name="selinux_toggle">SeLinux Toggle</string>
<string name="root_system">Improperly Installed</string> <string name="root_system">Improperly Installed</string>
<string name="root_system_info">Root improperly installed. Safety Net (Android Pay) will NOT work, and impossible to toggle</string> <string name="root_system_info">Root improperly installed. Safety Net (Android Pay) will NOT work, and impossible to toggle</string>
<string name="root_none">Not Rooted</string>
<string name="root_none_info">Safety Net (Android Pay) should work</string> <string name="selinux_error_info">SELinux Status Unknown</string>
<string name="magisk_version">Installed Magisk v%1$s</string> <string name="selinux_enforcing_info">SELinux is enforced</string>
<string name="selinux_samsung">Samsung do not support switching SELinux status!</string> <string name="selinux_permissive_info">SELinux is permissive\nOnly turn off SELinux if necessary!</string>
<string name="selinux_samsung_info">Samsung do not support switching SELinux status!</string>
<string name="root_toggle">Root Toggle</string>
<string name="selinux_toggle">SELinux Toggle</string>
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>