-
Notifications
You must be signed in to change notification settings - Fork 83
/
example_test.go
68 lines (60 loc) · 3.38 KB
/
example_test.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package androidbinary_test
import (
"encoding/xml"
"fmt"
"os"
"github.com/shogo82148/androidbinary"
"github.com/shogo82148/androidbinary/apk"
)
func ExampleNewXMLFile() {
f, _ := os.Open("testdata/AndroidManifest.xml")
xmlFile, err := androidbinary.NewXMLFile(f)
if err != nil {
panic(err)
}
var v apk.Manifest
dec := xml.NewDecoder(xmlFile.Reader())
dec.Decode(&v)
enc := xml.NewEncoder(os.Stdout)
enc.Indent("", "\t")
enc.Encode(v)
// Output:
// <Manifest package="net.sorablue.shogo.FWMeasure" xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="0" android:compileSdkVersionCodename="" android:versionCode="1" android:versionName="テスト版">
// <application android:allowTaskReparenting="false" android:allowBackup="false" android:backupAgent="" android:debuggable="false" android:description="" android:enabled="false" android:hasCode="false" android:hardwareAccelerated="false" android:icon="@0x7F020000" android:killAfterRestore="false" android:largeHeap="false" android:label="@0x7F040000" android:logo="" android:manageSpaceActivity="" android:name="" android:permission="" android:persistent="false" android:process="" android:restoreAnyVersion="false" android:requiredAccountType="" android:restrictedAccountType="" android:supportsRtl="false" android:taskAffinity="" android:testOnly="false" android:theme="" android:uiOptions="" android:vmSafeMode="false">
// <activity android:theme="" android:name="FWMeasureActivity" android:label="" android:screenOrientation="0">
// <intent-filter>
// <action android:name="android.intent.action.MAIN"></action>
// <category android:name="android.intent.category.LAUNCHER"></category>
// </intent-filter>
// </activity>
// <activity android:theme="" android:name="MapActivity" android:label="" android:screenOrientation="0"></activity>
// <activity android:theme="" android:name="SettingActivity" android:label="" android:screenOrientation=""></activity>
// <activity android:theme="" android:name="PlaceSettingActivity" android:label="" android:screenOrientation=""></activity>
// </application>
// <instrumentation android:name="" android:targetPackage="" android:handleProfiling="false" android:functionalTest="false"></instrumentation>
// <uses-sdk android:minSdkVersion="0" android:targetSdkVersion="0" android:maxSdkVersion="0"></uses-sdk>
// <uses-permission android:name="android.permission.CAMERA" android:maxSdkVersion="0"></uses-permission>
// <uses-permission android:name="android.permission.WAKE_LOCK" android:maxSdkVersion="0"></uses-permission>
// <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="0"></uses-permission>
// <uses-permission android:name="android.permission.INTERNET" android:maxSdkVersion="0"></uses-permission>
// <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" android:maxSdkVersion="0"></uses-permission>
// <uses-permission android:name="android.permission.RECORD_AUDIO" android:maxSdkVersion="0"></uses-permission>
// </Manifest>
}
func ExampleNewTableFile() {
f, err := os.Open("testdata/resources.arsc")
if err != nil {
panic(err)
}
tableFile, err := androidbinary.NewTableFile(f)
if err != nil {
panic(err)
}
val, err := tableFile.GetResource(0x7f040000, &androidbinary.ResTableConfig{})
if err != nil {
panic(err)
}
fmt.Println(val)
// Output:
// FireworksMeasure
}