-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanifest.go
43 lines (36 loc) · 921 Bytes
/
manifest.go
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
package main
import "encoding/xml"
type Manifest struct {
XMLName xml.Name `xml:"manifest"`
Package string `xml:"package,attr"`
Application Application `xml:"application"`
}
type Application struct {
XMLName xml.Name `xml:"application"`
Activities []Activity `xml:"activity"`
}
func (a Application) MainActivity() string {
for _, a := range a.Activities {
for _, i := range a.IntentFilter {
for _, n := range i.Actions {
if n.Name == "android.intent.action.MAIN" {
return a.Name
}
}
}
}
return ""
}
type Activity struct {
XMLName xml.Name `xml:"activity"`
Name string `xml:"name,attr"`
IntentFilter []IntentFilter `xml:"intent-filter"`
}
type IntentFilter struct {
XMLName xml.Name `xml:"intent-filter"`
Actions []Action `xml:"action"`
}
type Action struct {
XMLName xml.Name `xml:"action"`
Name string `xml:"name,attr"`
}