内容提要PackageParser和AndroidManifest.xml.以供备忘和参考。声明仅限学习交流,禁止商业用途。转载需注明出处。版本记录Date Ver Note2011-04-18 0.1 Draft. zcatt, Beijing 转自
http://blog.chinaunix.net/space.php?uid=433806&do=blog&id=249321 apk包中的AndroidManifest.xml文件包含了package的各种描述信息. 分析和获取这些信息的工作是由PackageParser完成的. 这里简述之. 首先我们先罗列AndroidManifest.xml文件的简要结构, 其次在大致整理PackageParser的逻辑.AndroidManifest.xml的简要结构====================================AndroidManifest.xml的内容在frameworks/base/core/res/res/values/attrs_manifest.xml中定义. 这里简要罗列, 按照层进关系, xml element用 "tagName, Name"的形式标记, 对于某些xml element的重要属性(attribute), 用"attr NAME"标记.AndridManifest.xml manifest, AndroidManifest attr versionCode attr versionName attr sharedUserId attr sharedUserLabel attr installLocation permission, AndroidManifestPermission attr name, label, icon attr permissionGroup attr protectionLevel permission-group, AndroidManifestPermissionGroup attr name, label, icon permission-tree, AndroidManifestPermissionTree attr name, label, icon uses-sdk, AndroidManifestUsesSdk uses-permission, AndroidManifestUsesPermission attr name uses-configuration, AndroidManifestUsesConfiguration attr reqTouchScreen attr requKeyboardType attr reqHardKeyboard attr reqNavigation attr reqFiveWayNav application, AndroidManifestApplication attr name, label, icon attr permission attr process attr taskAffinity attr persistent service, AndroidManifestService attr name, label, icon attr permission attr process attr enabled attr exported receiver, AndroidManifestReceiver attr name, label, icon attr permission attr process attr enabled attr exported provider, AndroidManifestProvider attr name, label, icon attr process, authorities, syncable attr readPermission, writePermission, grantUriPermissions attr permission attr mulitprocess attr enabled attr exported grant-uri-permission, AndroidManifestGrantUriPermission attr path, pathPrefix, pathPattern path-permission, AndroidManifestPathPermission attr path, pathPrefix, pathPattern attr permission, readPermission, writePermission activity, AndroidManifestActivity attr name, label, icon attr theme, launchMode, screenOrientation attr configChanges, permission, multiprocess attr process, taskAffinity, allowTaskReparenting attr finishOnTaskLaunch, finishOnCloseSystemDialogs attr clearTaskOnLauch, noHistory attr alwaysRetainTaskState, stateNotNeeded attr excludeFromRecents attr enabled, exported attr windowSoftInputMode activity-alias, AndroidManifestActivityAlias attr name, label, icon attr targetActivity attr permission attr enabled, exported uses-library, AndroidManifestUsesLibrary attr name attr required instrumentation, AnroidManifestInstrumentation attr name, label, icon attr targetPackage, handleProfiling attr functionalTest uses-feature, AndroidManifestUsesFeature attr glEsVersion attr name attr required supports-screens, AndroidManifestSupportsScreens attr smallScreens, normalScreens, largeScreens attr resizeable, anyDensity protected-broadcast, AndroidManifestProtectedBroadcast attr name adopt-permissions, AndroidManifestOriginalPackage attr name还有几个特别的xml element, 可以有多个parent element. application activity, receiver, provider, service permission, permissionGroup instrumentation meta-data, AndroidManifestMetaData attr name, value, resource activity, receiver, service intent-filter, AndroidManifestIntentFilter attr label, icon, priority action, AndroidManifestAction attr name data, AndroidManifestData attr mimeType, scheme, host attr port, path, pathPrefix attr pathPattern category, AndroidManifestCategory attr name intent, Intent attr action, data, mimeType attr targetPackage, targetClass category, IntentCategory attr name extra, Extra attr name, valuePackageParser的逻辑====================================PackageParser的parsePackage()方法会读取apk包中的AndroidManifest.xml文件, 调用各子par***XX()方法, 解析出包信息. 同时, PackageParser定义了一些class, 容纳这些解析得到的信息. 下面是对应的关系.class xml elements------------- --------------------------------------Package packagePermission permission, permission-treePermissionGroup permission-groupActivity activity, activity-alias, receiverService serviceProvider providerInstrumentation instrumentationActivityIntentInfo intent-filter @ activity or receiverServiceIntentInfo intent-filter @ servicePacakgeParser的结果主要被PackageManagerService使用.
阅读(3777) | 评论(0) | 转发(0) |