Skip to content

Commit

Permalink
修改demo
Browse files Browse the repository at this point in the history
  • Loading branch information
陈少平 committed Oct 20, 2021
1 parent 8468549 commit 5803014
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 231 deletions.
36 changes: 18 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ void createHookServiceByteCode(MethodVisitor mv) {
List<HookMethod> getHookMethods() {
List<HookMethod> hookMethodList = new ArrayList<>()
hookMethodList.add(new HookMethod("java/lang/Thread", "<init>", "()V", { MethodVisitor mv -> createHookThreadByteCode(mv, "java/lang/Thread") }))
hookMethodList.add(new HookMethod("android/os/AsyncTask", "<init>", "()V", { MethodVisitor mv -> createHookThreadByteCode(mv, "android/os/AsyncTask") }))
hookMethodList.add(new HookMethod("android/os/HandlerThread", "<init>", "(Ljava/lang/String;)V", { MethodVisitor mv -> createHookThreadByteCode(mv, "android/os/HandlerThread") }))
hookMethodList.add(new HookMethod("com/quwan/tt/asmdemoapp/MainActivity", "onCreate", "(Landroid/os/Bundle;)V", { MethodVisitor mv ->
println("====>com/quwan/tt/asmdemoapp/MainActivity")
mv.visitLdcInsn("====>MainActivity123")
mv.visitLdcInsn("\u6d4b\u8bd5\u63d2\u5165\u65e5\u5fd7")
mv.visitMethodInsn(Opcodes.INVOKESTATIC, "android/util/Log", "i", "(Ljava/lang/String;Ljava/lang/String;)I", false)
mv.visitInsn(Opcodes.POP)
}))

hookMethodList.add(new HookMethod("android/app/Service", "startForeground", "(ILandroid/app/Notification;)V", { MethodVisitor mv ->
println("====>startForeground")
createHookServiceByteCode(mv)
}))
hookMethodList.add(new HookMethod("android/app/Service", "startForeground", "(ILandroid/app/Notification;I)V", { MethodVisitor mv ->
println("====>startForeground")
createHookServiceByteCode(mv)
}))
// hookMethodList.add(new HookMethod("android/os/AsyncTask", "<init>", "()V", { MethodVisitor mv -> createHookThreadByteCode(mv, "android/os/AsyncTask") }))
// hookMethodList.add(new HookMethod("android/os/HandlerThread", "<init>", "(Ljava/lang/String;)V", { MethodVisitor mv -> createHookThreadByteCode(mv, "android/os/HandlerThread") }))
// hookMethodList.add(new HookMethod("com/quwan/tt/asmdemoapp/MainActivity", "onCreate", "(Landroid/os/Bundle;)V", { MethodVisitor mv ->
// println("====>com/quwan/tt/asmdemoapp/MainActivity")
// mv.visitLdcInsn("====>MainActivity123")
// mv.visitLdcInsn("\u6d4b\u8bd5\u63d2\u5165\u65e5\u5fd7")
// mv.visitMethodInsn(Opcodes.INVOKESTATIC, "android/util/Log", "i", "(Ljava/lang/String;Ljava/lang/String;)I", false)
// mv.visitInsn(Opcodes.POP)
// }))
//
// hookMethodList.add(new HookMethod("android/app/Service", "startForeground", "(ILandroid/app/Notification;)V", { MethodVisitor mv ->
// println("====>startForeground")
// createHookServiceByteCode(mv)
// }))
// hookMethodList.add(new HookMethod("android/app/Service", "startForeground", "(ILandroid/app/Notification;I)V", { MethodVisitor mv ->
// println("====>startForeground")
// createHookServiceByteCode(mv)
// }))

return hookMethodList
}
Expand Down
39 changes: 0 additions & 39 deletions app/src/main/java/com/quwan/tt/asmdemoapp/A.java

This file was deleted.

26 changes: 0 additions & 26 deletions app/src/main/java/com/quwan/tt/asmdemoapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,41 +1,15 @@
package com.quwan.tt.asmdemoapp

import android.content.Intent
import android.content.res.Resources
import android.os.AsyncTask
import android.os.Build
import android.os.Bundle
import android.os.HandlerThread
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.RequiresApi


class MainActivity : BaseActivity() {

@RequiresApi(Build.VERSION_CODES.Q)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val imageView: ImageView =findViewById(R.id.iv)
imageView.setImageDrawable(getDrawable(R.drawable.ic_launcher_background))
println("====>imageView:${ resources.getResourceEntryName(imageView.id)}")
println("====>tv:${ findViewById<TextView>(R.id.tv).toString()}")
Thread()
object : AsyncTask<Void?, Void?, Void?>() {
override fun doInBackground(vararg params: Void?): Void? {
return null
}

}.execute()
Thread()
Thread()
HandlerThread("test")
// A().test()
val startIntent = Intent(this, TestService::class.java)
startService(startIntent)
}



}
10 changes: 1 addition & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ buildscript {
ext.kotlin_version = "1.4.21"
repositories {
google()
// jcenter()
maven {
url "http://192.168.8.184:8081/repository/all-proxy/"
}
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'digital.wup:android-maven-publish:3.6.2'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -21,10 +17,6 @@ buildscript {
allprojects {
repositories {
google()
// jcenter()
maven {
url "http://192.168.8.184:8081/repository/all-proxy/"
}
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}
}
Expand Down
102 changes: 0 additions & 102 deletions buildSrc/.idea/libraries/Gradle__gradle_api_6_5.xml

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions buildSrc/.idea/libraries/Gradle__gradle_test_kit_6_5.xml

This file was deleted.

11 changes: 0 additions & 11 deletions buildSrc/.idea/libraries/Gradle__groovy_all_1_3_2_5_11.xml

This file was deleted.

Loading

0 comments on commit 5803014

Please sign in to comment.