# CTS-DEBUG CtsAppSecurityHostTestCases AdoptableHostTest#testApps
这个case 其实是和testEjected 是一样的,如果出现了和我上一篇一样的问题(Expected private volume; found [private:179,66 unmountable 02f80bf6-ac2d-4afa-99be-6869b479334c, private mounted null]),可以参考上一篇解决方案。这个其实是一整块的case ---AdoptableHostTest 可以单跑这个Test 测试该项
run cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AdoptableHostTest
可是这次报错的内容不一样,原因是这样的,不插实体sdcard 跑该case:在修改动态分区前
case 是pass的,修改动态分区后就不行了。
来看问题
cts AdoptableHostTest#testApps test fail log 如下
android.appsecurity.cts.AdoptableHostTest#testApps
java.lang.AssertionError: Expected success string but found Failure [-6]
at android.appsecurity.cts.AdoptableHostTest.assertSuccess(AdoptableHostTest.java:385)
at android.appsecurity.cts.AdoptableHostTest.testApps(AdoptableHostTest.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
调查过程中发现测试该case的时候会创建虚拟sdcard,然后转成内部存储,然后会将原来内部存储的数据移到虚拟的sdcard中。
因为在修改动态分区前的版本是ok的,所以参考动态分区修改的文件内容。
最后发现和分区表 fstab有关
我们设备是non ab的,非动态分区使用的文件为
device\qcom\msm8953_64\fstabs-4.9\fstab_non_AB_variant.qti
动态分区使用的文件是
device\qcom\msm8953_64\fstabs-4.9\fstab_non_AB_dynamic_partition_variant.qti
对比两个文件的差异,考虑到case测试的时候会移动数据,用户数据是放在userdata下的
fstab中 sdcard 使用的是**encryptable=footer**
/devices/soc/7864900.sdhci/mmc_host* /storage/sdcard1 vfat nosuid,nodev wait,voldmanaged=sdcard1:auto,noemulatedsd,encryptable=footer
动态分区前 userdata使用的是**forceencrypt=footer**
/dev/block/bootdevice/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc,discard wait,forceencrypt=footer,quota,reservedsize=128M
动态分区后userdata使用的是**fileencryption=ice**
/dev/block/bootdevice/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc,discard latemount,wait,formattable,fileencryption=ice,quota,reservedsize=128M,checkpoint=block
这两个加密方式不一样,所以尝试修改动态分区的fstab文件**forceencrypt=footer,fileencryption=ice**
/dev/block/bootdevice/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc,discard latemount,wait,formattable,forceencrypt=footer,fileencryption=ice,quota,reservedsize=128M,checkpoint=block
修改后在跑case 测试pass
注意啦
修改这种方式虽然能跑过case AdoptableHostTest 可是如果你是Android Q 以上的版本,测试CtsSecurityTestCases的时候会报错,原因就是AndroidQ 以上的版本需要用FBE加密 fileencryption=ice。上面那种修改方式,在forceencrypt,fileencryption两个都存在的时候通过查看 ro.crypto.type=block
if ("file".equals(PropertyUtil.getProperty("ro.crypto.type"))) {
Log.d(TAG, "Device is encrypted with file-based encryption.");
// TODO(b/111311698): If we're able to determine if the hardware
// has AES instructions, confirm that AES, and only AES,
// is in use. If the hardware does not have AES instructions,
// confirm that either AES or Adiantum is in use.
return;
}
if (PropertyUtil.getFirstApiLevel() < MIN_FBE_REQUIRED_API_LEVEL) {
Log.d(TAG, "Device is encrypted.");
return;
}
fail("File-based encryption is required");
知道问题点后,userdata就不能加forceencrypt了,那就修改sdcard的加密属性为 fileencryption=ice ,编译测试后 就没问题了
/devices/soc/7864900.sdhci/mmc_host* /storage/sdcard1 vfat nosuid,nodev wait,voldmanaged=sdcard1:auto,noemulatedsd,fileencryption=ice
/devices/platform/soc/7864900.sdhci/mmc_host* /storage/sdcard1 vfat nosuid,nodev wait,voldmanaged=sdcard1:auto,noemulatedsd,fileencryption=ice
在修改fstab的时候发现另一个问题跟这个有关,u盘插入设备可识别到插入,但是识别不成存储设备导致U盘不可用 下一篇说明