Skip to content

Commit

Permalink
Use AOSP Share Sheet for IntentResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
YifePlayte committed Dec 23, 2024
1 parent 2c84dfd commit cbbeb62
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 15 deletions.
9 changes: 1 addition & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
tools:node="remove" />
<permission
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
tools:node="remove" />
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
22 changes: 17 additions & 5 deletions app/src/main/java/com/yifeplayte/wommo/activity/pages/MainPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import cn.fkj233.ui.activity.view.TextSummaryV
import cn.fkj233.ui.dialog.MIUIDialog
import com.yifeplayte.wommo.R
import com.yifeplayte.wommo.hook.PACKAGE_NAME_HOOKED
import com.yifeplayte.wommo.utils.Build.HYPER_OS_VERSION
import com.yifeplayte.wommo.utils.Build.IS_INTERNATIONAL_BUILD
import com.yifeplayte.wommo.utils.Terminal

Expand All @@ -26,11 +27,13 @@ class MainPage : BasePage() {
tipsId = R.string.force_dark_mode_for_all_apps_tips
), SwitchV("force_dark_mode_for_all_apps", false)
)
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.use_aosp_share_sheet,
), SwitchV("use_aosp_share_sheet", false)
)
if (HYPER_OS_VERSION < 2) {
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.use_aosp_share_sheet,
), SwitchV("use_aosp_share_sheet", false)
)
}
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.use_aosp_screenshot,
Expand Down Expand Up @@ -312,6 +315,15 @@ class MainPage : BasePage() {
}, bindingEnableBatteryMonitorService.getRecv(1)
)
Line()
TitleText(textId = R.string.intent_resolver)
if (HYPER_OS_VERSION >= 2) {
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.use_aosp_share_sheet,
), SwitchV("use_aosp_share_sheet", false)
)
}
Line()
TitleText(textId = R.string.others)
TextSummaryWithSwitch(
TextSummaryV(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.yifeplayte.wommo.hook.hooks.singlepackage

import com.yifeplayte.wommo.hook.hooks.BasePackage

@Suppress("unused")
object IntentResolver : BasePackage("com.android.intentresolver")
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package com.yifeplayte.wommo.hook.hooks.singlepackage.android

import android.provider.Settings
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.EzXHelper.appContext
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import com.yifeplayte.wommo.hook.hooks.BaseHook
import com.yifeplayte.wommo.utils.Build.HYPER_OS_VERSION

@Suppress("unused")
object UseAOSPShareSheet : BaseHook() {
override val key = "use_aosp_share_sheet"
override val isEnabled = (HYPER_OS_VERSION < 2) and super.isEnabled
override fun hook() {
loadClass("com.android.internal.app.ResolverActivityStubImpl").methodFinder()
.filterByName("useAospShareSheet").single().createHook {
returnConstant(true)
before {
it.result = Settings.System.getInt(
appContext.contentResolver,
"mishare_enabled"
) != 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.yifeplayte.wommo.hook.hooks.singlepackage.intentresolver

import android.provider.Settings
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.EzXHelper.appContext
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import com.yifeplayte.wommo.hook.hooks.BaseHook
import com.yifeplayte.wommo.utils.Build.HYPER_OS_VERSION

@Suppress("unused")
object UseAOSPShareSheet : BaseHook() {
override val key = "use_aosp_share_sheet"
override val isEnabled = (HYPER_OS_VERSION >= 2) and super.isEnabled
override fun hook() {
loadClass("com.android.intentresolver.ApplicationStubImpl").methodFinder()
.filterByName("useAospVersion").single().createHook {
before {
it.result = Settings.System.getInt(
appContext.contentResolver,
"mishare_enabled"
) != 1
}
}
}
}
9 changes: 9 additions & 0 deletions app/src/main/java/com/yifeplayte/wommo/utils/Build.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ object Build {
clazzSystemProperties, "getInt", null, "ro.mi.os.version.code", -1
) != -1
}

/**
* HyperOS版本
*/
val HYPER_OS_VERSION by lazy {
invokeStaticMethodBestMatch(
clazzSystemProperties, "getInt", null, "ro.mi.os.version.code", -1
) as Int
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@
<string name="warning">警告</string>
<string name="wave_charge">启用 Alpha 充电动画</string>
<string name="widget_transition_animation">为所有小部件添加启动动画</string>
<string name="intent_resolver">IntentResolver</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<resources>
<string-array name="xposedscope">
<item>android</item>
<item>com.android.intentresolver</item>
<item>com.android.providers.downloads</item>
<item>com.android.settings</item>
<item>com.android.systemui</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@
<string name="wave_charge">Enable wave charge animation</string>
<string name="widget_transition_animation">Enable transition animation for all widgets</string>
<string name="xposed_desc" translatable="false">Works on my machine ONLY</string>
<string name="intent_resolver">IntentResolver</string>
</resources>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.enableR8.fullMode=false
android.nonTransitiveRClass=false
android.nonTransitiveRClass=true
android.nonFinalResIds=false

0 comments on commit cbbeb62

Please sign in to comment.