Android Browser Gallery3D无法两指手势缩放
在我们三星s5pv210平台上使用的Android2.3.4自带的browser无法打开网页后进行两指手势缩放操作,只能通过连击缩放,而其他平台都可以,后来发现问题在frameworks/base/core/java/android/webkit/WebView.java文件的如下函数中:
void
updateMultiTouchSupport(Context context) {
WebSettings settings = getSettings();
final PackageManager pm =
context.getPackageManager();
mSupportMultiTouch =
pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH) &&
settings.supportZoom() &&
settings.getBuiltInZoomControls();
mAllowPanAndScale = pm.hasSystemFeature(
PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
if (mSupportMultiTouch
&& (mScaleDetector == null))
mScaleDetector = new ScaleGestureDetector(context,new
ScaleDetectorListener());
} else if (!mSupportMultiTouch
&& (mScaleDetector != null))
mScaleDetector = null; 查了下,mSupportMultiTouch这个变量是决定性因素,而其又决定于下面三大条件:
1、PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH;
2、settings.supportZoom();
3、settings.getBuiltInZoomControls();
后面两个函数对应于mSupportZoom和mBuiltInZoomControls两变量,查到在里面相应的设置都会为true,故问题存在于第一点,该点取决于/system/etc/permissions/目录下的文件,只有其中有一个xml文件里含有android.hardware.touchscreen.multitouch这项就要吧,后来发现原来我们的文件系统对应的目录下是不存在相应的文件,再查下去发现在我们的frameworks/base/data/etc/目录下有文件android.hardware.touchscreen.multitouch.xml,含有如下内容:
<permissions>
<feature
name="android.hardware.touchscreen" />
<feature
name="android.hardware.touchscreen.multitouch"
/>
</permissions>
现在,我们在编译的脚本中让其每次都复制到/system/etc/permissions/目录下即可,修改device/samsung/smdkv210/device.mk文件,在任一项PRODUCT_COPY_FILES frameworks/base/data/etc/android.hardware.touchscreen.multitouch.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.xml,至此就搞定了,为何只要含有上面的配置项即能让PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH这个特性生效,首先取决于硬件,TP要支持两点以上触摸,再者取决于文件frameworks/base/services/java/com/android/server/PackageManagerService.java,该文件会读取复制的目标目录下的xml,并配置相应的参数。 参考网址:http://blog.csdn.net/tjd0227/article/details/6043206 http://www.bangchui.org/simple/?t8649.html