问题描述
[GTS_7.01]GtsInstallPackagesWhitelistDeviceTestCases:com.google.android.installpackageswhitelist.gts.GtsInstallPackagesWhitelistDeviceTest#testInstallerPackagesAgainstWhitelist failed
com.google.android.installpackageswhitelist.gts.GtsInstallPackagesWhitelistDeviceTest#testInstallerPackagesAgainstWhitelist
java.lang.AssertionError: Package com.mediatek.location.lppe.main permission mismatch.. Actual: 0
java.lang.AssertionError: Package com.mediatek.location.lppe.main permission mismatch.. Actual: 0
解决方案
这个case fail 的原因是GTS7.0_R1 的测试逻辑有变化,新增了测试逻辑,是查找系统中APP 的manifest 中如果未申请android.permission.INSTALL_PACKAGES 权限,
但是grant 到了此权限,gts 即会fail. 而系统中存在share uid 的状况,只要share uid 组的其中一个APP grant了android.permission.INSTALL_PACKAGES 权限,share uid 组
中的其他module 都会grant 到此权限,因此gts log 中打到的package name 并不一定是真正错误申请权限的模块,需要检查同一个share uid 组的所有APP,是否有违背gts rule.
举例来说:
build userdebug 版本
adb root
adb pull /data/system/packages.xml(user 版本无权限pull)
看到/data/system/packages.xml 中share user android.uid.system 1000 有申请 android.permission.INSTALL_PACKAGES 权限
<shared-user name="android.uid.system" userId="1000">
<sigs count="1" schemeVersion="3">
<cert index="0" />
</sigs>
<perms>
....
<item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
</perms>
</shared-user>
意味着平台里 有一个APP 的manifest 中满足下面2个条件
1 |
<<span class="n">uses</span>-<span class="n">permission</span> <span class="n">android</span>:<strong>name=</strong><span class="s">"android.permission.INSTALL_PACKAGES"</span> /> |
1 |
android:<strong>sharedUserId =</strong> <span class="s">"android.uid.system"</span> |
只要有一个share uid 为system 的ap 有申请
android.permission.INSTALL_PACKAGES
其他所有的system uid app 都有拿到此权限。
这题中的gts log 中报出来的 com.mediatek.location.lppe.main 其实并没有申请此权限,只是因为share uid 1000, 连带着 grant了此权限。
我们在/data/system/packages.xml 中搜索关键字 android.permission.INSTALL_PACKAGES|package name,搜到了以下 grant 了此权限的APP,
原则上需要review 每个APP 的manifest,但是因为MTK 公版gts 是pass 的,客户可以重点关注客制化的 APP 是否有符合条件即可。
例如有找到 com.redstone.ota.ui,移除APP 中INSTALL_PACKAGES 权限的申请,然后rebuild 检查 /data/system/packages.xml, 确保 <shared-user name="android.uid.system" userId="1000"> 中没有grant INSTALL_PACKAGES,gts 即可pass
Line 1040: <package name="com.mediatek.location.lppe.main" codePath="/system/app/LPPeService" nativeLibraryPath="/system/app/LPPeService/lib" publicFlags="805846597" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="1" sharedUserId="1000" isOrphaned="true">
Line 1064: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 1342: <package name="com.mediatek.simprocessor" codePath="/system/priv-app/MtkSimProcessor" nativeLibraryPath="/system/priv-app/MtkSimProcessor/lib" publicFlags="805879365" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 1366: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 1918: <package name="com.redstone.ota.ui" codePath="/system/app/Rsota" nativeLibraryPath="/system/app/Rsota/lib" publicFlags="805879365" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="18" sharedUserId="1000" isOrphaned="true">
Line 1942: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 2086: <package name="com.android.vending" codePath="/system/priv-app/Phonesky" nativeLibraryPath="/system/priv-app/Phonesky/lib" primaryCpuAbi="armeabi-v7a" publicFlags="944422469" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="81452000" userId="10026" isOrphaned="true">
Line 2099: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 2343: <package name="android" codePath="/system/framework/framework-res.apk" nativeLibraryPath="/system/lib/framework-res" publicFlags="810073609" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 2367: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 2481: <package name="com.mediatek.connectivity" codePath="/system/priv-app/CDS_INFO" nativeLibraryPath="/system/priv-app/CDS_INFO/lib" publicFlags="805879365" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="1" sharedUserId="1000" isOrphaned="true">
Line 2505: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 2970: <package name="com.mediatek.providers.drm" codePath="/system/app/DrmProvider" nativeLibraryPath="/system/app/DrmProvider/lib" publicFlags="805846597" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="28" sharedUserId="1000" isOrphaned="true">
Line 2994: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 3178: <package name="com.android.providers.settings" codePath="/system/priv-app/MtkSettingsProvider" nativeLibraryPath="/system/priv-app/MtkSettingsProvider/lib" publicFlags="806010373" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 3202: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 3325: <package name="com.mediatek.batterywarning" codePath="/system/app/BatteryWarning" nativeLibraryPath="/system/app/BatteryWarning/lib" publicFlags="810073669" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="28" sharedUserId="1000" isOrphaned="true">
Line 3349: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 3533: <package name="com.android.inputdevices" codePath="/system/priv-app/InputDevices" nativeLibraryPath="/system/priv-app/InputDevices/lib" publicFlags="805879301" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 3557: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 3711: <package name="com.mediatek" codePath="/system/framework/mediatek-res" nativeLibraryPath="/system/framework/mediatek-res/lib" publicFlags="540161" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 3735: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 3892: <package name="com.mediatek.duraspeed" codePath="/system/priv-app/DuraSpeed" nativeLibraryPath="/system/priv-app/DuraSpeed/lib" publicFlags="810073605" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="2" sharedUserId="1000" isOrphaned="true">
Line 3916: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 4518: <package name="com.mediatek.nlpservice" codePath="/system/app/NlpService" nativeLibraryPath="/system/app/NlpService/lib" publicFlags="805846597" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="1" sharedUserId="1000" isOrphaned="true">
Line 4542: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 4656: <package name="com.android.server.telecom" codePath="/system/priv-app/MtkTelecom" nativeLibraryPath="/system/priv-app/MtkTelecom/lib" publicFlags="810040901" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 4680: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 4817: <package name="com.android.keychain" codePath="/system/app/KeyChain" nativeLibraryPath="/system/app/KeyChain/lib" publicFlags="805846597" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="28" sharedUserId="1000" isOrphaned="true">
Line 4841: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 5030: <package name="com.google.android.packageinstaller" codePath="/system/priv-app/GooglePackageInstaller" nativeLibraryPath="/system/priv-app/GooglePackageInstaller/lib" publicFlags="810040901" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" userId="10045" isOrphaned="true">
Line 5038: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 5672: <package name="com.android.managedprovisioning" codePath="/system/priv-app/ManagedProvisioning" nativeLibraryPath="/system/priv-app/ManagedProvisioning/lib" publicFlags="944291333" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" userId="10021" isOrphaned="true">
Line 5680: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 5710: <package name="com.mediatek.atci.service" codePath="/system/app/AtciService" nativeLibraryPath="/system/app/AtciService/lib" publicFlags="805879365" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="1" sharedUserId="1000" isOrphaned="true">
Line 5734: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 5848: <package name="com.mediatek.thermalmanager" codePath="/vendor/app/MTKThermalManager" nativeLibraryPath="/vendor/app/MTKThermalManager/lib" publicFlags="805879365" privateFlags="262144" ft="16c647647e8" it="16c647647e8" ut="16c647647e8" version="1" sharedUserId="1000" isOrphaned="true">
Line 5872: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 5986: <package name="com.mediatek.callrecorder" codePath="/system/priv-app/CallRecorderService" nativeLibraryPath="/system/priv-app/CallRecorderService/lib" publicFlags="805879365" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 6010: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 6233: <package name="com.payjoy.access" codePath="/system/priv-app/PayJoyAccess" nativeLibraryPath="/system/priv-app/PayJoyAccess/lib" publicFlags="810073669" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="120" sharedUserId="1000" isOrphaned="true">
Line 6257: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 6616: <package name="com.android.settings" codePath="/system/priv-app/MtkSettings" nativeLibraryPath="/system/priv-app/MtkSettings/lib" publicFlags="944258629" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 6640: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 6899: <package name="com.android.shell" codePath="/system/priv-app/Shell" nativeLibraryPath="/system/priv-app/Shell/lib" publicFlags="805879365" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="2000" isOrphaned="true">
Line 6918: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 7014: <package name="com.android.wallpaperbackup" codePath="/system/app/WallpaperBackup" nativeLibraryPath="/system/app/WallpaperBackup/lib" publicFlags="872988165" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="28" sharedUserId="1000" isOrphaned="true">
Line 7038: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 7196: <package name="com.android.location.fused" codePath="/system/priv-app/FusedLocation" nativeLibraryPath="/system/priv-app/FusedLocation/lib" publicFlags="805879365" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 7220: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 7334: <package name="com.android.deskclock" codePath="/system/priv-app/MtkDeskClock" nativeLibraryPath="/system/priv-app/MtkDeskClock/lib" publicFlags="810040901" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="28" sharedUserId="1000" isOrphaned="true">
Line 7358: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 7592: <package name="com.mediatek.location.mtknlp" codePath="/system/app/MtkNlp" nativeLibraryPath="/system/app/MtkNlp/lib" publicFlags="805846597" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="28" sharedUserId="1000" isOrphaned="true">
Line 7616: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 7762: <package name="com.mediatek.sensorhub.ui" codePath="/system/app/SensorHub" nativeLibraryPath="/system/app/SensorHub/lib" publicFlags="805879365" privateFlags="0" ft="16c64764018" it="16c64764018" ut="16c64764018" version="2" sharedUserId="1000" isOrphaned="true">
Line 7786: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />
Line 7989: <package name="com.mediatek.dataprotection" codePath="/system/priv-app/DataProtection" nativeLibraryPath="/system/priv-app/DataProtection/lib" publicFlags="810073605" privateFlags="8" ft="16c64764400" it="16c64764400" ut="16c64764400" version="1" sharedUserId="1000" isOrphaned="true">
Line 8013: <item name="android.permission.INSTALL_PACKAGES" granted="true" flags="0" />