Documentation
¶
Index ¶
- Constants
- func IsResID(s string) bool
- type Bool
- func (v Bool) Bool() (bool, error)
- func (v Bool) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (v Bool) MustBool() bool
- func (v *Bool) SetBool(value bool)
- func (v *Bool) SetResID(resID ResID)
- func (v *Bool) UnmarshalXMLAttr(attr xml.Attr) error
- func (v Bool) WithResTableConfig(config *ResTableConfig) Bool
- func (v Bool) WithTableFile(table *TableFile) Bool
- type ChunkType
- type DataType
- type Flags
- type InputFlags
- type Int32
- func (v Int32) Int32() (int32, error)
- func (v Int32) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (v Int32) MustInt32() int32
- func (v *Int32) SetInt32(value int32)
- func (v *Int32) SetResID(resID ResID)
- func (v *Int32) UnmarshalXMLAttr(attr xml.Attr) error
- func (v Int32) WithResTableConfig(config *ResTableConfig) Bool
- func (v Int32) WithTableFile(table *TableFile) Int32
- type ResChunkHeader
- type ResID
- type ResStringPool
- type ResStringPoolHeader
- type ResStringPoolRef
- type ResStringPoolSpan
- type ResTableConfig
- func (c *ResTableConfig) IsBetterThan(o *ResTableConfig, r *ResTableConfig) bool
- func (c *ResTableConfig) IsLocaleBetterThan(o *ResTableConfig, r *ResTableConfig) bool
- func (c *ResTableConfig) IsLocaleMoreSpecificThan(o *ResTableConfig) int
- func (c *ResTableConfig) IsMoreSpecificThan(o *ResTableConfig) bool
- func (c *ResTableConfig) Locale() string
- func (c *ResTableConfig) Match(settings *ResTableConfig) bool
- type ResTableEntry
- type ResTableHeader
- type ResTablePackage
- type ResTableType
- type ResTableTypeSpec
- type ResValue
- type ResXMLTreeAttrExt
- type ResXMLTreeAttribute
- type ResXMLTreeEndElementExt
- type ResXMLTreeNamespaceExt
- type ResXMLTreeNode
- type ScreenLayout
- type String
- func (v String) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (v String) MustString() string
- func (v *String) SetResID(resID ResID)
- func (v *String) SetString(value string)
- func (v String) String() (string, error)
- func (v *String) UnmarshalXMLAttr(attr xml.Attr) error
- func (v String) WithResTableConfig(config *ResTableConfig) String
- func (v String) WithTableFile(table *TableFile) String
- type TableEntry
- type TableFile
- type TablePackage
- type TableType
- type UIMode
- type XMLFile
Examples ¶
Constants ¶
const NilResStringPoolRef = ResStringPoolRef(0xFFFFFFFF)
NilResStringPoolRef is nil reference for string pool.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bool ¶ added in v0.0.2
type Bool struct {
// contains filtered or unexported fields
}
Bool is a boolean value in XML file. It may be an immediate value or a reference.
func (Bool) Bool ¶ added in v0.0.2
Bool returns the boolean value. It resolves the reference if needed.
func (Bool) MarshalXMLAttr ¶ added in v0.0.2
MarshalXMLAttr implements xml.MarshalerAttr.
func (Bool) MustBool ¶ added in v0.0.2
MustBool is same as Bool, but it panics if it fails to parse the value.
func (*Bool) UnmarshalXMLAttr ¶ added in v0.0.2
UnmarshalXMLAttr implements xml.UnmarshalerAttr.
func (Bool) WithResTableConfig ¶ added in v0.0.2
func (v Bool) WithResTableConfig(config *ResTableConfig) Bool
WithResTableConfig ties ResTableConfig to the Bool.
func (Bool) WithTableFile ¶ added in v0.0.2
WithTableFile ties TableFile to the Bool.
type ChunkType ¶
type ChunkType uint16
ChunkType is a type of a resource chunk.
const ( ResNullChunkType ChunkType = 0x0000 ResStringPoolChunkType ChunkType = 0x0001 ResTableChunkType ChunkType = 0x0002 ResXMLChunkType ChunkType = 0x0003 // Chunk types in RES_XML_TYPE ResXMLFirstChunkType ChunkType = 0x0100 ResXMLStartNamespaceType ChunkType = 0x0100 ResXMLEndNamespaceType ChunkType = 0x0101 ResXMLStartElementType ChunkType = 0x0102 ResXMLEndElementType ChunkType = 0x0103 ResXMLCDataType ChunkType = 0x0104 ResXMLLastChunkType ChunkType = 0x017f // This contains a uint32_t array mapping strings in the string // pool back to resource identifiers. It is optional. ResXMLResourceMapType ChunkType = 0x0180 // Chunk types in RES_TABLE_TYPE ResTablePackageType ChunkType = 0x0200 ResTableTypeType ChunkType = 0x0201 ResTableTypeSpecType ChunkType = 0x0202 )
Chunk types.
type DataType ¶
type DataType uint8
DataType is a type of the data value.
const ( TypeNull DataType = 0x00 TypeReference DataType = 0x01 TypeAttribute DataType = 0x02 TypeString DataType = 0x03 TypeFloat DataType = 0x04 TypeDemention DataType = 0x05 TypeFraction DataType = 0x06 TypeFirstInt DataType = 0x10 TypeIntDec DataType = 0x10 TypeIntHex DataType = 0x11 TypeIntBoolean DataType = 0x12 TypeFirstColorInt DataType = 0x1c TypeIntColorARGB8 DataType = 0x1c TypeIntColorRGB8 DataType = 0x1d TypeIntColorARGB4 DataType = 0x1e TypeIntColorRGB4 DataType = 0x1f TypeLastColorInt DataType = 0x1f TypeLastInt DataType = 0x1f )
The constants for DataType
type InputFlags ¶
type InputFlags uint8
InputFlags are input flags.
const ( MaskKeysHidden InputFlags = 0x03 KeysHiddenAny InputFlags = 0x00 KeysHiddenNo InputFlags = 0x01 KeysHiddenYes InputFlags = 0x02 KeysHiddenSoft InputFlags = 0x03 )
input flags
type Int32 ¶ added in v0.0.2
type Int32 struct {
// contains filtered or unexported fields
}
Int32 is an integer value in XML file. It may be an immediate value or a reference.
func (Int32) Int32 ¶ added in v0.0.2
Int32 returns the integer value. It resolves the reference if needed.
func (Int32) MarshalXMLAttr ¶ added in v0.0.2
MarshalXMLAttr implements xml.MarshalerAttr.
func (Int32) MustInt32 ¶ added in v0.0.2
MustInt32 is same as Int32, but it panics if it fails to parse the value.
func (*Int32) UnmarshalXMLAttr ¶ added in v0.0.2
UnmarshalXMLAttr implements xml.UnmarshalerAttr.
func (Int32) WithResTableConfig ¶ added in v0.0.2
func (v Int32) WithResTableConfig(config *ResTableConfig) Bool
WithResTableConfig ties ResTableConfig to the Bool.
func (Int32) WithTableFile ¶ added in v0.0.2
WithTableFile ties TableFile to the Bool.
type ResChunkHeader ¶
ResChunkHeader is a header of a resource chunk.
type ResStringPool ¶
type ResStringPool struct {
Header ResStringPoolHeader
Strings []string
Styles []ResStringPoolSpan
}
ResStringPool is a string pool resource.
func (*ResStringPool) GetString ¶
func (pool *ResStringPool) GetString(ref ResStringPoolRef) string
GetString returns a string referenced by ref.
type ResStringPoolHeader ¶
type ResStringPoolHeader struct {
Header ResChunkHeader
StringCount uint32
StyleCount uint32
Flags Flags
StringStart uint32
StylesStart uint32
}
ResStringPoolHeader is a chunk header of string pool.
type ResStringPoolRef ¶
type ResStringPoolRef uint32
ResStringPoolRef is a type representing a reference to a string.
type ResStringPoolSpan ¶
type ResStringPoolSpan struct {
FirstChar, LastChar uint32
}
ResStringPoolSpan is a span of style information associated with a string in the pool.
type ResTableConfig ¶
type ResTableConfig struct {
Size uint32
// imsi
Mcc uint16
Mnc uint16
// locale
Language [2]uint8
Country [2]uint8
// screen type
Orientation uint8
Touchscreen uint8
Density uint16
// inout
Keyboard uint8
InputFlags InputFlags
InputPad0 uint8
// screen size
ScreenWidth uint16
ScreenHeight uint16
// version
SDKVersion uint16
MinorVersion uint16
// screen config
ScreenLayout ScreenLayout
UIMode UIMode
SmallestScreenWidthDp uint16
// screen size dp
ScreenWidthDp uint16
ScreenHeightDp uint16
}
ResTableConfig is a configuration of a table.
func (*ResTableConfig) IsBetterThan ¶
func (c *ResTableConfig) IsBetterThan(o *ResTableConfig, r *ResTableConfig) bool
IsBetterThan returns true if c is better than o for the r configuration.
func (*ResTableConfig) IsLocaleBetterThan ¶
func (c *ResTableConfig) IsLocaleBetterThan(o *ResTableConfig, r *ResTableConfig) bool
IsLocaleBetterThan returns true if c is a better locale match than o for the r configuration.
func (*ResTableConfig) IsLocaleMoreSpecificThan ¶
func (c *ResTableConfig) IsLocaleMoreSpecificThan(o *ResTableConfig) int
IsLocaleMoreSpecificThan a positive integer if this config is more specific than o, a negative integer if |o| is more specific and 0 if they're equally specific.
func (*ResTableConfig) IsMoreSpecificThan ¶
func (c *ResTableConfig) IsMoreSpecificThan(o *ResTableConfig) bool
IsMoreSpecificThan returns true if c is more specific than o.
func (*ResTableConfig) Locale ¶
func (c *ResTableConfig) Locale() string
Locale returns the locale of the configuration.
func (*ResTableConfig) Match ¶
func (c *ResTableConfig) Match(settings *ResTableConfig) bool
Match returns true if c can be considered a match for the parameters in settings.
type ResTableEntry ¶
type ResTableEntry struct {
Size uint16
Flags uint16
Key ResStringPoolRef
}
ResTableEntry is the beginning of information about an entry in the resource table.
type ResTableHeader ¶
type ResTableHeader struct {
Header ResChunkHeader
PackageCount uint32
}
ResTableHeader is a header of TableFile.
type ResTablePackage ¶
type ResTablePackage struct {
Header ResChunkHeader
ID uint32
Name [128]uint16
TypeStrings uint32
LastPublicType uint32
KeyStrings uint32
LastPublicKey uint32
}
ResTablePackage is a header of table packages.
type ResTableType ¶
type ResTableType struct {
Header ResChunkHeader
ID uint8
Res0 uint8
Res1 uint16
EntryCount uint32
EntriesStart uint32
Config ResTableConfig
}
ResTableType is a type of a table.
type ResTableTypeSpec ¶
type ResTableTypeSpec struct {
Header ResChunkHeader
ID uint8
Res0 uint8
Res1 uint16
EntryCount uint32
}
ResTableTypeSpec is specification of the resources defined by a particular type.
type ResXMLTreeAttrExt ¶
type ResXMLTreeAttrExt struct {
NS ResStringPoolRef
Name ResStringPoolRef
AttributeStart uint16
AttributeSize uint16
AttributeCount uint16
IDIndex uint16
ClassIndex uint16
StyleIndex uint16
}
ResXMLTreeAttrExt is extended XML tree node for start tags -- includes attribute.
type ResXMLTreeAttribute ¶
type ResXMLTreeAttribute struct {
NS ResStringPoolRef
Name ResStringPoolRef
RawValue ResStringPoolRef
TypedValue ResValue
}
ResXMLTreeAttribute is an attribute of start tags.
type ResXMLTreeEndElementExt ¶
type ResXMLTreeEndElementExt struct {
NS ResStringPoolRef
Name ResStringPoolRef
}
ResXMLTreeEndElementExt is extended XML tree node for element start/end nodes.
type ResXMLTreeNamespaceExt ¶
type ResXMLTreeNamespaceExt struct {
Prefix ResStringPoolRef
URI ResStringPoolRef
}
ResXMLTreeNamespaceExt is extended XML tree node for namespace start/end nodes.
type ResXMLTreeNode ¶
type ResXMLTreeNode struct {
Header ResChunkHeader
LineNumber uint32
Comment ResStringPoolRef
}
ResXMLTreeNode is basic XML tree node.
type ScreenLayout ¶
type ScreenLayout uint8
ScreenLayout describes screen layout.
const ( MaskScreenSize ScreenLayout = 0x0f ScreenSizeAny ScreenLayout = 0x01 ScreenSizeSmall ScreenLayout = 0x02 ScreenSizeNormal ScreenLayout = 0x03 ScreenSizeLarge ScreenLayout = 0x04 ScreenSizeXLarge ScreenLayout = 0x05 MaskScreenLong ScreenLayout = 0x30 ShiftScreenLong = 4 ScreenLongAny ScreenLayout = 0x00 ScreenLongNo ScreenLayout = 0x10 ScreenLongYes ScreenLayout = 0x20 MaskLayoutDir ScreenLayout = 0xC0 ShiftLayoutDir = 6 LayoutDirAny ScreenLayout = 0x00 LayoutDirLTR ScreenLayout = 0x40 LayoutDirRTL ScreenLayout = 0x80 )
ScreenLayout bits
type String ¶ added in v0.0.2
type String struct {
// contains filtered or unexported fields
}
String is a boolean value in XML file. It may be an immediate value or a reference.
func (String) MarshalXMLAttr ¶ added in v0.0.2
MarshalXMLAttr implements xml.MarshalerAttr.
func (String) MustString ¶ added in v0.0.2
MustString is same as String, but it panics if it fails to parse the value.
func (String) String ¶ added in v0.0.2
String returns the string value. It resolves the reference if needed.
func (*String) UnmarshalXMLAttr ¶ added in v0.0.2
UnmarshalXMLAttr implements xml.UnmarshalerAttr.
func (String) WithResTableConfig ¶ added in v0.0.2
func (v String) WithResTableConfig(config *ResTableConfig) String
WithResTableConfig ties ResTableConfig to the Bool.
func (String) WithTableFile ¶ added in v0.0.2
WithTableFile ties TableFile to the Bool.
type TableEntry ¶
type TableEntry struct {
Key *ResTableEntry
Value *ResValue
Flags uint32
}
TableEntry is a entry in a resource table.
type TableFile ¶
type TableFile struct {
// contains filtered or unexported fields
}
TableFile is a resource table file.
func NewTableFile ¶
NewTableFile returns new TableFile.
Example ¶
package main
import (
"fmt"
"os"
"github.com/shogo82148/androidbinary"
)
func main() {
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
func (*TableFile) GetResource ¶
func (f *TableFile) GetResource(id ResID, config *ResTableConfig) (interface{}, error)
GetResource returns a resource referenced by id.
func (*TableFile) GetString ¶
func (f *TableFile) GetString(ref ResStringPoolRef) string
GetString returns a string referenced by ref.
type TablePackage ¶
type TablePackage struct {
Header ResTablePackage
TypeStrings *ResStringPool
KeyStrings *ResStringPool
TableTypes []*TableType
}
TablePackage is a table package.
type TableType ¶
type TableType struct {
Header *ResTableType
Entries []TableEntry
}
TableType is a collection of resource entries for a particular resource data type.
type UIMode ¶
type UIMode uint8
UIMode describes UI mode.
const ( MaskUIModeType UIMode = 0x0f UIModeTypeAny UIMode = 0x01 UIModeTypeNormal UIMode = 0x02 UIModeTypeDesk UIMode = 0x03 UIModeTypeCar UIMode = 0x04 MaskUIModeNight UIMode = 0x30 ShiftUIModeNight = 4 UIModeNightAny UIMode = 0x00 UIModeNightNo UIMode = 0x10 UIModeNightYes UIMode = 0x20 )
UIMode bits
type XMLFile ¶
type XMLFile struct {
// contains filtered or unexported fields
}
XMLFile is an XML file expressed in binary format.
func NewXMLFile ¶
NewXMLFile returns a new XMLFile.
Example ¶
package main
import (
"encoding/xml"
"os"
"github.com/shogo82148/androidbinary"
"github.com/shogo82148/androidbinary/apk"
)
func main() {
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: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=""> <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=""></activity> <activity android:theme="" android:name="SettingActivity" android:label=""></activity> <activity android:theme="" android:name="PlaceSettingActivity" android:label=""></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> </Manifest>
func (*XMLFile) Decode ¶ added in v0.0.2
func (f *XMLFile) Decode(v interface{}, table *TableFile, config *ResTableConfig) error
Decode decodes XML file and stores the result in the value pointed to by v. To resolve the resource references, Decode also stores default TableFile and ResTableConfig in the value pointed to by v.
func (*XMLFile) GetString ¶
func (f *XMLFile) GetString(ref ResStringPoolRef) string
GetString returns a string referenced by ref.