mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 18:47:38 +00:00
Rename class
This commit is contained in:
parent
355341f0ab
commit
f4cf5dc0cd
@ -13,7 +13,7 @@ import java.util.Map;
|
||||
import io.michaelrocks.paranoid.Obfuscate;
|
||||
|
||||
@Obfuscate
|
||||
public class DynAPK {
|
||||
public class StubApk {
|
||||
private static File dynDir;
|
||||
private static Method addAssetPath;
|
||||
|
@ -6,7 +6,7 @@ import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.StubApk
|
||||
import com.topjohnwu.magisk.core.utils.*
|
||||
import com.topjohnwu.magisk.di.ServiceLocator
|
||||
import com.topjohnwu.superuser.Shell
|
||||
@ -19,7 +19,7 @@ import kotlin.system.exitProcess
|
||||
open class App() : Application() {
|
||||
|
||||
constructor(o: Any) : this() {
|
||||
val data = DynAPK.Data(o)
|
||||
val data = StubApk.Data(o)
|
||||
// Add the root service name mapping
|
||||
data.classToComponent[RootRegistry::class.java.name] = data.rootService.name
|
||||
// Send back the actual root service class
|
||||
@ -58,7 +58,7 @@ open class App() : Application() {
|
||||
|
||||
refreshLocale()
|
||||
AppApkPath = if (isRunningAsStub) {
|
||||
DynAPK.current(base).path
|
||||
StubApk.current(base).path
|
||||
} else {
|
||||
base.packageResourcePath
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ import android.content.res.AssetManager
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.util.DisplayMetrics
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.StubApk
|
||||
import com.topjohnwu.magisk.core.utils.syncLocale
|
||||
import com.topjohnwu.magisk.di.AppContext
|
||||
|
||||
lateinit var AppApkPath: String
|
||||
|
||||
fun AssetManager.addAssetPath(path: String) = DynAPK.addAssetPath(this, path)
|
||||
fun AssetManager.addAssetPath(path: String) = StubApk.addAssetPath(this, path)
|
||||
|
||||
fun Context.wrap(): Context = if (this is PatchedContext) this else PatchedContext(this)
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.topjohnwu.magisk.core
|
||||
|
||||
import android.os.Build
|
||||
import androidx.databinding.ObservableBoolean
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.StubApk
|
||||
import com.topjohnwu.magisk.core.model.UpdateInfo
|
||||
import com.topjohnwu.magisk.core.utils.net.NetworkObserver
|
||||
import com.topjohnwu.magisk.data.repository.NetworkService
|
||||
@ -16,7 +16,7 @@ val isRunningAsStub get() = Info.stub != null
|
||||
|
||||
object Info {
|
||||
|
||||
var stub: DynAPK.Data? = null
|
||||
var stub: StubApk.Data? = null
|
||||
|
||||
val EMPTY_REMOTE = UpdateInfo()
|
||||
var remote = EMPTY_REMOTE
|
||||
|
@ -5,8 +5,8 @@ import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.net.toFile
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.StubApk
|
||||
import com.topjohnwu.magisk.core.ActivityTracker
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.isRunningAsStub
|
||||
@ -45,7 +45,7 @@ suspend fun DownloadService.handleAPK(subject: Subject.Manager, stream: InputStr
|
||||
if (isRunningAsStub) {
|
||||
val apk = subject.file.toFile()
|
||||
val id = subject.notifyId
|
||||
write(DynAPK.update(this).outputStream())
|
||||
write(StubApk.update(this).outputStream())
|
||||
if (Info.stub!!.version < subject.stub.versionCode) {
|
||||
// Also upgrade stub
|
||||
update(id) {
|
||||
|
@ -5,8 +5,8 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.Toast
|
||||
import com.topjohnwu.magisk.BuildConfig.APPLICATION_ID
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.StubApk
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
@ -156,7 +156,7 @@ object HideAPK {
|
||||
setCancelable(false)
|
||||
show()
|
||||
}
|
||||
val apk = DynAPK.current(activity)
|
||||
val apk = StubApk.current(activity)
|
||||
val receiver = APKInstall.register(activity, APPLICATION_ID) {
|
||||
launchApp(activity, APPLICATION_ID)
|
||||
dialog.dismiss()
|
||||
|
@ -6,8 +6,8 @@ import android.widget.Toast
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.core.os.postDelayed
|
||||
import com.topjohnwu.magisk.BuildConfig
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.StubApk
|
||||
import com.topjohnwu.magisk.core.*
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.inputStream
|
||||
@ -93,7 +93,7 @@ abstract class MagiskInstallImpl protected constructor(
|
||||
try {
|
||||
// Extract binaries
|
||||
if (isRunningAsStub) {
|
||||
val zf = ZipFile(DynAPK.current(context))
|
||||
val zf = ZipFile(StubApk.current(context))
|
||||
|
||||
// Also extract magisk32 on non 64-bit only 64-bit devices
|
||||
val is32lib = Const.CPU_ABI_32?.let {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.topjohnwu.magisk.core.utils
|
||||
|
||||
import android.content.Context
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.StubApk
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
@ -29,7 +29,7 @@ class ShellInit : Shell.Initializer() {
|
||||
if (isRunningAsStub) {
|
||||
if (!shell.isRoot)
|
||||
return true
|
||||
val jar = JarFile(DynAPK.current(context))
|
||||
val jar = JarFile(StubApk.current(context))
|
||||
val bb = jar.getJarEntry("lib/${Const.CPU_ABI}/libbusybox.so")
|
||||
localBB = context.deviceProtectedContext.cachedFile("busybox")
|
||||
localBB.delete()
|
||||
|
@ -21,7 +21,7 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
|
||||
@Override
|
||||
public ClassLoader instantiateClassLoader(ClassLoader cl, ApplicationInfo info) {
|
||||
DynLoad.loadAPK(info);
|
||||
DynLoad.loadApk(info);
|
||||
return new DelegateClassLoader();
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class DownloadActivity extends Activity {
|
||||
finish();
|
||||
};
|
||||
// Download and upgrade the app
|
||||
File apk = dynLoad ? DynAPK.current(this) : new File(getCacheDir(), "manager.apk");
|
||||
File apk = dynLoad ? StubApk.current(this) : new File(getCacheDir(), "manager.apk");
|
||||
request(apkLink).setExecutor(AsyncTask.THREAD_POOL_EXECUTOR).getAsFile(apk, file -> {
|
||||
if (dynLoad) {
|
||||
// TODO
|
||||
@ -140,7 +140,7 @@ public class DownloadActivity extends Activity {
|
||||
try (is; out) {
|
||||
APKInstall.transfer(is, out);
|
||||
}
|
||||
DynAPK.addAssetPath(getResources().getAssets(), apk.getPath());
|
||||
StubApk.addAssetPath(getResources().getAssets(), apk.getPath());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class DynLoad {
|
||||
// The current active classloader
|
||||
static ClassLoader loader = new RedirectClassLoader();
|
||||
static Object componentFactory;
|
||||
static final DynAPK.Data apkData = createApkData();
|
||||
static final StubApk.Data apkData = createApkData();
|
||||
|
||||
private static boolean loadedApk = false;
|
||||
|
||||
@ -46,13 +46,13 @@ public class DynLoad {
|
||||
}
|
||||
|
||||
// Dynamically load APK from internal or external storage
|
||||
static void loadAPK(ApplicationInfo info) {
|
||||
static void loadApk(ApplicationInfo info) {
|
||||
if (loadedApk)
|
||||
return;
|
||||
loadedApk = true;
|
||||
|
||||
File apk = DynAPK.current(info);
|
||||
File update = DynAPK.update(info);
|
||||
File apk = StubApk.current(info);
|
||||
File update = StubApk.update(info);
|
||||
|
||||
if (update.exists()) {
|
||||
// Rename from update
|
||||
@ -98,8 +98,8 @@ public class DynLoad {
|
||||
// Dynamically load APK, inject ClassLoader into ContextImpl, then
|
||||
// create the non-stub Application instance from the loaded APK
|
||||
static Application createApp(Context context) {
|
||||
File apk = DynAPK.current(context);
|
||||
loadAPK(context.getApplicationInfo());
|
||||
File apk = StubApk.current(context);
|
||||
loadApk(context.getApplicationInfo());
|
||||
|
||||
// Trigger folder creation
|
||||
context.getExternalFilesDir(null);
|
||||
@ -193,8 +193,8 @@ public class DynLoad {
|
||||
}
|
||||
}
|
||||
|
||||
private static DynAPK.Data createApkData() {
|
||||
var data = new DynAPK.Data();
|
||||
private static StubApk.Data createApkData() {
|
||||
var data = new StubApk.Data();
|
||||
data.setVersion(BuildConfig.STUB_VERSION);
|
||||
data.setClassToComponent(Mapping.inverseMap);
|
||||
data.setRootService(DelegateRootService.class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user