File tree 6 files changed +35
-15
lines changed
6 files changed +35
-15
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,6 @@ language: go
2
2
sudo : false
3
3
4
4
go :
5
- - ' 1.3.x'
6
- - ' 1.4.x'
7
- - ' 1.5.x'
8
- - ' 1.6.x'
9
- - ' 1.7.x'
10
5
- ' 1.8.x'
11
6
- ' 1.9.x'
12
7
- ' 1.10.x'
Original file line number Diff line number Diff line change @@ -108,20 +108,30 @@ func (k *Apk) PackageName() string {
108
108
return k .manifest .Package
109
109
}
110
110
111
- // MainActivty returns the name of the main activity.
111
+ func isMainIntentFilter (intent ActivityIntentFilter ) bool {
112
+ if intent .Action .Name != "android.intent.action.MAIN" {
113
+ return false
114
+ }
115
+ for _ , category := range intent .Categories {
116
+ if category .Name == "android.intent.category.LAUNCHER" {
117
+ return true
118
+ }
119
+ }
120
+ return false
121
+ }
122
+
123
+ // MainActivity returns the name of the main activity.
112
124
func (k * Apk ) MainActivity () (activity string , err error ) {
113
125
for _ , act := range k .manifest .App .Activities {
114
126
for _ , intent := range act .IntentFilters {
115
- if intent .Action .Name == "android.intent.action.MAIN" &&
116
- intent .Category .Name == "android.intent.category.LAUNCHER" {
127
+ if isMainIntentFilter (intent ) {
117
128
return act .Name , nil
118
129
}
119
130
}
120
131
}
121
132
for _ , act := range k .manifest .App .ActivityAliases {
122
133
for _ , intent := range act .IntentFilters {
123
- if intent .Action .Name == "android.intent.action.MAIN" &&
124
- intent .Category .Name == "android.intent.category.LAUNCHER" {
134
+ if isMainIntentFilter (intent ) {
125
135
return act .TargetActivity , nil
126
136
}
127
137
}
Original file line number Diff line number Diff line change @@ -18,15 +18,15 @@ func TestGetIcon(t *testing.T) {
18
18
19
19
label , err := apk .Label (nil )
20
20
assert .NoError (t , err )
21
- assert .Equal (t , label , "HelloWorld" )
21
+ assert .Equal (t , "HelloWorld" , label )
22
22
t .Log ("app label:" , label )
23
23
24
- assert .Equal (t , apk . PackageName (), "com.example.helloworld" )
24
+ assert .Equal (t , "com.example.helloworld" , apk . PackageName () )
25
25
26
26
manifest := apk .Manifest ()
27
27
assert .Equal (t , manifest .SDK .Target , 24 )
28
28
29
29
mainActivity , err := apk .MainActivity ()
30
30
assert .NoError (t , err )
31
- assert .Equal (t , mainActivity , "com.example.helloworld.MainActivity" )
31
+ assert .Equal (t , "com.example.helloworld.MainActivity" , mainActivity )
32
32
}
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ type ActivityCategory struct {
20
20
21
21
// ActivityIntentFilter is an intent filter of an activity.
22
22
type ActivityIntentFilter struct {
23
- Action ActivityAction `xml:"action"`
24
- Category ActivityCategory `xml:"category"`
23
+ Action ActivityAction `xml:"action"`
24
+ Categories [] ActivityCategory `xml:"category"`
25
25
}
26
26
27
27
// AppActivity is an activity in an application.
Original file line number Diff line number Diff line change
1
+ module github.com/shogo82148/androidbinary
2
+
3
+ require (
4
+ github.com/pkg/errors v0.8.1
5
+ github.com/stretchr/testify v1.3.0
6
+ )
Original file line number Diff line number Diff line change
1
+ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
2
+ github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
3
+ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I =
4
+ github.com/pkg/errors v0.8.1 /go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0 =
5
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
6
+ github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
7
+ github.com/stretchr/objx v0.1.0 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
8
+ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q =
9
+ github.com/stretchr/testify v1.3.0 /go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI =
You can’t perform that action at this time.
0 commit comments