浏览器插件的默认Android浏览器 [英] browser plugin for default android browser

查看:231
本文介绍了浏览器插件的默认Android浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个插件,这将指定在谷歌搜索结果中的网站类别的默认Android浏览器。 Android浏览器不明确显示插件架构。我想知道如何可以做任何参考材料相关的。

I would like to develop a plugin for the default android browser which would specify the category of sites in the google search result. The android browser dont explicitly show plugin architecture. I would like to know how that can be done and any reference materials related to that.

谢谢

推荐答案

最近,我试图让一个机器人插件,发现在SO但没有多少详细解答了很多问题,所以我想我会在这里分享我的研究,甚至但现在的问题是很老。我不知道,如果一个插件真的是你想在这里做什么,因为你很可能在使用谷歌的JSON / ATOM自定义搜索API和解析,但尽管如此我提供了一些如何让插件工作在Android上的细节。我希望这是对别人有用的。

I recently tried to make an android plugin and found many questions on SO but not many detailed answers, so I'd thought I'd share my research here even though the question is quite old now. I'm not sure if a plugin is really what you want to do here since you could probably use google's JSON/ATOM Custom Search API and parse that, but nonetheless I give details on how to get plugins working on Android. I hope it is useful for others.

如果你看这里: PluginManager.java 你会看到如下:

If you look here: PluginManager.java you will see the following lines:

// Only plugin matches one of the signatures in the list can be loaded
// inside the WebView process
private static final String SIGNATURE_1 = "308204c5..."

这里使用的签名是一个为Adobe的Flash插件(支持它现在已经下降了Adobe下载。)

The signature used here is the one for the Adobe Flash plugin (support for which has now been dropped by Adobe.)

和进一步向下在这里您将看到:

and further down here you will see:

if (SystemProperties.getBoolean("ro.secure", false)) {
            boolean signatureMatch = false;
            for (Signature signature : signatures) {
                for (int i = 0; i < SIGNATURES.length; i++) {
                    if (SIGNATURES[i].equals(signature)) {
                        signatureMatch = true;
                        break;
                    }
                }
            }
            if (!signatureMatch) {
                return false;
            }
        }

这意味着,如果 ro.secure = 0 那么就不会检查签名 - 这将只允许Flash插件,否则。 ro.secure 是一个构建属性,您可以设置,如果你有根privaleges为您的设备或者你有一个开发版本(键入亚行外壳getprop RO .secure 来找出你所拥有的)。你可以研究如何在必要时进行更改。我使用的是高通Snapdragon MDP8960这是开发板,它有ro.secure = 0了。要获得包括Android中你的插件的签名,你就必须跟专人负责 - 不知道如何可行的,这是在present

This means that if ro.secure=0 then it won't check the signatures - it would only allow the flash plugin otherwise. ro.secure is a build property that you can set if you have root privaleges for your device or you have a dev build (type adb shell getprop ro.secure to find out what you have). You can research how to change this if necessary. I was using a Qualcomm Snapdragon MDP8960 which is development board which had ro.secure=0 already. To get your plugin signature included in android you'll have to talk to someone in charge - not sure how feasible this is at present.

现在写一个插件 - 你可以找到在Android sourcetree(请确保您有一个64位的Linux机器,如果你想建立它所谓SampleBrowserPlugin一个例子 - 键入使SampleBrowserPlugin 从源代码树的根,你可能需要设置构建配置首先使用午餐,你可以找到在Android源代码树网站说明)

Now to write a plugin - you can find an example called SampleBrowserPlugin in the android sourcetree (make sure you have a 64 bit linux machine if you want to build it - type make SampleBrowserPlugin from the source tree root. You might need to set up the build configuration first using lunch and you can find instructions on the android source tree site)

其实,我抓住了我需要从 Android源在GitHub上并取得源的NDK版本,因为我比较熟悉如何做到这一点不是修改了Android构建脚本。这也将是比下载整个Android的树要快很多 - 你可以看到什么看什么是包含在Android.mk(见下文)下载

I actually grabbed the source I needed from android source on github and made an NDK build of the source as I am more familiar with how to do this than modifying the android build scripts. It will also be a lot faster than downloading the whole android tree - you can see what to download by looking at what is included in Android.mk (see below).

基本上,我把我所需要的设备,以确保我的插件将是兼容的共享对象库。他们在我的设备上 /系统/ lib目录:(例如:键入亚行拉/system/libnativehelper.so 等从你想让他们存储的目录) 得到如下:

Basically, I pulled the shared object libraries that I needed from the device to make sure my plugin would be compatible. They were in /system/lib on my device: (e.g. type adb pull /system/libnativehelper.so etc from the directory where you want them stored) get the following:

libnativehelper.so
libandroid.so
libutils.so
libcutils.so
libEGL.so
libGLESv2.so
libskia.so

把它们其中 SO_LIB_PATH 指向 Android.mk (见下文,并根据需要更改路径)。 然后安装NDK SDK后,你应该可以使用下面的构建脚本 - 不需要64位机 - (可以安装winbash,使用Cygwin或Linux的虚拟机如的Oracle VM VirtualBox:

Put them where SO_LIB_PATH points to in Android.mk (see below and change Path as necessary). Then after installing the NDK sdk you should be able to use the following build script - don't need a 64 bit machine - (you can install winbash, use cygwin, or a linux virtual machine e.g. Oracle VM VirtualBox:

(把这些文件放在 C:/路径/ BrowserPlugin / JNI / 并确保 NDK建造命令你的路径上) (如果你在Linux上删除的.cmd NDK-build.cmd

(Place these files in C:/Path/BrowserPlugin/jni/ and make sure the ndk-build command is on your path) (if you're on linux remove the .cmd from ndk-build.cmd)

build.sh:

#!/bin/bash
echo -e "Mode\t\t: Debug"
OPTIM=debug

### ---------------- Generic Build Command ---------------- 
# run NDK build
ndk-build.cmd \
    -d \
    -B \
    NDK_DEBUG=1 \
    NDK_PROJECT_PATH=C:/Path/BrowserPlugin/jni \
    NDK_APPLICATION_MK=C:/Path/BrowserPlugin/jni/Application.mk \
    NDK_MODULE_PATH=C:/Path/BrowserPlugin/jni \
    NDK_APP_OUT=C:/Path/BrowserPlugin/jni/Out/ \
    APP_BUILD_SCRIPT=C:/Path/BrowserPlugin/jni/Android.mk \
    APP_OPTIM=$OPTIM

cp C:/Path/BrowserPlugin/jni/Out/local/armeabi/libsampleplugin.so C:/Path/BrowserPlugin/libs/armeabi/.

echo "copied libsampleplugin.so into PROJECT_ROOT/libs dir"

Android.mk:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := \
    main.cpp \
    PluginObject.cpp \
    RenderingThread.cpp \
    animation/AnimationPlugin.cpp \
    animation/AnimationThread.cpp \
    audio/AudioPlugin.cpp \
    background/BackgroundPlugin.cpp \
    form/FormPlugin.cpp \
    navigation/NavigationPlugin.cpp \
    paint/PaintPlugin.cpp \
    video/VideoPlugin.cpp \
    jni-bridge.cpp \

WEBCORE_PATH := C:/Path/AndroidBrowserPlugin/webkit/Source/WebCore

LOCAL_C_INCLUDES += \
    $(JNI_H_INCLUDE) \
    $(LOCAL_PATH) \
    $(LOCAL_PATH)/animation \
    $(LOCAL_PATH)/audio \
    $(LOCAL_PATH)/background \
    $(LOCAL_PATH)/form \
    $(LOCAL_PATH)/navigation \
    $(LOCAL_PATH)/paint \
    $(LOCAL_PATH)/video \
    $(WEBCORE_PATH)/bridge \
    $(WEBCORE_PATH)/plugins \
    C:/Path/AndroidBrowserPlugin/webkit/Source/WebKit/android/JavaVM \
    C:/Path/AndroidBrowserPlugin/webkit/Source/WebKit/android/plugins \
    C:/Path/AndroidBrowserPlugin/platform_external_skia/include/core \
    C:/Path/AndroidBrowserPlugin/frameworks_native/include \
    C:/Path/AndroidBrowserPlugin/frameworks_native/libs \
    C:/Path/AndroidBrowserPlugin/frameworks_native/opengl/libs \
    C:/Path/AndroidBrowserPlugin/platform_system_core/include \
    C:/Path/AndroidBrowserPlugin/frameworks_native/opengl/include \
    C:/Users/user/android-ndk-r8c/platforms/android-14/arch-arm/usr/include \
    C:/Path/AndroidBrowserPlugin/BrowserPlugin/jni/libs/armeabi \
    C:/Path/AndroidBrowserPlugin/platform_bionic \
    C:/Path/AndroidBrowserPlugin/platform_bionic/libc/private \
    C:/Path/AndroidBrowserPlugin/platform_hardware_libhardware/include

SO_LIB_PATH := C:/Path/AndroidBrowserPlugin/libs_qualcomm_MDP8960

LOCAL_LDLIBS := \
    -L$(SO_LIB_PATH)/ -lnativehelper -landroid -lutils -lcutils -lEGL -lGLESv2 -lskia 

LOCAL_CFLAGS += -fvisibility=hidden
LOCAL_CFLAGS += -DHAVE_PTHREADS -DANDROID

LOCAL_MODULE:= libsampleplugin

LOCAL_MODULE_TAGS := optional

include $(BUILD_SHARED_LIBRARY)

Application.mk:

# =============================================================================
#
# Main build file defining the project modules and their global variables.
#
# =============================================================================

# Don't remove this - mandatory
APP_PROJECT_PATH := $(call my-dir)

# The only STL implementation currently working with exceptions
APP_STL := gnustl_static

# Don't optimize for better debugging
APP_OPTIM := debug

您可能还需要一些头文件(如 JNIHelp.h ),你可以将如在你正在做的NDK构建根 BrowserPlugin / JNI /

You may also need some header files (e.g. JNIHelp.h) which you can place e.g. in the root where you are doing the ndk build BrowserPlugin/jni/.

希望庆典build.sh 应该建立自己的 libsampleplugin.so 其中构建脚本复制到应用程序目录中。然后,你可以如导入项目到Eclipse和构建应用程序。在设备上安装它,然后如使用WAMP服务器托管以下文件:

Hopefully bash build.sh should build your libsampleplugin.so which the build script copies into the app directory. You can then e.g. import the project into eclipse and build the app. Install it on the device, then e.g. use WAMP server to host the following file:

index.html的:

<!DOCTYPE html>
<html>
    <head>
        <title>Test Plugin</title>
    </head>
    <body>
        <object type="application/x-testbrowserplugin" height=50 width=250 id="testPlugin">
            <param name="DrawingModel" value="Bitmap" />
            <param name="PluginType" value="Form" />
        </object>
    </body>
</html>

运行 IPCONFIG 从您的主机,以获取IP地址如: 192.168.x.x 然后点设备的浏览器如的http://192.168.xx/ ,瞧你应该会看到一个表格插件

run ipconfig from your host machine to get the IP address e.g. 192.168.x.x Then point your device browser to e.g. http://192.168.x.x/ and voila you should see a form plugin.

我无法让动画插件才能正常工作,并在窗体插件没有工作充分,但至少该插件被认可并加载确定。

I couldn't get the animation plugins to work properly, and the form plugin didn't work fully, but at least the plugin was recognised and loaded ok.

现在,你可以写一个WebKit的NPAPI插件做自己喜欢或者使用示例插件的浏览器为指导,或其他互联网资源的内容。

Now, you can write a webkit NPAPI plugin to do what you like either using the sample plugin browser as a guide, or other internet resources.

这篇关于浏览器插件的默认Android浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆