• Home
Name Date Size #Lines LOC

..--

jni/03-May-2024-3,0341,952

res/03-May-2024-204

src/com/android/sampleplugin/03-May-2024-346185

Android.mkD03-May-20241.1 KiB379

AndroidManifest.xmlD03-May-20241.3 KiB3616

MODULE_LICENSE_APACHE2D03-May-20240

NOTICED03-May-202410.4 KiB191158

READMED03-May-20247.1 KiB174134

README

1# Copyright (C) 2009 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16##############################
17######### CONTENTS ###########
18A. INTRODUCTION
19B. PLUGIN STRUCTURE
20C. HOW TO DEPLOY
21D. SUB-PLUGINS
22    1. ANIMATION
23    2. AUDIO
24    3. BACKGROUND
25    4. FORM
26    5. PAINT
27
28
29##############################
30## (A) INTRODUCTION ##########
31
32The sample plugin is intended to give plugin developers a point of reference to
33see how an android browser plugin is created and how to use the available APIs.
34A plugin is packaged like a standard apk and can be installed either via the
35market or adb.  The sample plugin attempts to exercise as many of the APIs as
36possible but unfortunately not all are covered.
37
38Trying to have a single plugin demonstrate all possible API interactions on one
39screen was not practical. On the other hand we also didn't want a separate
40plugin for each interction, as that would result in many separate apk's that
41would need to be maintained.  To solve this problem we developed the idea to use
42"sub-plugins". With a sub-plugin only one specific feature of the plugin would
43be active at a time, but they would all share as much common code as possible.
44A detailed description of each sub-plugin and its function can be found in the
45sub-plugins section.
46
47##############################
48## (B) PLUGIN STRUCTURE ######
49
50The sample plugin is packaged as one plugin but contains many unique sub-plugins
51(e.g. audio and paint).  The package consists of two pieces: (1) Java code
52containing the config; (2) C++ shared library containing the brower/plugin
53bindings and the sub-plugin classes.
54
55~~~~ (1) JAVA ~~~~~
56Android.mk: specifies the name of the APK (SampleBrowserPlugin) as well as which
57            shared libraries to include.
58
59AndroidManifest.xml: similar to a standard android manifest file, except that it
60                     must contain the "uses-permission" and "intent-filter"
61                     elements that are plugin specific.
62
63src/*: location of the java files which in our case is just an empty service
64
65res/*: location of the static resources (e.g. an icon for the plugin)
66
67~~~~ (2) C++ ~~~~~
68jni/Android.mk: specifies the build parameters for the shared library that is to
69                be included with the apk. The library contains all the bindings
70                between the plugin and the browser.
71
72jni/main.*: this code is the binding point between the plugin and the browser.
73            It supports all of the functions required for a standard netscape
74            style plugin as well as all the android specific APIs. The initial
75            starting point for the plugin is the NP_Initialize function. The
76            NPP_New function is responsible for reading the input args and
77            selecting the appropriate sub-plugin to instantiate. Most other
78            functions either return fixed values or pass their inputs to the
79            sub-plugin for processing.
80
81jni/PluginObject.*: The pluginObject provides a convenient container in which to
82                    store variables (the plugin's state).  This objects two main
83                    responsibilities are (1) to construct and store the NPClass
84                    object (done using code provided by Apple) and (2) provide
85                    the abstract class for the sub-plugin objects and a place to
86                    store the sub-plugin after it is instantiated.
87
88jni/*/*: Each of the sub-plugins has a folder that contains its class definition
89         and logic. The sub-plugin receives events from the browser and it can
90         also communicate with the browser using the netscape plugin functions
91         as well as the specialized android interfaces.
92
93
94##############################
95## (C) HOW TO DEPLOY #########
96
97To compile and install a plugin on a device/emulator simply...
98
991. run "make SampleBrowserPlugin" (compiles libsampleplugin.so and builds the apk)
1002. the previous command produces an apk file so record its location
1013. run "adb install [apk_file]" to install it on a device/emulator
1024. the browser will auto recognize the plugin is available
103
104Now that the plugin is installed you can manage it just like you would any other
105application via Settings -> Applications -> Manage applications. To execute the
106plugin you need to include an html snippet (similar to the one found below) in
107a document that is accessible by the browser.  The mime-type cannot change but
108you can change the width, height, and parameters.  The parameters are used to
109notify the plugin which sub-plugin to execute and which drawing model to use.
110
111<object type="application/x-testbrowserplugin" height=50 width=250>
112    <param name="DrawingModel" value="Surface" />
113    <param name="PluginType" value="Background" />
114</object>
115
116
117##############################
118## (D) SUB-PLUGINS ###########
119
120Each sub-plugin corresponds to exactly one plugin type and can support one or
121more drawing models. In the subsections below there are descriptions of each of
122the sub-plugins as well as the information required to create the html snippets.
123
124#######################
125## (D1) ANIMATION #####
126
127PLUGIN TYPE: Animation
128DRAWING MODEL: Bitmap
129
130This plugin draws a ball bouncing around the screen. If the plugin is not entirely
131on the screen and it it touched, then it will attempt to center itself on screen.
132
133#######################
134## (D2) AUDIO #########
135
136PLUGIN TYPE: Audio
137DRAWING MODEL: Bitmap
138
139This plugin plays a raw audio file located at /sdcard/sample.raw (need to supply
140your own). It uses touch to trigger the play, pause, and stop buttons.
141
142#######################
143## (D3) BACKGROUND ####
144
145PLUGIN TYPE: Background
146DRAWING MODEL: Surface
147
148This plugin has minimal visual components but mainly runs API tests in the
149background. The  plugin handles scaling its own bitmap on zoom which in this
150case is a simple string of text. The output of this plugin is found in the logs
151as it prints errors if it detects any API failures. Some of the API's tested are
152timers, javascript access, and bitmap formatting.
153
154#######################
155## (D4) FORM ##########
156
157PLUGIN TYPE: Form
158DRAWING MODEL: Bitmap
159
160This plugin mimics a simple username/password form. You can select a textbox by
161either touching it or using the navigation keys.  Once selected the box will
162highlight and the keyboard will appear. If the textbox selected is not fully
163in view then the plugin will ensure it is centered on the screen.
164
165#######################
166## (D5) PAINT #########
167
168PLUGIN TYPE: Paint
169DRAWING MODEL: Surface
170
171This plugin provides a surface that the user can "paint" on.  The inputs method
172can be toggled between mouse (dots) and touch (lines).  This plugin has a fixed
173surface and allows the browser to scale the surface when zooming.
174