公司的手机最近也开始进行CTS测试了。分配了几个bug给我,改的我欲仙欲死。
1:run cts -m CtsViewTestCases -t
android.view.cts.PixelCopyTest#testWindowProducerCopyToRGBA16F
错误原因:未知
解决方案:修改以下文件
frameworks/base/libs/hwui/Extensions.cpp
+mHasRenderableFloatTexture = extensions.has("GL_OES_texture_half_float");
frameworks/base/libs/hwui/Extensions.h
+ inline bool hasRenderableFloatTextures() const {
+ return (mVersionMajor >= 3 && mVersionMinor >= 2) || mHasRenderableFloatTexture;
+ }
+ bool mHasRenderableFloatTexture;
+ bool mHasRenderableFloatTexture;
- if (bitmap->colorType() == kRGBA_F16_SkColorType && !caches.extensions().hasFloatTextures()) {
+ if (bitmap->colorType() == kRGBA_F16_SkColorType &&
+ !caches.extensions().hasRenderableFloatTextures()) {
ALOGW("Can't copy surface into bitmap, RGBA_F16 config is not supported");
return CopyResult::DestinationInvalid;
}
请看清楚加减号哦
2:run cts -m CtsViewTestCases -t android.view.cts.ViewTest#testSetBackgroundResource
首先看报错log。
java.lang.AssertionError: expected null, but was:<android.graphics.drawable.BitmapDrawable@7ebc70a> at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.failNotNull(Assert.java:755) at org.junit.Assert.assertNull(Assert.java:737) at org.junit.Assert.assertNull(Assert.java:747) at android.view.cts.ViewTest.testSetBackgroundResource(ViewTest.java:674) at java.lang.reflect.Method.invoke(Native Method) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:148) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:145) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:764)
可以看到是viewTest的674行,继续追踪
@Test
public void testSetBackgroundResource() {
View view = new View(mActivity);
assertNull(view.getBackground());
view.setBackgroundResource(R.drawable.pass);
assertNotNull(view.getBackground());
view.setBackgroundResource(0);
assertNull(view.getBackground());
}
可以看到最后两句代码他把view的背景设置为空进行断言判断,却发现view的背景并不为空,所以导致本项测试fail。也就是说view.setBackgroundResource为空失败。那么我们进入view源码里面看看。果不其然发现同事在其中加了个判断。修改下就能Pass了
int if_auto_switch_wallpaper=android.provider.Settings.System.getInt(mContext.getContentResolver(),"AUTO_SWITCH_WALLPAPER",1);
if(resid==0&&if_auto_switch_wallpaper==1){
return;
}
3:run cts -m CtsShortcutManagerTestCases -m
android.content.pm.cts.shortcutmanager.ShortcutManagerClientApiTest#testShortcutInfoMissingMandatoryFields
找了我n久,最后问了mtk才知道是豁免项,百度竟然没有。心痛。
Google bug id : 112251274
4:run cts -m CtsSecurityTestCases -t
android.security.cts.PackageSignatureTest#testPackageSignatures
这个百度倒是挺多的,原因是因为使用了谷歌默认的key,需要自己生成key替换掉。
具体解决方法:
第一步:生成自定义的key,进入/android_src/development/tools目录。使用目录下的make_key工具。
development/tools$ sh make_key releasekey '/C=CN/ST=JiangSu/L=NanJing/O=Company/OU=Department/CN=YourName/emailAddress=YourE-mailAddress'
Enter password for 'releasekey' (blank for none; password will be visible): mypassword <------- 设置你的密码
creating platform.pk8 with password [mypassword]
Generating RSA private key, 2048 bit long modulus
这是我百度到的一段代码。说实话,把我坑的够惨,不管怎么样设置密码为空都成功不了。博主也未说明。找了半天才知道这是本来就有的坑。需要换一种方式写法才行,直接用./,而不是sh make_key
./make_key '/C=CN/ST=GuangDong/L=ShenZhen/O=Forme/OU=Development/CN=Forme/emailAddress=13510507054@163.com' releasekey
C ---> Country Name (2 letter code)
ST ---> State or Province Name (full name)
L ---> Locality Name (eg, city)
O ---> Organization Name (eg, company)
OU ---> Organizational Unit Name (eg, section)
CN ---> Common Name (eg, your name or your server’s hostname)
emailAddress ---> Contact email address
请一定要注意生成key的时候设置密码为空。make编译的时候是不会给你输密码的。会报错的。而且需要生成releasekey,media,shared,platform,都是需要的,
第二部:把生成的8个文件替换掉默认key,路径:项目名/build/make/target/product/security
第三部:更改项目配置。build/make/core/Makefile,在BUILD_KEYS := test-keys下添加以下语句。
BUILD_KEYS := test-keys
endif
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/releasekey)
BUILD_KEYS := release-keys
路径:device/mediatek/common/device.mk添加以下语句。
PRODUCT_DEFAULT_DEV_CERTIFICATE := build/target/product/security/releasekey
然后重新编译一次就行就可以pass这个测试了。
5:run cts -m CtsSystemUiTestCases -t android.systemui.cts.LightBarTests#testLightStatusBarIcons
原因:未知
测试过程中发现systemui里面有个变量报空。按道理来说应该是不可能报空的,因为我们没有修改过那里,不知道是怎么回事。给那个变量加个为空判断就PASS了
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java
@@ -265,7 +265,8 @@ public class LightBarController implements BatteryController.BatteryStateChangeC
mStatusBarIconController.getTransitionsController().dump(fd, pw, args);
pw.println();
pw.println(" NavigationBarTransitionsController:");
- mNavigationBarController.dump(fd, pw, args);
+ if(mNavigationBarController!=null){mNavigationBarController.dump(fd, pw, args);}
+
pw.println();
}
}
嘛。暂时就这些。如有不对,请多指教。