diff --git a/android/app/src/main/java/now/fortuitous/thanos/ThanosApp.kt b/android/app/src/main/java/now/fortuitous/thanos/ThanosApp.kt index 988206ef7..b2a0dfec3 100644 --- a/android/app/src/main/java/now/fortuitous/thanos/ThanosApp.kt +++ b/android/app/src/main/java/now/fortuitous/thanos/ThanosApp.kt @@ -32,6 +32,7 @@ import github.tornaco.thanos.module.component.manager.initRules import io.reactivex.plugins.RxJavaPlugins import now.fortuitous.app.Init import now.fortuitous.app.Stats +import now.fortuitous.thanos.power.ShortcutHelper import org.lsposed.hiddenapibypass.HiddenApiBypass import tornaco.apps.thanox.ThanosLite @@ -74,5 +75,8 @@ class ThanosApp : MultipleModulesApp() { } ThanosLite.init(this) + ThanosLite.installShortcut = { context, app -> + ShortcutHelper.addShortcut(context, app) + } } } \ No newline at end of file diff --git a/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutHelper.java b/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutHelper.java index 20e507314..d8bc7791e 100644 --- a/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutHelper.java +++ b/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutHelper.java @@ -52,13 +52,13 @@ import github.tornaco.android.thanos.util.ShortcutReceiver; @SuppressWarnings("UnstableApiUsage") -class ShortcutHelper { +public class ShortcutHelper { private static final String STUB_APK_TEMPLATE_PATH = "shortcut_stub_template.apk"; private static final String OUT_APK_PATH = "shortcut_stub_apks"; private static final String WORK_DIR_PATH = "tmp_"; private static final String ICON_DIR_PATH = "icon.png"; - static void addShortcut(Context context, AppInfo appInfo) { + public static void addShortcut(Context context, AppInfo appInfo) { if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) { // Post load with glide. GlideApp.with(context) diff --git a/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutStubActivity.java b/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutStubActivity.java index 6334ca146..c14072e65 100644 --- a/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutStubActivity.java +++ b/android/app/src/main/java/now/fortuitous/thanos/power/ShortcutStubActivity.java @@ -27,6 +27,7 @@ import github.tornaco.android.thanos.core.app.ThanosManager; import github.tornaco.android.thanos.core.pm.Pkg; +import tornaco.apps.thanox.ThanosLite; public class ShortcutStubActivity extends Activity { @@ -65,8 +66,10 @@ private void internalResolveIntent() { int userId = intent.getIntExtra(EXTRA_TARGET_USER_ID, 0); - ThanosManager.from(getApplicationContext()) - .ifServiceInstalled(thanosManager -> - thanosManager.getPkgManager().launchSmartFreezePkg(new Pkg(target, userId))); + if (ThanosManager.from(getApplicationContext()).isServiceInstalled()) { + ThanosManager.from(getApplicationContext()).getPkgManager().launchSmartFreezePkg(new Pkg(target, userId)); + } else { + ThanosLite.Companion.launchShortcut(new Pkg(target, userId)); + } } } diff --git a/android/internal/Thanox-Internal b/android/internal/Thanox-Internal index 047af2d7c..9cdddbd81 160000 --- a/android/internal/Thanox-Internal +++ b/android/internal/Thanox-Internal @@ -1 +1 @@ -Subproject commit 047af2d7c4d4d415b6951a61854adfa58b729df8 +Subproject commit 9cdddbd81e3d866b89b0c7c458ba9f30c278f61f