我正在尝试打印Python中Android Manifest文件中使用的所有权限,功能,最小sdk版本,服务,内容提供商,广播接收器。 我编写了一个可以打印权限和功能的代码,但是在打印服务和内容提供程序时它显示为空值。
这是我的Android Manifest Code:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto" package="com.nianticlabs.pokemongo"
platformBuildVersionCode="23" platformBuildVersionName="6.0-2704002">
<supports-screens android:anyDensity="true" android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:xlargeScreens="true"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application android:banner="@drawable/app_banner"
android:debuggable="false" android:icon="@drawable/app_icon"
android:isGame="false" android:label="@string/app_name"
android:theme="@style/UnityThemeSelector">
<activity
android:configChanges="fontScale|keyboard|
keyboardHidden|locale|mcc|mnc|navigati
on|orientation|screenLayout|screenSize|
smallestScreenSize|touchscreen|uiMode"
android:label="@string/app_name" android:launchMode="singleTask"
android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity"
android:value="true"/>
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik"
android:value="true"/>
</activity>
<activity android:name="com.google.nianticproject.platform.AccountsActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar"/>
<service android:name="com.upsight.android.analytics.internal.DispatcherService"/>
<meta-data android:name="com.upsight.extension.analytics" android:value="com.upsight.android.UpsightAnalyticsExtension"/>
<meta-data android:name="com.upsight.core" android:value="com.upsight.android.internal.CoreComponentFactory"/>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<meta-data android:name="com.upsight.extension.googleadvertisingid" android:value="com.upsight.android.UpsightGoogleAdvertisingIdExtension"/>
<service android:name="com.upsight.android.googlepushservices.internal.PushIntentService"/>
<service android:name="com.upsight.android.googlepushservices.internal.PushClickIntentService"/>
<meta-data android:name="com.upsight.extension.googlepushservices" android:value="com.upsight.android.UpsightGooglePushServicesExtension"/>
<meta-data android:name="com.upsight.extension.managedvariables" android:value="com.upsight.android.UpsightManagedVariablesExtension"/>
<meta-data android:name="com.upsight.extension.marketing" android:value="com.upsight.android.UpsightMarketingExtension"/>
<activity android:name="com.nianticlabs.nia.account.AccountsActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar"/>
<activity android:exported="false" android:name="com.nianticlabs.nia.iap.PurchaseActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<service android:exported="false" android:name="com.nianticlabs.nia.useractivity.ActivityRecognitionService"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent"/>
<activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" android:theme="@style/Theme.IAPTheme"/>
<service android:enabled="true" android:name="com.nianticproject.holoholo.sfida.service.SfidaService"/>
<meta-data android:name="com.upsight.session_callbacks" android:value="com.upsight.android.unity.UnitySessionCallbacks"/>
<receiver android:name="com.upsight.android.googlepushservices.internal.PushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.nianticlabs.pokemongo"/>
</intent-filter>
</receiver>
<provider android:authorities="com.nianticlabs.pokemongo.upsight" android:enabled="true" android:exported="false" android:name="com.upsight.android.internal.persistence.ContentProvider"/>
<meta-data android:name="com.upsight.sdk_plugin" android:value="4.0.7"/>
<meta-data android:name="com.upsight.app_token" android:value="a9cc12f87adc420baf964f187672ecb4"/>
<meta-data android:name="com.upsight.public_key" android:value="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyYKX0nb1ezY2KLkAl0tuWn2AZ0PfS2NF2BSM0T2OLCJM/H8Siyz1+OTvDWo1w+psbz6ugjTOaBGtkTRI1uikGcu32mhW2I4c9XUUkx1AYlC3wwiqnWZMvMKthp1yaKzrTsqhZzwJ6DvgZHUf1IPIkoxXoGmfyYNRI3QcpW5Uwa1dsZr5YeG8fwC53hyukOutt6PRqwDXQCsyCd/PawjUJZT6oxDFYYZ8a/11OIstlS4jXnQQ+k/f5HV5b8+ITiKhqXuNVsByPZqSIwi5T8pwJan7Rk8OCVImSkgUmWLcmlPcoL1UaF+vMZXZYhk1hM765IUw++7Dw2qvKVi4yl+giwIDAQAB"/>
<meta-data android:name="com.upsight.gcm" android:value="com.nianticlabs.pokemongo.GCM_SENDER_ID"/>
<meta-data android:name="com.upsight.user_attribute.player_level" android:value="0"/>
<meta-data android:name="com.upsight.user_attribute.player_xp" android:value="0"/>
<meta-data android:name="com.upsight.user_attribute.player_avatar" android:value="0"/>
<meta-data android:name="com.upsight.user_attribute.pokemon_count" android:value="0"/>
<meta-data android:name="com.upsight.user_attribute.item_count" android:value="0"/>
<meta-data android:name="com.upsight.user_attribute.pokecoin" android:value="0"/>
</application>
<uses-feature android:glEsVersion="0x00020000"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>
<uses-feature android:name="android.hardware.touchscreen"/>
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
<permission android:name="com.nianticlabs.pokemongo.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.nianticlabs.pokemongo.permission.C2D_MESSAGE"/>
<uses-feature android:name="android.hardware.location.gps" android:required="false"/>
<uses-feature android:name="android.hardware.location" android:required="false"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
这是Python代码:
import xml.etree.ElementTree as ET
root = ET.parse("AndroidManifest.xml").getroot()
var = root.findall("uses-permission")
#print(var)
n=len(var)
for i in range(n):
print(var[i].attrib)
var1 = root.findall("uses-feature")
#print(var1)
m=len(var1)
for j in range(m):
print(var1[j].attrib)
var2 = root.findall("application")
#print(var2)
a=len(var2)
for k in range(a):
print(var2[k].attrib)
var3 = root.findall("service")
print(var3)
b=len(var3)
for v in range(b):
print(var3[v].attrib)
此代码可以打印Manifest文件使用的权限,功能,但不能打印使用的服务。可能是什么问题?我在哪里弄错了?