waitForOnCreate waits for android.app.Application.onCreate to be called, and then suspends all threads.
(ctx context.Context, conn *jdwp.Connection)
| 59 | // waitForOnCreate waits for android.app.Application.onCreate to be called, and |
| 60 | // then suspends all threads. |
| 61 | func waitForOnCreate(ctx context.Context, conn *jdwp.Connection) (*jdwp.EventMethodEntry, error) { |
| 62 | app, err := conn.GetClassBySignature("Landroid/app/Application;") |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | |
| 67 | constructor, err := conn.GetClassMethod(app.ClassID(), "<init>", "()V") |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | |
| 72 | log.I(ctx, " Waiting for Application.<init>()") |
| 73 | initEntry, err := conn.WaitForMethodEntry(ctx, app.ClassID(), constructor.ID) |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | |
| 78 | var entry *jdwp.EventMethodEntry |
| 79 | err = jdbg.Do(conn, initEntry.Thread, func(j *jdbg.JDbg) error { |
| 80 | class := j.This().Call("getClass").AsType().(*jdbg.Class) |
| 81 | var onCreate jdwp.Method |
| 82 | for class != nil { |
| 83 | var err error |
| 84 | onCreate, err = conn.GetClassMethod(class.ID(), "onCreate", "()V") |
| 85 | if err == nil { |
| 86 | break |
| 87 | } |
| 88 | class = class.Super() |
| 89 | } |
| 90 | if class == nil { |
| 91 | return fmt.Errorf("Couldn't find Application.onCreate") |
| 92 | } |
| 93 | log.I(ctx, " Waiting for %v.onCreate()", class.String()) |
| 94 | out, err := conn.WaitForMethodEntry(ctx, class.ID(), onCreate.ID) |
| 95 | if err != nil { |
| 96 | return err |
| 97 | } |
| 98 | entry = out |
| 99 | return nil |
| 100 | }) |
| 101 | if err != nil { |
| 102 | return nil, err |
| 103 | } |
| 104 | |
| 105 | return entry, nil |
| 106 | } |
| 107 | |
| 108 | // waitForVulkanLoad for android.app.ApplicationLoaders.getClassLoader to be called, |
| 109 | // and then suspends the thread. |
no test coverage detected