Closed codeskyblue closed 4 years ago
It is a ResID
.
You can get the real value by TableFile.GetResource, instead of the apk package.
Any field may be a RedID
, so we need a new interface to handle it.
But I have no idea. I'm thinking a solution now... 🤔
What about create a new Type BoolField
type BoolField struct {
value string
}
func (f *BoolField) UnmarshalXMLAttr(attr xml.Attr) error {
f.value = attr.Value
return nil
}
func (f *BoolField) Bool(table *TableFile) (bool, error) {
if (strings.HasPrefix(f.value, "@") {
if (table != nil){
return table.GetResource(f.value)
}
}
return strconv.ParseBool(f.value)
}
func (f *BoolField) MustBool(table *TableFile) bool {
v, err := f.Bool()
if err != nil {
panic(err)
}
return v
}
code is not tested
ref: https://stackoverflow.com/questions/24980166/golang-unmarshalxmlattr-in-encoding-xml
I implemented Proof of Concept for resolving this issue. #28 It looks that it works with momo.apk. could you check it please?
package main
import (
"fmt"
"github.com/shogo82148/androidbinary/apk"
)
func main() {
apkFile, err := apk.OpenFile("momo.apk")
if err != nil {
panic(err)
}
fmt.Println(apkFile.Manifest().App.HardwareAccelerated.Bool())
// Output:
// true, nil
}
I tested the it is working. Awesome. There is a method need to implement UnmarshalXMLAttr
The demo can see here: https://play.golang.org/p/IlzpKQ8ehn
released v0.0.2 https://github.com/shogo82148/androidbinary/releases/tag/v0.0.2 try it.
API changes, why not change version to 1.0.0
because androidbinary have not reached v1.0.0 yet. v0.x.y versions may have broken changes.
do you use androidbinary in production? if yes, I will bump up to v1.0.0 soon.
That's fine, v0.0.2 is fine to me, even through I have already used in production. I like this library very much.
Thanks! Released v1.0.0 now https://github.com/shogo82148/androidbinary/releases/tag/v1.0.0
Can you remove tag v0.0.2
Thanks
The bool filed might be none of "true" or "false", this happends in apk: https://www.immomo.com/download/momo_apk
AndroidManifest.xml.txt
Ref: https://github.com/openatx/uiautomator2/issues/393