mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 22:27:54 +00:00
Various fixes
This commit is contained in:
parent
d788bd8323
commit
f2611f64ac
@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 24
|
compileSdkVersion 24
|
||||||
buildToolsVersion "24.0.3"
|
buildToolsVersion "24.0.2"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.topjohnwu.magisk"
|
applicationId "com.topjohnwu.magisk"
|
||||||
|
@ -9,10 +9,10 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.graphics.drawable.animated.BuildConfig;
|
|
||||||
import android.support.v4.content.FileProvider;
|
import android.support.v4.content.FileProvider;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
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;
|
||||||
@ -23,9 +23,11 @@ import android.widget.TextView;
|
|||||||
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
|
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.util.List;
|
||||||
|
|
||||||
import butterknife.BindColor;
|
import butterknife.BindColor;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -107,7 +109,7 @@ public class MagiskFragment extends Fragment {
|
|||||||
appCheckUpdatesProgress.setVisibility(View.VISIBLE);
|
appCheckUpdatesProgress.setVisibility(View.VISIBLE);
|
||||||
magiskCheckUpdatesProgress.setVisibility(View.VISIBLE);
|
magiskCheckUpdatesProgress.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
new Async.CheckUpdates(getActivity()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new Async.CheckUpdates(prefs).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (prefs.getBoolean("update_check_done", false)) {
|
if (prefs.getBoolean("update_check_done", false)) {
|
||||||
@ -147,6 +149,13 @@ public class MagiskFragment extends Fragment {
|
|||||||
builder = new AlertDialog.Builder(getActivity());
|
builder = new AlertDialog.Builder(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> ret = Shell.sh("getprop magisk.version");
|
||||||
|
if (ret.get(0).isEmpty()) {
|
||||||
|
magiskVersion = -1;
|
||||||
|
} else {
|
||||||
|
magiskVersion = Integer.parseInt(ret.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
if (remoteMagiskVersion == -1) {
|
if (remoteMagiskVersion == -1) {
|
||||||
appCheckUpdatesContainer.setBackgroundColor(colorWarn);
|
appCheckUpdatesContainer.setBackgroundColor(colorWarn);
|
||||||
magiskCheckUpdatesContainer.setBackgroundColor(colorWarn);
|
magiskCheckUpdatesContainer.setBackgroundColor(colorWarn);
|
||||||
@ -204,13 +213,7 @@ public class MagiskFragment extends Fragment {
|
|||||||
.show());
|
.show());
|
||||||
}
|
}
|
||||||
|
|
||||||
int appVersionCode = 0;
|
if (remoteAppVersionCode > BuildConfig.VERSION_CODE) {
|
||||||
try {
|
|
||||||
appVersionCode = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode;
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (remoteAppVersionCode > appVersionCode) {
|
|
||||||
appCheckUpdatesContainer.setBackgroundColor(colorInfo);
|
appCheckUpdatesContainer.setBackgroundColor(colorInfo);
|
||||||
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
appCheckUpdatesIcon.setImageResource(R.drawable.ic_file_download);
|
||||||
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, remoteAppVersion));
|
appCheckUpdatesStatus.setText(getString(R.string.app_update_available, remoteAppVersion));
|
||||||
@ -258,7 +261,13 @@ public class MagiskFragment extends Fragment {
|
|||||||
new DownloadReceiver() {
|
new DownloadReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void task(Uri uri) {
|
public void task(Uri uri) {
|
||||||
new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.FlashZIP(mContext, uri) {
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
Shell.su("setprop magisk.version " + String.valueOf(remoteMagiskVersion));
|
||||||
|
super.done();
|
||||||
|
}
|
||||||
|
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
magiskLink,
|
magiskLink,
|
||||||
|
@ -59,7 +59,7 @@ public class ModulesFragment extends Fragment {
|
|||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
||||||
recyclerView.setVisibility(View.GONE);
|
recyclerView.setVisibility(View.GONE);
|
||||||
prefs.edit().putBoolean("module_done", false).apply();
|
prefs.edit().putBoolean("module_done", false).apply();
|
||||||
new Async.LoadModules(getActivity()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.LoadModules(prefs).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (prefs.getBoolean("module_done", false)) {
|
if (prefs.getBoolean("module_done", false)) {
|
||||||
|
@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
|
|||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -12,7 +12,6 @@ import android.support.v7.app.ActionBar;
|
|||||||
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.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -12,38 +13,41 @@ import com.topjohnwu.magisk.utils.Logger;
|
|||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
|
||||||
if (defaultPrefs.getString("theme","").equals("Dark")) {
|
if (prefs.getString("theme","").equals("Dark")) {
|
||||||
setTheme(R.style.AppTheme_dh);
|
setTheme(R.style.AppTheme_dh);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.devLog = defaultPrefs.getBoolean("developer_logging", false);
|
Logger.devLog = prefs.getBoolean("developer_logging", false);
|
||||||
Logger.logShell = defaultPrefs.getBoolean("shell_logging", false);
|
Logger.logShell = prefs.getBoolean("shell_logging", false);
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
Utils.init(this);
|
prefs.edit()
|
||||||
|
|
||||||
defaultPrefs.edit()
|
|
||||||
.putBoolean("module_done", false)
|
.putBoolean("module_done", false)
|
||||||
.putBoolean("repo_done", false)
|
.putBoolean("repo_done", false)
|
||||||
.putBoolean("update_check_done", false)
|
.putBoolean("update_check_done", false)
|
||||||
.putBoolean("root", Utils.rootEnabled())
|
.putBoolean("root", Utils.rootEnabled())
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
new Async.CheckUpdates(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new Async.CheckUpdates(prefs).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
new Async.constructEnv(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new Async.constructEnv(getApplicationInfo()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
|
||||||
new Async.LoadModules(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new Async.LoadModules(prefs) {
|
||||||
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
@Override
|
||||||
|
protected void onPostExecute(Void v) {
|
||||||
|
super.onPostExecute(v);
|
||||||
|
new Async.LoadRepos(getApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
// Start main activity
|
||||||
|
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
|
||||||
// Start main activity
|
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.topjohnwu.magisk.utils;
|
|||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -34,20 +35,20 @@ public class Async {
|
|||||||
|
|
||||||
public static class constructEnv extends AsyncTask<Void, Void, Void> {
|
public static class constructEnv extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
Context mContext;
|
ApplicationInfo mInfo;
|
||||||
|
|
||||||
public constructEnv(Context context) {
|
public constructEnv(ApplicationInfo info) {
|
||||||
mContext = context;
|
mInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
String toolPath = mContext.getApplicationInfo().dataDir + "/tools";
|
String toolPath = mInfo.dataDir + "/tools";
|
||||||
String busybox = mContext.getApplicationInfo().dataDir + "/lib/libbusybox.so";
|
String busybox = mInfo.dataDir + "/lib/libbusybox.so";
|
||||||
String zip = mContext.getApplicationInfo().dataDir + "/lib/libzip.so";
|
String zip = mInfo.dataDir + "/lib/libzip.so";
|
||||||
if (Shell.rootAccess()) {
|
if (Shell.rootAccess()) {
|
||||||
if (!Utils.itemExist(false, toolPath)) {
|
if (!Utils.itemExist(false, toolPath)) {
|
||||||
Shell.sh(
|
Shell.su(
|
||||||
"rm -rf " + toolPath,
|
"rm -rf " + toolPath,
|
||||||
"mkdir " + toolPath,
|
"mkdir " + toolPath,
|
||||||
"chmod 755 " + toolPath,
|
"chmod 755 " + toolPath,
|
||||||
@ -60,6 +61,7 @@ public class Async {
|
|||||||
"ln -s " + zip + " zip"
|
"ln -s " + zip + " zip"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Shell.su("PATH=" + toolPath + ":$PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -68,10 +70,10 @@ public class Async {
|
|||||||
|
|
||||||
public static class CheckUpdates extends AsyncTask<Void, Void, Void> {
|
public static class CheckUpdates extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
private Context mContext;
|
private SharedPreferences mPrefs;
|
||||||
|
|
||||||
public CheckUpdates(Context context) {
|
public CheckUpdates(SharedPreferences prefs) {
|
||||||
mContext = context;
|
mPrefs = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,17 +102,16 @@ public class Async {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
mPrefs.edit().putBoolean("update_check_done", true).apply();
|
||||||
prefs.edit().putBoolean("update_check_done", true).apply();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LoadModules extends AsyncTask<Void, Void, Void> {
|
public static class LoadModules extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
private Context mContext;
|
private SharedPreferences mPrefs;
|
||||||
|
|
||||||
public LoadModules(Context context) {
|
public LoadModules(SharedPreferences prefs) {
|
||||||
mContext = context;
|
mPrefs = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -121,8 +122,7 @@ public class Async {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
mPrefs.edit().putBoolean("module_done", true).apply();
|
||||||
prefs.edit().putBoolean("module_done", true).apply();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +142,8 @@ public class Async {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
PreferenceManager.getDefaultSharedPreferences(mContext).edit()
|
||||||
prefs.edit().putBoolean("repo_done", true).apply();
|
.putBoolean("repo_done", true).apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,8 +308,8 @@ public class Async {
|
|||||||
|
|
||||||
protected void done() {
|
protected void done() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||||
prefs.edit().putBoolean("module_done", false).apply();
|
prefs.edit().putBoolean("module_done", false).putBoolean("update_check_done", true).apply();
|
||||||
new LoadModules(mContext).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new LoadModules(prefs).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
|
||||||
AlertDialog.Builder builder;
|
AlertDialog.Builder builder;
|
||||||
String theme = PreferenceManager.getDefaultSharedPreferences(mContext).getString("theme", "");
|
String theme = PreferenceManager.getDefaultSharedPreferences(mContext).getString("theme", "");
|
||||||
|
@ -39,17 +39,6 @@ public class Utils {
|
|||||||
private static final String cryptoPass = "MagiskRox666";
|
private static final String cryptoPass = "MagiskRox666";
|
||||||
private static final String secret = "GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus";
|
private static final String secret = "GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus";
|
||||||
|
|
||||||
public static void init(Context context) {
|
|
||||||
List<String> ret = Shell.sh("getprop magisk.version");
|
|
||||||
if (ret.get(0).isEmpty()) {
|
|
||||||
MagiskFragment.magiskVersion = -1;
|
|
||||||
} else {
|
|
||||||
MagiskFragment.magiskVersion = Integer.parseInt(ret.get(0));
|
|
||||||
}
|
|
||||||
String toolPath = context.getApplicationInfo().dataDir + "/tools";
|
|
||||||
Shell.su("PATH=" + toolPath + ":$PATH");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean itemExist(String path) {
|
public static boolean itemExist(String path) {
|
||||||
return itemExist(true, path);
|
return itemExist(true, path);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user