Refactoring
This commit is contained in:
parent
7737c6aee1
commit
615bbcae74
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,5 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/.idea/
|
||||
/build
|
||||
/captures
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
@ -11,10 +12,9 @@
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<profile default="true" name="Default" enabled="true">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
|
@ -1,3 +0,0 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
@ -5,7 +5,7 @@
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="LOCAL" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
|
||||
<option name="gradleHome" value="C:\Program Files\Android-Studio\gradle\gradle-2.14.1" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
@ -27,6 +27,47 @@
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectInspectionProfilesVisibleTreeState">
|
||||
<entry key="Project Default">
|
||||
<profile-state>
|
||||
<expanded-state>
|
||||
<State>
|
||||
<id>Android Lint</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>Groovy</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>HTML</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>J2ME issues</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>JUnit issues</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>Java language level issues</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>JavaBeans issues</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>Pattern Validation</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>Threading issues</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>Threading issuesGroovy</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>XML</id>
|
||||
</State>
|
||||
</expanded-state>
|
||||
</profile-state>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
@ -37,10 +78,26 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
@ -10,6 +10,10 @@ android {
|
||||
targetSdkVersion 24
|
||||
versionCode 3
|
||||
versionName "v4"
|
||||
|
||||
jackOptions {
|
||||
enabled true
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@ -21,5 +25,4 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
@ -5,10 +5,9 @@ import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
@ -21,6 +20,41 @@ public class MainActivity extends Activity {
|
||||
private TextView magiskVersion, rootStatus, selinuxStatus, safetyNet, permissive;
|
||||
private String suPath;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
magiskVersion = (TextView) findViewById(R.id.magisk_version);
|
||||
rootToggle = (Switch) findViewById(R.id.root_toggle);
|
||||
selinuxToggle = (Switch) findViewById(R.id.selinux_toggle);
|
||||
rootStatus = (TextView) findViewById(R.id.root_status);
|
||||
selinuxStatus = (TextView) findViewById(R.id.selinux_status);
|
||||
safetyNet = (TextView) findViewById(R.id.safety_net);
|
||||
permissive = (TextView) findViewById(R.id.permissive);
|
||||
|
||||
suPath = execute("getprop magisk.supath");
|
||||
updateStatus();
|
||||
|
||||
rootToggle.setOnClickListener(view -> {
|
||||
Switch s = (Switch) view;
|
||||
if (s.isChecked()) {
|
||||
(new SU()).execute("setprop magisk.root 1");
|
||||
} else {
|
||||
(new SU()).execute("setprop magisk.root 0");
|
||||
}
|
||||
});
|
||||
|
||||
selinuxToggle.setOnClickListener(view -> {
|
||||
Switch s = (Switch) view;
|
||||
if (s.isChecked()) {
|
||||
new SU().execute("setenforce 1");
|
||||
} else {
|
||||
new SU().execute("setenforce 0");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String execute(String command) {
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
@ -32,8 +66,8 @@ public class MainActivity extends Activity {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine())!= null) {
|
||||
if(output.length() != 0) output.append("\n");
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (output.length() != 0) output.append("\n");
|
||||
output.append(line);
|
||||
}
|
||||
|
||||
@ -50,7 +84,7 @@ public class MainActivity extends Activity {
|
||||
magiskVersion.setText(getString(R.string.magisk_version, execute("getprop magisk.version")));
|
||||
selinuxStatus.setText(selinux);
|
||||
|
||||
if(selinux.equals("Enforcing")) {
|
||||
if (selinux.equals("Enforcing")) {
|
||||
selinuxStatus.setTextColor(Color.GREEN);
|
||||
selinuxToggle.setChecked(true);
|
||||
permissive.setText(R.string.selinux_enforcing_info);
|
||||
@ -62,17 +96,17 @@ public class MainActivity extends Activity {
|
||||
permissive.setTextColor(Color.RED);
|
||||
}
|
||||
|
||||
if((new File("/system/framework/twframework.jar")).exists()) {
|
||||
if (new File("/system/framework/twframework.jar").exists()) {
|
||||
selinuxToggle.setEnabled(false);
|
||||
permissive.setText(R.string.selinux_samsung);
|
||||
}
|
||||
|
||||
if((new File("/system/xbin/su").exists())) {
|
||||
if (new File("/system/xbin/su").exists()) {
|
||||
rootStatus.setTextColor(Color.RED);
|
||||
safetyNet.setTextColor(Color.RED);
|
||||
rootToggle.setChecked(true);
|
||||
|
||||
if(!(new File(suPath + "/su")).exists()) {
|
||||
if (!(new File(suPath + "/su")).exists()) {
|
||||
rootStatus.setText(R.string.root_system);
|
||||
safetyNet.setText(R.string.root_system_info);
|
||||
rootToggle.setEnabled(false);
|
||||
@ -86,7 +120,7 @@ public class MainActivity extends Activity {
|
||||
safetyNet.setTextColor(Color.GREEN);
|
||||
rootToggle.setChecked(false);
|
||||
|
||||
if(!(new File(suPath + "/su")).exists()) {
|
||||
if (!new File(suPath + "/su").exists()) {
|
||||
rootStatus.setText(R.string.root_none);
|
||||
safetyNet.setText(R.string.root_none_info);
|
||||
rootToggle.setEnabled(false);
|
||||
@ -105,77 +139,22 @@ public class MainActivity extends Activity {
|
||||
try {
|
||||
Process su = Runtime.getRuntime().exec(suPath + "/su");
|
||||
DataOutputStream out = new DataOutputStream(su.getOutputStream());
|
||||
for(String command : params) {
|
||||
for (String command : params) {
|
||||
out.writeBytes(command + "\n");
|
||||
out.flush();
|
||||
}
|
||||
out.writeBytes("exit\n");
|
||||
out.flush();
|
||||
} catch (IOException e) { e.printStackTrace(); }
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
final Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateStatus();
|
||||
}
|
||||
}, 1500);
|
||||
handler.postDelayed(MainActivity.this::updateStatus, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
magiskVersion = (TextView) findViewById(R.id.magisk_version);
|
||||
rootToggle = (Switch) findViewById(R.id.root_toggle);
|
||||
selinuxToggle = (Switch) findViewById(R.id.selinux_toggle);
|
||||
rootStatus = (TextView) findViewById(R.id.root_status);
|
||||
selinuxStatus = (TextView) findViewById(R.id.selinux_status);
|
||||
safetyNet = (TextView) findViewById(R.id.safety_net);
|
||||
permissive = (TextView) findViewById(R.id.permissive);
|
||||
|
||||
suPath = execute("getprop magisk.supath");
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
magiskVersion = (TextView) findViewById(R.id.magisk_version);
|
||||
rootToggle = (Switch) findViewById(R.id.root_toggle);
|
||||
selinuxToggle = (Switch) findViewById(R.id.selinux_toggle);
|
||||
rootStatus = (TextView) findViewById(R.id.root_status);
|
||||
selinuxStatus = (TextView) findViewById(R.id.selinux_status);
|
||||
safetyNet = (TextView) findViewById(R.id.safety_net);
|
||||
permissive = (TextView) findViewById(R.id.permissive);
|
||||
|
||||
updateStatus();
|
||||
|
||||
rootToggle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Switch s = (Switch) view;
|
||||
if(s.isChecked()) {
|
||||
(new SU()).execute("setprop magisk.root 1");
|
||||
} else {
|
||||
(new SU()).execute("setprop magisk.root 0");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
selinuxToggle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Switch s = (Switch) view;
|
||||
if(s.isChecked()) {
|
||||
(new SU()).execute("setenforce 1");
|
||||
} else {
|
||||
(new SU()).execute("setenforce 0");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
classpath 'com.android.tools.build:gradle:2.1.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Mon Dec 28 10:00:20 PST 2015
|
||||
#Wed Aug 17 11:39:12 CEST 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
||||
|
Loading…
Reference in New Issue
Block a user