Documentation ¶
Index ¶
- Constants
- func IsResID(s string) bool
- type ChunkType
- type DataType
- type Flags
- type InputFlags
- 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 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 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 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 resrouce.
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 TableEntry ¶
type TableEntry struct { Key *ResTableEntry Value *ResValue Flags uint32 }
TableEntry is a entry in a recource table.
type TableFile ¶
type TableFile struct {
// contains filtered or unexported fields
}
TableFile is a resrouce 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 resrouce 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" versionCode="1" versionName="テスト版"> <application allowTaskReparenting="false" allowBackup="false" backupAgent="" debuggable="false" description="" enabled="false" hasCode="false" hardwareAccelerated="false" icon="@0x7F020000" killAfterRestore="false" largeHeap="false" label="@0x7F040000" logo="" manageSpaceActivity="" name="" permission="" persistent="false" process="" restoreAnyVersion="false" requiredAccountType="" restrictedAccountType="" supportsRtl="false" taskAffinity="" testOnly="false" theme="" uiOptions="" vmSafeMode="false"> <activity theme="" name="FWMeasureActivity" label=""> <intent-filter> <action name="android.intent.action.MAIN"></action> <category name="android.intent.category.LAUNCHER"></category> </intent-filter> </activity> <activity theme="" name="MapActivity" label=""></activity> <activity theme="" name="SettingActivity" label=""></activity> <activity theme="" name="PlaceSettingActivity" label=""></activity> </application> <instrumentation name="" targetPackage="" handleProfiling="false" functionalTest="false"></instrumentation> <uses-sdk minSdkVersion="0" targetSdkVersion="0" maxSdkVersion="0"></uses-sdk> </Manifest>
func (*XMLFile) GetString ¶
func (f *XMLFile) GetString(ref ResStringPoolRef) string
GetString returns a string referenced by ref.