mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-21 16:47:08 +02:00
fix(sc_plus): mapping update
This commit is contained in:
parent
adc237e0d3
commit
017dd912f6
@ -137,7 +137,9 @@ afterEvaluate {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.8.10'
|
||||
|
||||
compileOnly files('libs/LSPosed-api-1.0-SNAPSHOT.jar')
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'com.arthenica:ffmpeg-kit-full-gpl:5.1.LTS'
|
||||
|
@ -10,19 +10,25 @@ class SnapchatPlus: Feature("SnapchatPlus", loadParams = FeatureLoadParams.ACTIV
|
||||
override fun asyncOnActivityCreate() {
|
||||
if (!context.config.bool(ConfigProperty.SNAPCHAT_PLUS)) return
|
||||
|
||||
Hooker.hookConstructor(context.mappings.getMappedClass("SubscriptionInfoClass"), HookStage.BEFORE) { param ->
|
||||
val subscriptionInfoMembers = context.mappings.getMappedMap("SubscriptionInfoClassMembers")
|
||||
|
||||
Hooker.hookConstructor(context.mappings.getMappedClass("SubscriptionInfoClass"), HookStage.AFTER) { param ->
|
||||
val getField = { key: String -> param.thisObject<Any>().javaClass.declaredFields.first {it.name == (subscriptionInfoMembers[key] as String)}.also { it.isAccessible = true }}
|
||||
|
||||
val subscriptionStatusField = getField("status")
|
||||
val isSubscribedField = getField("isSubscribed")
|
||||
val startTimeMsField = getField("startTimeMs")
|
||||
val expireTimeMsField = getField("expireTimeMs")
|
||||
|
||||
//check if the user is already premium
|
||||
if (param.arg(0) as Int == 2) {
|
||||
if ((subscriptionStatusField[param.thisObject()] as Double).toInt() == 2) {
|
||||
return@hookConstructor
|
||||
}
|
||||
//subscription info tier
|
||||
param.setArg(0, 2)
|
||||
//subscription status
|
||||
param.setArg(1, 2)
|
||||
//subscription time
|
||||
param.setArg(2, System.currentTimeMillis() - 7776000000L)
|
||||
//expiration time
|
||||
param.setArg(3, System.currentTimeMillis() + 15552000000L)
|
||||
|
||||
isSubscribedField.set(param.thisObject(), true)
|
||||
startTimeMsField.set(param.thisObject(), (System.currentTimeMillis() - 7776000000L).toDouble())
|
||||
expireTimeMsField.set(param.thisObject(), (System.currentTimeMillis() + 15552000000L).toDouble())
|
||||
subscriptionStatusField.set(param.thisObject(), 2.toDouble())
|
||||
}
|
||||
}
|
||||
}
|
@ -13,18 +13,28 @@ class PlusSubscriptionMapper : Mapper() {
|
||||
) {
|
||||
//find a method that contains annotations with isSubscribed
|
||||
val loadSubscriptionMethod = context.classCache.composerLocalSubscriptionStore.declaredMethods.first { method: Method ->
|
||||
val returnType = method.returnType
|
||||
returnType.declaredFields.any { field: Field ->
|
||||
field.declaredAnnotations.any { annotation: Annotation ->
|
||||
annotation.toString().contains("isSubscribed")
|
||||
}
|
||||
val returnType = method.returnType
|
||||
returnType.declaredFields.any { field: Field ->
|
||||
field.declaredAnnotations.any { annotation: Annotation ->
|
||||
annotation.toString().contains("isSubscribed")
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
//get the first param of the method which is the PlusSubscriptionState class
|
||||
val plusSubscriptionStateClass = loadSubscriptionMethod.parameterTypes[0]
|
||||
//get the first param of the constructor of PlusSubscriptionState which is the SubscriptionInfo class
|
||||
val subscriptionInfoClass = plusSubscriptionStateClass.constructors[0].parameterTypes[0]
|
||||
*/
|
||||
mappings["SubscriptionInfoClass"] = loadSubscriptionMethod.returnType.name
|
||||
|
||||
mappings["SubscriptionInfoClass"] = subscriptionInfoClass.name
|
||||
val members = mutableMapOf<String, Any>()
|
||||
loadSubscriptionMethod.returnType.declaredFields.forEach { field ->
|
||||
val serializedNameAnnotation = field.declaredAnnotations.first()
|
||||
val propertyName = serializedNameAnnotation.annotationClass.members.first { it.name == "name" }.call(serializedNameAnnotation) as String
|
||||
members[propertyName] = field.name
|
||||
}
|
||||
|
||||
mappings["SubscriptionInfoClassMembers"] = members
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user