Skip to content

Commit 21d166c

Browse files
committed
chore(QQTIMHooker): comment and rollback PicEmoticonInfo part
unable to send stickers added by `PicEmoticonInfo` after a night, and failed to fix, so that comment them temporarily.
1 parent 395a58a commit 21d166c

1 file changed

Lines changed: 104 additions & 72 deletions

File tree

  • app/src/main/java/net/fosky/sticker/sticker_sword/hook/entity

app/src/main/java/net/fosky/sticker/sticker_sword/hook/entity/QQTIMHooker.kt

Lines changed: 104 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,17 @@
2323

2424
package net.fosky.sticker.sticker_sword.hook.entity
2525

26-
import android.app.Activity
27-
import android.Manifest
28-
import android.content.Intent
29-
import android.content.pm.PackageManager
30-
import android.net.Uri
31-
import android.os.Build
32-
import android.os.Environment
33-
import android.provider.Settings
34-
import androidx.annotation.RequiresApi
35-
import androidx.core.app.ActivityCompat
36-
import androidx.core.content.ContextCompat
26+
import android.view.View;
27+
import android.widget.TextView
3728
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
3829
import com.highcapable.yukihookapi.hook.factory.allConstructors
30+
import com.highcapable.yukihookapi.hook.factory.allFields
3931
import com.highcapable.yukihookapi.hook.factory.allMethods
4032
import com.highcapable.yukihookapi.hook.factory.buildOf
41-
import com.highcapable.yukihookapi.hook.factory.constructor
42-
import com.highcapable.yukihookapi.hook.factory.current
4333
import com.highcapable.yukihookapi.hook.factory.field
4434
import com.highcapable.yukihookapi.hook.factory.method
4535
import com.highcapable.yukihookapi.hook.log.YLog
4636
import com.highcapable.yukihookapi.hook.type.java.StringClass
47-
import de.robv.android.xposed.XC_MethodHook
48-
import de.robv.android.xposed.XposedHelpers
49-
import de.robv.android.xposed.XposedHelpers.getObjectField
5037
import net.fosky.sticker.sticker_sword.const.PackageName
5138
import net.fosky.sticker.sticker_sword.hook.entity.QQTIMHooker.lazyClassOrNull
5239
import net.fosky.sticker.sticker_sword.utils.factory.*
@@ -77,24 +64,6 @@ class StickerManagerEmoticonProvider : ExtraEmoticonProvider() {
7764
val FavoriteEmoticonInfo by lazyClassOrNull("${PackageName.QQ}.emoticonview.FavoriteEmoticonInfo")
7865
val PicEmoticonInfo by lazyClassOrNull("${PackageName.QQ}.emoticonview.PicEmoticonInfo")
7966
val Emoticon by lazyClassOrNull("${PackageName.QQ}.data.Emoticon")
80-
// val emoticon = first?.get<Any>("emoticon")
81-
//// val imageType = first?.get<Any>("imageType")//3
82-
//// val mDefault = first?.get<Any>("mDefault")
83-
//// val mEmptyDrawable = first?.get<Any>("mEmptyDrawable")
84-
//// val mFailed = first?.get<Any>("mFailed")
85-
//// val uin = first?.get<Any>("uin")
86-
//
87-
// //YLog.info("getEmotionPanelData: $emoticon, $imageType, $isAPNG, $isDownLoad, $mDefault, $mEmptyDrawable, $mFailed, $mFiveInchDefault, $mFiveInchFailed, $reqHeight, $reqWidth, $roamingType, $uin")
88-
//
89-
// val eId = emoticon?.get<Any>("eId")//md5?
90-
// val encryptKey = emoticon?.get<Any>("encryptKey")//?
91-
// val epId = emoticon?.get<Any>("epId")//id
92-
// val extensionHeight = emoticon?.get<Any>("extensionHeight")//300
93-
// val extensionWidth = emoticon?.get<Any>("extensionWidth")//300
94-
// val height = emoticon?.get<Any>("height")//200
95-
// val keywords = emoticon?.get<Any>("keywords")//["XXXX"]
96-
// val name = emoticon?.get<Any>("name")//name
97-
// val width = emoticon?.get<Any>("width")//200
9867

9968
private var emoticons: List<ExtraEmoticon> = listOf()
10069
private var iconPath: String? = null
@@ -104,35 +73,40 @@ class StickerManagerEmoticonProvider : ExtraEmoticonProvider() {
10473

10574
for (sticker in stickers) {
10675
emoticons.add(object : ExtraEmoticon() {
107-
// val info = FavoriteEmoticonInfo?.buildOf()
108-
//
109-
// init {
110-
// info.set("path", sticker.path)
111-
// info.set("remark", sticker.notes)
112-
// info.set("actionData", "${uniqueId()}:${sticker.path}")
113-
// }
114-
val _info = PicEmoticonInfo?.buildOf("uin") {
115-
param(StringClass)
116-
}
117-
val _emoticon = Emoticon?.buildOf()
76+
val _info = FavoriteEmoticonInfo?.buildOf()
11877

11978
init {
120-
_emoticon?.set("eId", sticker.path)
121-
_emoticon?.set("epId", "ss:${sticker.id}")
122-
_emoticon?.set("encryptKey", "")
123-
_emoticon?.set("extensionHeight", 300)
124-
_emoticon?.set("extensionWidth", 300)
125-
_emoticon?.set("height", 200)
126-
_emoticon?.set("width", 200)
127-
_emoticon?.set("keywords", "[\"${sticker.notes}\"]")
128-
_emoticon?.set("name", sticker.notes)
129-
130-
if (_emoticon != null) {
131-
_info?.set("emoticon", _emoticon)
132-
}
133-
134-
_info?.set("imageType", 3)
79+
_info.set("path", sticker.path)
80+
_info.set("actionData", "${uniqueId()}:${sticker.path}")
13581
}
82+
// 很怪的事情,过了一晚上就无法发送用 PicEmoticonInfo 增加的表情,疑似云控了?调试好久没找到哪里有做检测
83+
// com.tencent.mobileqq.emoticonview.QQEmoticonPanelLinearLayoutHelper -> performClick
84+
// 理论上下一步会调用 com.tencent.qqnt.aio.adapter.emoticon.NTEmoticonPanelProvider -> send
85+
// 但是只执行了 -> d, -> onResume, -> onPause
86+
// 不知道是不是在这之前有个校验啥的,没找到,先扔着了
87+
88+
// val _info = PicEmoticonInfo?.buildOf("uin") {
89+
// param(StringClass)
90+
// }
91+
// val _emoticon = Emoticon?.buildOf()
92+
//
93+
// init {
94+
// _emoticon?.set("eId", sticker.path)
95+
// _emoticon?.set("epId", "ss:${sticker.id}")
96+
// _emoticon?.set("encryptKey", "")
97+
// _emoticon?.set("extensionHeight", 300)
98+
// _emoticon?.set("extensionWidth", 300)
99+
// _emoticon?.set("height", 200)
100+
// _emoticon?.set("width", 200)
101+
// _emoticon?.set("keywords", "[\"${sticker.notes}\"]")
102+
// _emoticon?.set("name", sticker.notes)
103+
//
104+
// if (_emoticon != null) {
105+
// _info?.set("emoticon", _emoticon)
106+
// }
107+
//
108+
// _info?.set("imageType", 3)
109+
// }
136110

137111
override fun QQEmoticonObject(): Any? {
138112
return _info
@@ -201,23 +175,81 @@ object QQTIMHooker : YukiBaseHooker() {
201175
val EmoticonPanelInfo by lazyClassOrNull("${PackageName.QQ}.emoticonview.EmotionPanelInfo")
202176
val EmoticonPackage by lazyClassOrNull("${PackageName.QQ}.data.EmoticonPackage")
203177
val PicEmoticonInfo by lazyClassOrNull("${PackageName.QQ}.emoticonview.PicEmoticonInfo")
178+
val URLDrawable by lazyClassOrNull("com.tencent.image.URLDrawable")
179+
val URLDrawableOptionsClassName = "com.tencent.image.URLDrawable\$URLDrawableOptions"
180+
val URLDrawableOptions by lazyClassOrNull(URLDrawableOptionsClassName)
204181

205182
private val isQQ get() = packageName == PackageName.QQ
206183
private var hostVersionName = "<unknown>"
207184

208185
private fun hookEmoticon() {
209-
PicEmoticonInfo?.method {
210-
name = "getPanelImageURL"
211-
}?.hook()?.before {
212-
val emoticon = PicEmoticonInfo?.field {
213-
name = "emoticon"
214-
}?.get(instance)?.any()
215-
val epId = emoticon?.get<Any>("epId") as String
216-
if (epId.startsWith("ss:")) {
217-
val path = emoticon.get<String>("eId")
218-
result = java.net.URL("file://$path")
219-
}
220-
}
186+
// 既然暂时无法用 PicEmoticonInfo 增加表情,那这段也先注释了
187+
// PicEmoticonInfo?.apply {
188+
// method {
189+
// name = "getPanelImageURL"
190+
// }.hook().before {
191+
// val emoticon = PicEmoticonInfo?.field {
192+
// name = "emoticon"
193+
// }?.get(instance)?.any()
194+
// val epId = emoticon?.get<Any>("epId") as String
195+
// if (epId.startsWith("ss:")) {
196+
// val path = emoticon.get<String>("eId")
197+
// result = java.net.URL("file://$path")
198+
// }
199+
// }
200+
// // 修复长按预览表情无法加载
201+
// method {
202+
// name = "getPicEmoticonLoadingDrawable"
203+
// paramCount = 7
204+
// }.hook().after {
205+
// val emoticon = PicEmoticonInfo?.field {
206+
// name = "emoticon"
207+
// }?.get(instance)?.any()
208+
// val epId = emoticon?.get<Any>("epId") as String
209+
// if (epId.startsWith("ss:")) {
210+
// val obj = args[0]
211+
// val path = emoticon.get<String>("eId")
212+
// val url = java.net.URL("file://$path")
213+
//
214+
// val uRLDrawableO = URLDrawableOptions?.method {
215+
// name = "obtain"
216+
// }?.get()?.call()
217+
// obj.get<Any>("mFailed")?.let { uRLDrawableO.set("mFailedDrawable", it) }
218+
// obj.get<Any>("mDefault")?.let { uRLDrawableO.set("mLoadingDrawable", it) }
219+
// obj.get<Any>("reqWidth")?.let { uRLDrawableO.set("mRequestWidth", it) }
220+
// obj.get<Any>("reqHeight")?.let { uRLDrawableO.set("mRequestHeight", it) }
221+
//
222+
// uRLDrawableO.set("mPlayGifImage", true)
223+
// uRLDrawableO.set("mGifRefreshDelay", 0)
224+
//
225+
// val drawable = URLDrawable?.method {
226+
// name = "getDrawable"
227+
// param("java.net.URL", URLDrawableOptionsClassName)
228+
// }?.get()?.call(url, uRLDrawableO)
229+
// YLog.debug("getPicEmoticonLoadingDrawable: $drawable")
230+
// URLDrawable?.apply {
231+
// method {
232+
// name = "setTag"
233+
// paramCount = 1
234+
// }.get(drawable).call(emoticon)
235+
// method {
236+
// name = "addHeader"
237+
// paramCount = 2
238+
// }.get(drawable).call("my_uin", obj.get<Any>("uin") as String)
239+
// method {
240+
// name = "addHeader"
241+
// paramCount = 2
242+
// }.get(drawable).call("emo_type", obj.get<Any>("imageType").toString())
243+
// val p3 = args[3] as Boolean
244+
// method {
245+
// name = "addHeader"
246+
// paramCount = 2
247+
// }.get(drawable).call("2g_use_gif", if (p3) "true" else "false")
248+
// }
249+
// result = drawable
250+
// }
251+
// }
252+
// }
221253

222254
val providers: List<ExtraEmoticonProvider> = listOf(StickerManagerEmoticonProvider())
223255

0 commit comments

Comments
 (0)