-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathSharedPreferencesTest.kt
79 lines (70 loc) · 2.92 KB
/
SharedPreferencesTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package suites
import TestBase
import jmp0.app.AndroidEnvironment
import jmp0.app.IAndroidInvokeFile
import jmp0.app.conversation.AppdbgConversationSchemaEnum
import jmp0.app.conversation.IAppdbgConversation
import jmp0.app.conversation.IAppdbgConversationHandler
import jmp0.app.conversation.impl.sp.SharedPreferencesConversation
import jmp0.app.interceptor.intf.IInterceptor
import org.junit.jupiter.api.Test
class SharedPreferencesTest:TestBase(),IAndroidInvokeFile {
override fun test() {
val ae = AndroidEnvironment(TestUtil.testApkFile, object : IInterceptor {
override fun nativeCalled(
uuid: String,
className: String,
funcName: String,
signature: String,
param: Array<Any?>
): IInterceptor.ImplStatus {
return IInterceptor.ImplStatus(false,null)
}
override fun methodCalled(
uuid: String,
className: String,
instance: Any?,
funcName: String,
signature: String,
param: Array<Any?>
): Any? {
TODO("Not yet implemented")
}
override fun ioResolver(path: String): String? {
return null
}
})
ae.setConversationHandler(AppdbgConversationSchemaEnum.SHARED_PREFERENCES,object : IAppdbgConversationHandler {
override fun appdbgConversationHandle(
androidEnvironment: AndroidEnvironment,
conversation: IAppdbgConversation<*>
): IInterceptor.ImplStatus {
with(conversation as SharedPreferencesConversation){
val keyName = conversation.data.params[0] as String
when(conversation.data.methodName){
"getString"->{
if (keyName == "test1"){
return IInterceptor.ImplStatus(true,"SharedPreferencesConversation Test")
}
}
"getInt"->{
if (keyName == "test2"){
return IInterceptor.ImplStatus(true,666)
}
}
}
}
return IInterceptor.ImplStatus(false,null)
}
})
val contextClazz = ae.findClass("android.content.Context")
val clazz = ae.loadClass("jmp0.test.testapp.SharedPreferencesTest")
val ins = clazz.getDeclaredConstructor(contextClazz).newInstance(ae.context)
clazz.getDeclaredMethod("testAll").invoke(ins)
// ae.runInvokeFile(this)
ae.destroy()
}
override fun run(androidEnvironment: AndroidEnvironment) {
// jmp0.test.testapp.SharedPreferencesTest(androidEnvironment.context as android.content.Context).testAll()
}
}