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