diff --git a/app/src/main/assets/dark.css b/app/src/main/assets/dark.css index 3ba94249f..e00c7e0c9 100644 --- a/app/src/main/assets/dark.css +++ b/app/src/main/assets/dark.css @@ -6,7 +6,7 @@ body { padding-bottom: 10px; background-color: #303030; color: white; - padding: 30px; } + padding: 15px; } body > *:first-child { margin-top: 0 !important; } diff --git a/app/src/main/assets/light.css b/app/src/main/assets/light.css index 063e96f15..6895bb1a9 100644 --- a/app/src/main/assets/light.css +++ b/app/src/main/assets/light.css @@ -5,7 +5,7 @@ body { padding-top: 10px; padding-bottom: 10px; background-color: white; - padding: 30px; } + padding: 15px; } body > *:first-child { margin-top: 0 !important; } diff --git a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java index a7d4017f7..0c988afaf 100644 --- a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import butterknife.BindView; import butterknife.ButterKnife; @@ -56,8 +57,11 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener< View v = inflater.inflate(R.layout.fragment_install, container, false); unbinder = ButterKnife.bind(this, v); detectButton.setOnClickListener(v1 -> toAutoDetect()); - currentVersionTitle.setText(getString(R.string.current_magisk_title, getApplication().magiskVersionString)); - installTitle.setText(getString(R.string.install_magisk_title, getApplication().remoteMagiskVersion)); + if (getApplication().magiskVersion < 0) + currentVersionTitle.setText(getString(R.string.current_magisk_title, getString(R.string.version_none))); + else + currentVersionTitle.setText(getString(R.string.current_magisk_title, "v" + getApplication().magiskVersionString)); + installTitle.setText(getString(R.string.install_magisk_title, "v" + String.format(Locale.US, "%.1f", getApplication().remoteMagiskVersion))); flashButton.setOnClickListener(v1 -> { String bootImage; if (getApplication().bootBlock != null) { @@ -73,7 +77,7 @@ public class InstallFragment extends Fragment implements CallbackEvent.Listener< .setTitle(getString(R.string.repo_install_title, getString(R.string.magisk))) .setMessage(getString(R.string.repo_install_msg, filename)) .setCancelable(true) - .setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.dlAndReceive( + .setPositiveButton(R.string.install, (dialogInterface, i) -> Utils.dlAndReceive( getActivity(), new DownloadReceiver() { private String boot = bootImage; diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java index 172476cdc..53c3fcbf6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java @@ -38,7 +38,7 @@ public class MagiskManager extends Application { // Info public double magiskVersion; - public String magiskVersionString = "(none)"; + public String magiskVersionString; public double remoteMagiskVersion = -1; public String magiskLink; public String releaseNoteLink; @@ -46,7 +46,8 @@ public class MagiskManager extends Application { public String bootBlock = null; public boolean isSuClient = false; public String suVersion = null; - public boolean disabled = false; + public boolean disabled; + public boolean magiskHideStarted; // Data public ValueSortedMap repoMap; @@ -90,6 +91,8 @@ public class MagiskManager extends Application { devLogging = prefs.getBoolean("developer_logging", false); shellLogging = prefs.getBoolean("shell_logging", false); magiskHide = prefs.getBoolean("magiskhide", false); + // Always start a new root shell manually, just for safety + Shell.init(); updateMagiskInfo(); initSuAccess(); initSuConfigs(); @@ -149,6 +152,15 @@ public class MagiskManager extends Application { } catch (NumberFormatException e) { disabled = false; } + ret = Shell.sh("getprop persist.magisk.hide"); + try { + magiskHideStarted = Utils.isValidShellResponse(ret) && Integer.parseInt(ret.get(0)) != 0; + } catch (NumberFormatException e) { + magiskHideStarted = false; + } + + if (!magiskHide && magiskHideStarted) + magiskHide = true; } diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index bee007dbb..4d3978d3c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -15,10 +15,6 @@ import com.topjohnwu.magisk.asyncs.LoadRepos; import com.topjohnwu.magisk.asyncs.MagiskHide; import com.topjohnwu.magisk.components.Activity; import com.topjohnwu.magisk.services.UpdateCheckService; -import com.topjohnwu.magisk.utils.Shell; -import com.topjohnwu.magisk.utils.Utils; - -import java.util.List; public class SplashActivity extends Activity{ @@ -34,10 +30,6 @@ public class SplashActivity extends Activity{ // Init the info and configs and root shell magiskManager.init(); - // Check MagiskHide status - List ret = Shell.sh("getprop persist.magisk.hide"); - boolean started = Utils.isValidShellResponse(ret) && Integer.parseInt(ret.get(0)) != 0; - // Initialize the update check service, notify every 3 hours if (!"install".equals(getIntent().getStringExtra(MainActivity.SECTION))) { ComponentName service = new ComponentName(magiskManager, UpdateCheckService.class); @@ -53,7 +45,7 @@ public class SplashActivity extends Activity{ // Now fire all async tasks new GetBootBlocks(this).exec(); if (magiskManager.magiskHide && !magiskManager.disabled && - magiskManager.magiskVersion > 11 && !started) { + magiskManager.magiskVersion > 11 && !magiskManager.magiskHideStarted) { new MagiskHide().enable(); } new LoadModules(this) { diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java index b35bfc74c..be620f8eb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java @@ -60,7 +60,7 @@ public class ReposAdapter extends RecyclerView.Adapter .setTitle(mContext.getString(R.string.repo_install_title, repo.getName())) .setMessage(mContext.getString(R.string.repo_install_msg, filename)) .setCancelable(true) - .setPositiveButton(R.string.download_install, (d, i) -> Utils.dlAndReceive( + .setPositiveButton(R.string.install, (d, i) -> Utils.dlAndReceive( mContext, new DownloadReceiver() { @Override diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadRepos.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadRepos.java index 71994e85f..ca2cb87b1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadRepos.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadRepos.java @@ -42,24 +42,26 @@ public class LoadRepos extends ParallelTask { SharedPreferences prefs = magiskManager.prefs; + RepoDatabaseHelper dbHelper = new RepoDatabaseHelper(magiskManager); + // Legacy data cleanup - new File(prefsPath, "RepoMap.xml").delete(); - prefs.edit().remove("version").remove("repomap").apply(); + File old = new File(prefsPath, "RepoMap.xml"); + if (old.exists() || !prefs.getString("repomap", "empty").equals("empty")) { + old.delete(); + prefs.edit().remove("version").remove("repomap").remove(ETAG_KEY).apply(); + dbHelper.clearRepo(); + } Map header = new HashMap<>(); // Get cached ETag to add in the request header String etag = prefs.getString(ETAG_KEY, ""); - - // Add header only if db exists - if (magiskManager.getDatabasePath("repo.db").exists()) - header.put("If-None-Match", etag); + header.put("If-None-Match", etag); magiskManager.repoMap = new ValueSortedMap<>(); // Make a request to main URL for repo info String jsonString = WebService.request(REPO_URL, WebService.GET, null, header, false); - RepoDatabaseHelper dbHelper = new RepoDatabaseHelper(magiskManager); ValueSortedMap cached = dbHelper.getRepoMap(); if (!TextUtils.isEmpty(jsonString)) { diff --git a/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java b/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java index 37a150412..a8d803c19 100644 --- a/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java +++ b/app/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java @@ -6,6 +6,7 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import com.topjohnwu.magisk.module.Repo; +import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.ValueSortedMap; import java.util.Collection; @@ -65,6 +66,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper { try (Cursor c = db.query(TABLE_NAME, null, null, null, null, null, null)) { while (c.moveToNext()) { repo = new Repo(c); + Logger.dev("Load from cache: " + repo.getId()); ret.put(repo.getId(), repo); } } diff --git a/app/src/main/java/com/topjohnwu/magisk/module/BaseModule.java b/app/src/main/java/com/topjohnwu/magisk/module/BaseModule.java index aea90c1e8..7b3216697 100644 --- a/app/src/main/java/com/topjohnwu/magisk/module/BaseModule.java +++ b/app/src/main/java/com/topjohnwu/magisk/module/BaseModule.java @@ -1,6 +1,7 @@ package com.topjohnwu.magisk.module; +import android.database.Cursor; import android.support.annotation.NonNull; import com.topjohnwu.magisk.utils.Logger; @@ -9,43 +10,52 @@ import java.util.List; public abstract class BaseModule implements Comparable { - protected String mId, mName, mVersion, mAuthor, mDescription; - protected int mVersionCode = 0; + private String mId, mName, mVersion, mAuthor, mDescription; + private int mVersionCode = 0; + + protected BaseModule() {} + + protected BaseModule(Cursor c) { + mId = c.getString(c.getColumnIndex("id")); + mName = c.getString(c.getColumnIndex("name")); + mVersion = c.getString(c.getColumnIndex("version")); + mVersionCode = c.getInt(c.getColumnIndex("versionCode")); + mAuthor = c.getString(c.getColumnIndex("author")); + mDescription = c.getString(c.getColumnIndex("description")); + } protected void parseProps(List props) throws CacheModException { parseProps(props.toArray(new String[props.size()])); } protected void parseProps(String[] props) throws CacheModException { for (String line : props) { String[] prop = line.split("=", 2); - if (prop.length != 2) { + if (prop.length != 2) continue; - } String key = prop[0].trim(); - if (key.charAt(0) == '#') { + if (key.charAt(0) == '#') continue; - } switch (key) { case "id": - this.mId = prop[1]; + mId = prop[1]; break; case "name": - this.mName = prop[1]; + mName = prop[1]; break; case "version": - this.mVersion = prop[1]; + mVersion = prop[1]; break; case "versionCode": try { - this.mVersionCode = Integer.parseInt(prop[1]); + mVersionCode = Integer.parseInt(prop[1]); } catch (NumberFormatException ignored) {} break; case "author": - this.mAuthor = prop[1]; + mAuthor = prop[1]; break; case "description": - this.mDescription = prop[1]; + mDescription = prop[1]; break; case "cacheModule": if (Boolean.parseBoolean(prop[1])) @@ -61,6 +71,10 @@ public abstract class BaseModule implements Comparable { return mName; } + public void setName(String name) { + mName = name; + } + public String getVersion() { return mVersion; } @@ -73,6 +87,10 @@ public abstract class BaseModule implements Comparable { return mId; } + public void setId(String id) { + mId = id; + } + public String getDescription() { return mDescription; } @@ -88,7 +106,7 @@ public abstract class BaseModule implements Comparable { } @Override - public int compareTo(@NonNull BaseModule o) { - return this.getName().toLowerCase().compareTo(o.getName().toLowerCase()); + public int compareTo(@NonNull BaseModule module) { + return this.getName().toLowerCase().compareTo(module.getName().toLowerCase()); } } diff --git a/app/src/main/java/com/topjohnwu/magisk/module/Module.java b/app/src/main/java/com/topjohnwu/magisk/module/Module.java index bd7f62f9a..5996d26fa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/module/Module.java +++ b/app/src/main/java/com/topjohnwu/magisk/module/Module.java @@ -16,15 +16,15 @@ public class Module extends BaseModule { mDisableFile = path + "/disable"; mUpdateFile = path + "/update"; - if (mId == null) { + if (getId() == null) { int sep = path.lastIndexOf('/'); - mId = path.substring(sep + 1); + setId(path.substring(sep + 1)); } - if (mName == null) - mName = mId; + if (getName() == null) + setName(getId()); - Logger.dev("Creating Data, id: " + mId); + Logger.dev("Creating Module, id: " + getId()); mEnable = !Utils.itemExist(mDisableFile); mRemove = Utils.itemExist(mRemoveFile); diff --git a/app/src/main/java/com/topjohnwu/magisk/module/Repo.java b/app/src/main/java/com/topjohnwu/magisk/module/Repo.java index 2ce680196..12e69792d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/module/Repo.java +++ b/app/src/main/java/com/topjohnwu/magisk/module/Repo.java @@ -23,12 +23,7 @@ public class Repo extends BaseModule { } public Repo(Cursor c) { - mId = c.getString(c.getColumnIndex("id")); - mName = c.getString(c.getColumnIndex("name")); - mVersion = c.getString(c.getColumnIndex("version")); - mVersionCode = c.getInt(c.getColumnIndex("versionCode")); - mAuthor = c.getString(c.getColumnIndex("author")); - mDescription = c.getString(c.getColumnIndex("description")); + super(c); repoName = c.getString(c.getColumnIndex("repo_name")); mLastUpdate = new Date(c.getLong(c.getColumnIndex("last_update"))); } @@ -50,12 +45,12 @@ public class Repo extends BaseModule { public ContentValues getContentValues() { ContentValues values = new ContentValues(); - values.put("id", mId); - values.put("name", mName); - values.put("version", mVersion); - values.put("versionCode", mVersionCode); - values.put("author", mAuthor); - values.put("description", mDescription); + values.put("id", getId()); + values.put("name", getName()); + values.put("version", getVersion()); + values.put("versionCode", getVersionCode()); + values.put("author", getAuthor()); + values.put("description", getDescription()); values.put("repo_name", repoName); values.put("last_update", mLastUpdate.getTime()); return values; diff --git a/app/src/main/java/com/topjohnwu/magisk/services/BootupIntentService.java b/app/src/main/java/com/topjohnwu/magisk/services/BootupIntentService.java index b90ba2d73..2ba39b25b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/services/BootupIntentService.java +++ b/app/src/main/java/com/topjohnwu/magisk/services/BootupIntentService.java @@ -9,8 +9,6 @@ import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; -import java.util.List; - public class BootupIntentService extends IntentService { public BootupIntentService() { @@ -22,10 +20,8 @@ public class BootupIntentService extends IntentService { MagiskManager magiskManager = Utils.getMagiskManager(this); magiskManager.initSuAccess(); magiskManager.updateMagiskInfo(); - List ret = Shell.sh("getprop persist.magisk.hide"); - boolean started = Utils.isValidShellResponse(ret) && Integer.parseInt(ret.get(0)) != 0; if (magiskManager.prefs.getBoolean("magiskhide", false) && - !magiskManager.disabled && !started && magiskManager.magiskVersion > 11) { + !magiskManager.disabled && !magiskManager.magiskHideStarted && magiskManager.magiskVersion > 11) { magiskManager.toast(R.string.start_magiskhide, Toast.LENGTH_LONG); Shell.su(true, MagiskManager.MAGISK_HIDE_PATH + "enable", "setprop persist.magisk.hide 1"); diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index dc310f4a9..12e9366f4 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -105,7 +105,7 @@ نسخ الملف المضغوط إلى دليل مؤقت تحقق جاري التنزيل %1$s - تثبيت Magisk الإصدار: v%1$.1f + تثبيت Magisk الإصدار: %1$s إبقاء التشفير القوى إبقاء dm-verity مروت لكن لا يوجد إذن الروت، غير مسموح به؟ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 5c68cd7c4..8f48b5507 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -46,7 +46,7 @@ \"force encryption\" beibehalten \"dm-verity\"-Test beibehalten Installierte Magisk-Version: %1$s - Neueste Magisk-Version: %1$.1f + Neueste Magisk-Version: %1$s Deinstallieren diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index efbcfef26..0d641e1a2 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -40,8 +40,8 @@ Ajustes avanzados Mantener cifrado forzado Mantener dm-verity - Versión de Magisk instalada: v%1$s - Última versión de Magisk: v%1$.1f + Versión de Magisk instalada: %1$s + Última versión de Magisk: %1$s Desinstalar Reiniciando en %1$d diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 4caee2c1a..cd275a3ec 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -40,8 +40,8 @@ Impostazioni Avanzate Mantieni crittografia forzata Mantieni dm-verity - Versione Magisk installata: v%1$s - Ultima versione Magisk: v%1$.1f + Versione Magisk installata: %1$s + Ultima versione Magisk: %1$s diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 9fdaf1692..ee1d4d7db 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -40,8 +40,8 @@ 고급 설정 강제 암호화 유지 dm-verity 유지 - 설치된 Magisk 버전: v%1$s - 최신 Magisk 버전: v%1$.1f + 설치된 Magisk 버전: %1$s + 최신 Magisk 버전: %1$s 제거 %1$d초 안에 다시 시작됨 diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index adbe3a0aa..b6094c426 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -42,8 +42,8 @@ Zaawansowane Ustawienia Keep force encryption Keep dm-verity - Zainstalowana Wersja Magisk: v%1$s - Ostatnia Wersja Magisk: v%1$.1f + Zainstalowana Wersja Magisk: %1$s + Ostatnia Wersja Magisk: %1$s Odinstaluj Restartuj do %1$d diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 9ab7480f8..df8b71f56 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -41,8 +41,8 @@ Configurações avançadas Keep force encryption Keep dm-verity - Versão instalada do Magisk: v%1$s - Última versão do Magisk: v%1$.1f + Versão instalada do Magisk: %1$s + Última versão do Magisk: %1$s diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index c48640eb8..870a54a97 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -38,8 +38,8 @@ Дополнительные настройки Оставить шифрование Оставить dm-verity - Установленная версия Magisk: v%1$s - Последняя версия Magisk: v%1$.1f + Установленная версия Magisk: %1$s + Последняя версия Magisk: %1$s Удалить Перезагрузка через %1$d diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 92aff8186..31b518ba6 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -40,8 +40,8 @@ 高级设置 保持强制加密 保留 dm-verity - 已安装 Magisk 版本:v%1$s - 最新的 Magisk 版本:v%1$.1f + 已安装 Magisk 版本:%1$s + 最新的 Magisk 版本:%1$s 卸载 将在 %1$d 后重启 卸载 Magisk diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 7fa9d652f..285aaa33e 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -40,8 +40,8 @@ 高級設置 保持強制加密 保留 dm-verity - 已安裝 Magisk 版本:v%1$s - 最新的 Magisk 版本:v%1$.1f + 已安裝 Magisk 版本:%1$s + 最新的 Magisk 版本:%1$s 解除安裝 將在 %1$d 後重啟 @@ -188,5 +188,6 @@ 處理中 解除安裝 Magisk 這將會刪除所有模組,MagiskSU,並有可能在目前未加密的情況下加密的的資料\n你確定要繼續嗎? + (無) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 76d3b0053..16e84ee4a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -43,12 +43,13 @@ Advanced Settings Keep force encryption Keep dm-verity - Installed Magisk Version: v%1$s - Latest Magisk Version: v%1$.1f + Installed Magisk Version: %1$s + Latest Magisk Version: %1$s Uninstall Rebooting in %1$d Uninstall Magisk This will remove all modules, MagiskSU, and potentially encrypt your data if not encrypted\nAre you sure to continue? + (None) (No info provided)