You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2017/06/27 21:21:54 UTC
[13/51] [partial] cordova-lib git commit: Reorganized unit test
directory. Changes include: - consolidate spec-cordova/ and spec-plugman/
into a single spec/ dir. - put jasmine config and helper modules in top-level
spec dir. - changed package.json npm r
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPlugin.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPlugin.java
deleted file mode 100644
index 41af1db..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPlugin.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova;
-
-import org.apache.cordova.CordovaArgs;
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.CordovaInterface;
-import org.apache.cordova.CallbackContext;
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.res.Configuration;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- * Plugins must extend this class and override one of the execute methods.
- */
-public class CordovaPlugin {
- public CordovaWebView webView;
- public CordovaInterface cordova;
- protected CordovaPreferences preferences;
- private String serviceName;
-
- /**
- * Call this after constructing to initialize the plugin.
- * Final because we want to be able to change args without breaking plugins.
- */
- public final void privateInitialize(String serviceName, CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
- assert this.cordova == null;
- this.serviceName = serviceName;
- this.cordova = cordova;
- this.webView = webView;
- this.preferences = preferences;
- initialize(cordova, webView);
- pluginInitialize();
- }
-
- /**
- * Called after plugin construction and fields have been initialized.
- * Prefer to use pluginInitialize instead since there is no value in
- * having parameters on the initialize() function.
- */
- public void initialize(CordovaInterface cordova, CordovaWebView webView) {
- }
-
- /**
- * Called after plugin construction and fields have been initialized.
- */
- protected void pluginInitialize() {
- }
-
- /**
- * Returns the plugin's service name (what you'd use when calling pluginManger.getPlugin())
- */
- public String getServiceName() {
- return serviceName;
- }
-
- /**
- * Executes the request.
- *
- * This method is called from the WebView thread. To do a non-trivial amount of work, use:
- * cordova.getThreadPool().execute(runnable);
- *
- * To run on the UI thread, use:
- * cordova.getActivity().runOnUiThread(runnable);
- *
- * @param action The action to execute.
- * @param rawArgs The exec() arguments in JSON form.
- * @param callbackContext The callback context used when calling back into JavaScript.
- * @return Whether the action was valid.
- */
- public boolean execute(String action, String rawArgs, CallbackContext callbackContext) throws JSONException {
- JSONArray args = new JSONArray(rawArgs);
- return execute(action, args, callbackContext);
- }
-
- /**
- * Executes the request.
- *
- * This method is called from the WebView thread. To do a non-trivial amount of work, use:
- * cordova.getThreadPool().execute(runnable);
- *
- * To run on the UI thread, use:
- * cordova.getActivity().runOnUiThread(runnable);
- *
- * @param action The action to execute.
- * @param args The exec() arguments.
- * @param callbackContext The callback context used when calling back into JavaScript.
- * @return Whether the action was valid.
- */
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- CordovaArgs cordovaArgs = new CordovaArgs(args);
- return execute(action, cordovaArgs, callbackContext);
- }
-
- /**
- * Executes the request.
- *
- * This method is called from the WebView thread. To do a non-trivial amount of work, use:
- * cordova.getThreadPool().execute(runnable);
- *
- * To run on the UI thread, use:
- * cordova.getActivity().runOnUiThread(runnable);
- *
- * @param action The action to execute.
- * @param args The exec() arguments, wrapped with some Cordova helpers.
- * @param callbackContext The callback context used when calling back into JavaScript.
- * @return Whether the action was valid.
- */
- public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
- return false;
- }
-
- /**
- * Called when the system is about to start resuming a previous activity.
- *
- * @param multitasking Flag indicating if multitasking is turned on for app
- */
- public void onPause(boolean multitasking) {
- }
-
- /**
- * Called when the activity will start interacting with the user.
- *
- * @param multitasking Flag indicating if multitasking is turned on for app
- */
- public void onResume(boolean multitasking) {
- }
-
- /**
- * Called when the activity is becoming visible to the user.
- */
- public void onStart() {
- }
-
- /**
- * Called when the activity is no longer visible to the user.
- */
- public void onStop() {
- }
-
- /**
- * Called when the activity receives a new intent.
- */
- public void onNewIntent(Intent intent) {
- }
-
- /**
- * The final call you receive before your activity is destroyed.
- */
- public void onDestroy() {
- }
-
- /**
- * Called when the Activity is being destroyed (e.g. if a plugin calls out to an external
- * Activity and the OS kills the CordovaActivity in the background). The plugin should save its
- * state in this method only if it is awaiting the result of an external Activity and needs
- * to preserve some information so as to handle that result; onRestoreStateForActivityResult()
- * will only be called if the plugin is the recipient of an Activity result
- *
- * @return Bundle containing the state of the plugin or null if state does not need to be saved
- */
- public Bundle onSaveInstanceState() {
- return null;
- }
-
- /**
- * Called when a plugin is the recipient of an Activity result after the CordovaActivity has
- * been destroyed. The Bundle will be the same as the one the plugin returned in
- * onSaveInstanceState()
- *
- * @param state Bundle containing the state of the plugin
- * @param callbackContext Replacement Context to return the plugin result to
- */
- public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) {}
-
- /**
- * Called when a message is sent to plugin.
- *
- * @param id The message id
- * @param data The message data
- * @return Object to stop propagation or null
- */
- public Object onMessage(String id, Object data) {
- return null;
- }
-
- /**
- * Called when an activity you launched exits, giving you the requestCode you started it with,
- * the resultCode it returned, and any additional data from it.
- *
- * @param requestCode The request code originally supplied to startActivityForResult(),
- * allowing you to identify who this result came from.
- * @param resultCode The integer result code returned by the child activity through its setResult().
- * @param intent An Intent, which can return result data to the caller (various data can be
- * attached to Intent "extras").
- */
- public void onActivityResult(int requestCode, int resultCode, Intent intent) {
- }
-
- /**
- * Hook for blocking the loading of external resources.
- *
- * This will be called when the WebView's shouldInterceptRequest wants to
- * know whether to open a connection to an external resource. Return false
- * to block the request: if any plugin returns false, Cordova will block
- * the request. If all plugins return null, the default policy will be
- * enforced. If at least one plugin returns true, and no plugins return
- * false, then the request will proceed.
- *
- * Note that this only affects resource requests which are routed through
- * WebViewClient.shouldInterceptRequest, such as XMLHttpRequest requests and
- * img tag loads. WebSockets and media requests (such as <video> and <audio>
- * tags) are not affected by this method. Use CSP headers to control access
- * to such resources.
- */
- public Boolean shouldAllowRequest(String url) {
- return null;
- }
-
- /**
- * Hook for blocking navigation by the Cordova WebView. This applies both to top-level and
- * iframe navigations.
- *
- * This will be called when the WebView's needs to know whether to navigate
- * to a new page. Return false to block the navigation: if any plugin
- * returns false, Cordova will block the navigation. If all plugins return
- * null, the default policy will be enforced. It at least one plugin returns
- * true, and no plugins return false, then the navigation will proceed.
- */
- public Boolean shouldAllowNavigation(String url) {
- return null;
- }
-
- /**
- * Hook for allowing page to call exec(). By default, this returns the result of
- * shouldAllowNavigation(). It's generally unsafe to allow untrusted content to be loaded
- * into a CordovaWebView, even within an iframe, so it's best not to touch this.
- */
- public Boolean shouldAllowBridgeAccess(String url) {
- return shouldAllowNavigation(url);
- }
-
- /**
- * Hook for blocking the launching of Intents by the Cordova application.
- *
- * This will be called when the WebView will not navigate to a page, but
- * could launch an intent to handle the URL. Return false to block this: if
- * any plugin returns false, Cordova will block the navigation. If all
- * plugins return null, the default policy will be enforced. If at least one
- * plugin returns true, and no plugins return false, then the URL will be
- * opened.
- */
- public Boolean shouldOpenExternalUrl(String url) {
- return null;
- }
-
- /**
- * Allows plugins to handle a link being clicked. Return true here to cancel the navigation.
- *
- * @param url The URL that is trying to be loaded in the Cordova webview.
- * @return Return true to prevent the URL from loading. Default is false.
- */
- public boolean onOverrideUrlLoading(String url) {
- return false;
- }
-
- /**
- * Hook for redirecting requests. Applies to WebView requests as well as requests made by plugins.
- * To handle the request directly, return a URI in the form:
- *
- * cdvplugin://pluginId/...
- *
- * And implement handleOpenForRead().
- * To make this easier, use the toPluginUri() and fromPluginUri() helpers:
- *
- * public Uri remapUri(Uri uri) { return toPluginUri(uri); }
- *
- * public CordovaResourceApi.OpenForReadResult handleOpenForRead(Uri uri) throws IOException {
- * Uri origUri = fromPluginUri(uri);
- * ...
- * }
- */
- public Uri remapUri(Uri uri) {
- return null;
- }
-
- /**
- * Called to handle CordovaResourceApi.openForRead() calls for a cdvplugin://pluginId/ URL.
- * Should never return null.
- * Added in cordova-android@4.0.0
- */
- public CordovaResourceApi.OpenForReadResult handleOpenForRead(Uri uri) throws IOException {
- throw new FileNotFoundException("Plugin can't handle uri: " + uri);
- }
-
- /**
- * Refer to remapUri()
- * Added in cordova-android@4.0.0
- */
- protected Uri toPluginUri(Uri origUri) {
- return new Uri.Builder()
- .scheme(CordovaResourceApi.PLUGIN_URI_SCHEME)
- .authority(serviceName)
- .appendQueryParameter("origUri", origUri.toString())
- .build();
- }
-
- /**
- * Refer to remapUri()
- * Added in cordova-android@4.0.0
- */
- protected Uri fromPluginUri(Uri pluginUri) {
- return Uri.parse(pluginUri.getQueryParameter("origUri"));
- }
-
- /**
- * Called when the WebView does a top-level navigation or refreshes.
- *
- * Plugins should stop any long-running processes and clean up internal state.
- *
- * Does nothing by default.
- */
- public void onReset() {
- }
-
- /**
- * Called when the system received an HTTP authentication request. Plugin can use
- * the supplied HttpAuthHandler to process this auth challenge.
- *
- * @param view The WebView that is initiating the callback
- * @param handler The HttpAuthHandler used to set the WebView's response
- * @param host The host requiring authentication
- * @param realm The realm for which authentication is required
- *
- * @return Returns True if plugin will resolve this auth challenge, otherwise False
- *
- */
- public boolean onReceivedHttpAuthRequest(CordovaWebView view, ICordovaHttpAuthHandler handler, String host, String realm) {
- return false;
- }
-
- /**
- * Called when he system received an SSL client certificate request. Plugin can use
- * the supplied ClientCertRequest to process this certificate challenge.
- *
- * @param view The WebView that is initiating the callback
- * @param request The client certificate request
- *
- * @return Returns True if plugin will resolve this auth challenge, otherwise False
- *
- */
- public boolean onReceivedClientCertRequest(CordovaWebView view, ICordovaClientCertRequest request) {
- return false;
- }
-
- /**
- * Called by the system when the device configuration changes while your activity is running.
- *
- * @param newConfig The new device configuration
- */
- public void onConfigurationChanged(Configuration newConfig) {
- }
-
- /**
- * Called by the Plugin Manager when we need to actually request permissions
- *
- * @param requestCode Passed to the activity to track the request
- *
- * @return Returns the permission that was stored in the plugin
- */
-
- public void requestPermissions(int requestCode) {
- }
-
- /*
- * Called by the WebView implementation to check for geolocation permissions, can be used
- * by other Java methods in the event that a plugin is using this as a dependency.
- *
- * @return Returns true if the plugin has all the permissions it needs to operate.
- */
-
- public boolean hasPermisssion() {
- return true;
- }
-
- /**
- * Called by the system when the user grants permissions
- *
- * @param requestCode
- * @param permissions
- * @param grantResults
- */
- public void onRequestPermissionResult(int requestCode, String[] permissions,
- int[] grantResults) throws JSONException {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPreferences.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPreferences.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPreferences.java
deleted file mode 100644
index 4dbc93e..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaPreferences.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-package org.apache.cordova;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.cordova.LOG;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class CordovaPreferences {
- private HashMap<String, String> prefs = new HashMap<String, String>(20);
- private Bundle preferencesBundleExtras;
-
- public void setPreferencesBundle(Bundle extras) {
- preferencesBundleExtras = extras;
- }
-
- public void set(String name, String value) {
- prefs.put(name.toLowerCase(Locale.ENGLISH), value);
- }
-
- public void set(String name, boolean value) {
- set(name, "" + value);
- }
-
- public void set(String name, int value) {
- set(name, "" + value);
- }
-
- public void set(String name, double value) {
- set(name, "" + value);
- }
-
- public Map<String, String> getAll() {
- return prefs;
- }
-
- public boolean getBoolean(String name, boolean defaultValue) {
- name = name.toLowerCase(Locale.ENGLISH);
- String value = prefs.get(name);
- if (value != null) {
- return Boolean.parseBoolean(value);
- }
- return defaultValue;
- }
-
- // Added in 4.0.0
- public boolean contains(String name) {
- return getString(name, null) != null;
- }
-
- public int getInteger(String name, int defaultValue) {
- name = name.toLowerCase(Locale.ENGLISH);
- String value = prefs.get(name);
- if (value != null) {
- // Use Integer.decode() can't handle it if the highest bit is set.
- return (int)(long)Long.decode(value);
- }
- return defaultValue;
- }
-
- public double getDouble(String name, double defaultValue) {
- name = name.toLowerCase(Locale.ENGLISH);
- String value = prefs.get(name);
- if (value != null) {
- return Double.valueOf(value);
- }
- return defaultValue;
- }
-
- public String getString(String name, String defaultValue) {
- name = name.toLowerCase(Locale.ENGLISH);
- String value = prefs.get(name);
- if (value != null) {
- return value;
- }
- return defaultValue;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java
deleted file mode 100644
index e725e25..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.cordova;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.AssetFileDescriptor;
-import android.content.res.AssetManager;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Looper;
-import android.util.Base64;
-import android.webkit.MimeTypeMap;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.nio.channels.FileChannel;
-import java.util.Locale;
-
-/**
- * What this class provides:
- * 1. Helpers for reading & writing to URLs.
- * - E.g. handles assets, resources, content providers, files, data URIs, http[s]
- * - E.g. Can be used to query for mime-type & content length.
- *
- * 2. To allow plugins to redirect URLs (via remapUrl).
- * - All plugins should call remapUrl() on URLs they receive from JS *before*
- * passing the URL onto other utility functions in this class.
- * - For an example usage of this, refer to the org.apache.cordova.file plugin.
- *
- * Future Work:
- * - Consider using a Cursor to query content URLs for their size (like the file plugin does).
- * - Allow plugins to remapUri to "cdv-plugin://plugin-name/foo", which CordovaResourceApi
- * would then delegate to pluginManager.getPlugin(plugin-name).openForRead(url)
- * - Currently, plugins *can* do this by remapping to a data: URL, but it's inefficient
- * for large payloads.
- */
-public class CordovaResourceApi {
- @SuppressWarnings("unused")
- private static final String LOG_TAG = "CordovaResourceApi";
-
- public static final int URI_TYPE_FILE = 0;
- public static final int URI_TYPE_ASSET = 1;
- public static final int URI_TYPE_CONTENT = 2;
- public static final int URI_TYPE_RESOURCE = 3;
- public static final int URI_TYPE_DATA = 4;
- public static final int URI_TYPE_HTTP = 5;
- public static final int URI_TYPE_HTTPS = 6;
- public static final int URI_TYPE_PLUGIN = 7;
- public static final int URI_TYPE_UNKNOWN = -1;
-
- public static final String PLUGIN_URI_SCHEME = "cdvplugin";
-
- private static final String[] LOCAL_FILE_PROJECTION = { "_data" };
-
- public static Thread jsThread;
-
- private final AssetManager assetManager;
- private final ContentResolver contentResolver;
- private final PluginManager pluginManager;
- private boolean threadCheckingEnabled = true;
-
-
- public CordovaResourceApi(Context context, PluginManager pluginManager) {
- this.contentResolver = context.getContentResolver();
- this.assetManager = context.getAssets();
- this.pluginManager = pluginManager;
- }
-
- public void setThreadCheckingEnabled(boolean value) {
- threadCheckingEnabled = value;
- }
-
- public boolean isThreadCheckingEnabled() {
- return threadCheckingEnabled;
- }
-
-
- public static int getUriType(Uri uri) {
- assertNonRelative(uri);
- String scheme = uri.getScheme();
- if (ContentResolver.SCHEME_CONTENT.equalsIgnoreCase(scheme)) {
- return URI_TYPE_CONTENT;
- }
- if (ContentResolver.SCHEME_ANDROID_RESOURCE.equalsIgnoreCase(scheme)) {
- return URI_TYPE_RESOURCE;
- }
- if (ContentResolver.SCHEME_FILE.equalsIgnoreCase(scheme)) {
- if (uri.getPath().startsWith("/android_asset/")) {
- return URI_TYPE_ASSET;
- }
- return URI_TYPE_FILE;
- }
- if ("data".equalsIgnoreCase(scheme)) {
- return URI_TYPE_DATA;
- }
- if ("http".equalsIgnoreCase(scheme)) {
- return URI_TYPE_HTTP;
- }
- if ("https".equalsIgnoreCase(scheme)) {
- return URI_TYPE_HTTPS;
- }
- if (PLUGIN_URI_SCHEME.equalsIgnoreCase(scheme)) {
- return URI_TYPE_PLUGIN;
- }
- return URI_TYPE_UNKNOWN;
- }
-
- public Uri remapUri(Uri uri) {
- assertNonRelative(uri);
- Uri pluginUri = pluginManager.remapUri(uri);
- return pluginUri != null ? pluginUri : uri;
- }
-
- public String remapPath(String path) {
- return remapUri(Uri.fromFile(new File(path))).getPath();
- }
-
- /**
- * Returns a File that points to the resource, or null if the resource
- * is not on the local filesystem.
- */
- public File mapUriToFile(Uri uri) {
- assertBackgroundThread();
- switch (getUriType(uri)) {
- case URI_TYPE_FILE:
- return new File(uri.getPath());
- case URI_TYPE_CONTENT: {
- Cursor cursor = contentResolver.query(uri, LOCAL_FILE_PROJECTION, null, null, null);
- if (cursor != null) {
- try {
- int columnIndex = cursor.getColumnIndex(LOCAL_FILE_PROJECTION[0]);
- if (columnIndex != -1 && cursor.getCount() > 0) {
- cursor.moveToFirst();
- String realPath = cursor.getString(columnIndex);
- if (realPath != null) {
- return new File(realPath);
- }
- }
- } finally {
- cursor.close();
- }
- }
- }
- }
- return null;
- }
-
- public String getMimeType(Uri uri) {
- switch (getUriType(uri)) {
- case URI_TYPE_FILE:
- case URI_TYPE_ASSET:
- return getMimeTypeFromPath(uri.getPath());
- case URI_TYPE_CONTENT:
- case URI_TYPE_RESOURCE:
- return contentResolver.getType(uri);
- case URI_TYPE_DATA: {
- return getDataUriMimeType(uri);
- }
- case URI_TYPE_HTTP:
- case URI_TYPE_HTTPS: {
- try {
- HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
- conn.setDoInput(false);
- conn.setRequestMethod("HEAD");
- String mimeType = conn.getHeaderField("Content-Type");
- if (mimeType != null) {
- mimeType = mimeType.split(";")[0];
- }
- return mimeType;
- } catch (IOException e) {
- }
- }
- }
-
- return null;
- }
-
-
- //This already exists
- private String getMimeTypeFromPath(String path) {
- String extension = path;
- int lastDot = extension.lastIndexOf('.');
- if (lastDot != -1) {
- extension = extension.substring(lastDot + 1);
- }
- // Convert the URI string to lower case to ensure compatibility with MimeTypeMap (see CB-2185).
- extension = extension.toLowerCase(Locale.getDefault());
- if (extension.equals("3ga")) {
- return "audio/3gpp";
- } else if (extension.equals("js")) {
- // Missing from the map :(.
- return "text/javascript";
- }
- return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
- }
-
- /**
- * Opens a stream to the given URI, also providing the MIME type & length.
- * @return Never returns null.
- * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
- * resolved before being passed into this function.
- * @throws Throws an IOException if the URI cannot be opened.
- * @throws Throws an IllegalStateException if called on a foreground thread.
- */
- public OpenForReadResult openForRead(Uri uri) throws IOException {
- return openForRead(uri, false);
- }
-
- /**
- * Opens a stream to the given URI, also providing the MIME type & length.
- * @return Never returns null.
- * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
- * resolved before being passed into this function.
- * @throws Throws an IOException if the URI cannot be opened.
- * @throws Throws an IllegalStateException if called on a foreground thread and skipThreadCheck is false.
- */
- public OpenForReadResult openForRead(Uri uri, boolean skipThreadCheck) throws IOException {
- if (!skipThreadCheck) {
- assertBackgroundThread();
- }
- switch (getUriType(uri)) {
- case URI_TYPE_FILE: {
- FileInputStream inputStream = new FileInputStream(uri.getPath());
- String mimeType = getMimeTypeFromPath(uri.getPath());
- long length = inputStream.getChannel().size();
- return new OpenForReadResult(uri, inputStream, mimeType, length, null);
- }
- case URI_TYPE_ASSET: {
- String assetPath = uri.getPath().substring(15);
- AssetFileDescriptor assetFd = null;
- InputStream inputStream;
- long length = -1;
- try {
- assetFd = assetManager.openFd(assetPath);
- inputStream = assetFd.createInputStream();
- length = assetFd.getLength();
- } catch (FileNotFoundException e) {
- // Will occur if the file is compressed.
- inputStream = assetManager.open(assetPath);
- }
- String mimeType = getMimeTypeFromPath(assetPath);
- return new OpenForReadResult(uri, inputStream, mimeType, length, assetFd);
- }
- case URI_TYPE_CONTENT:
- case URI_TYPE_RESOURCE: {
- String mimeType = contentResolver.getType(uri);
- AssetFileDescriptor assetFd = contentResolver.openAssetFileDescriptor(uri, "r");
- InputStream inputStream = assetFd.createInputStream();
- long length = assetFd.getLength();
- return new OpenForReadResult(uri, inputStream, mimeType, length, assetFd);
- }
- case URI_TYPE_DATA: {
- OpenForReadResult ret = readDataUri(uri);
- if (ret == null) {
- break;
- }
- return ret;
- }
- case URI_TYPE_HTTP:
- case URI_TYPE_HTTPS: {
- HttpURLConnection conn = (HttpURLConnection)new URL(uri.toString()).openConnection();
- conn.setDoInput(true);
- String mimeType = conn.getHeaderField("Content-Type");
- if (mimeType != null) {
- mimeType = mimeType.split(";")[0];
- }
- int length = conn.getContentLength();
- InputStream inputStream = conn.getInputStream();
- return new OpenForReadResult(uri, inputStream, mimeType, length, null);
- }
- case URI_TYPE_PLUGIN: {
- String pluginId = uri.getHost();
- CordovaPlugin plugin = pluginManager.getPlugin(pluginId);
- if (plugin == null) {
- throw new FileNotFoundException("Invalid plugin ID in URI: " + uri);
- }
- return plugin.handleOpenForRead(uri);
- }
- }
- throw new FileNotFoundException("URI not supported by CordovaResourceApi: " + uri);
- }
-
- public OutputStream openOutputStream(Uri uri) throws IOException {
- return openOutputStream(uri, false);
- }
-
- /**
- * Opens a stream to the given URI.
- * @return Never returns null.
- * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
- * resolved before being passed into this function.
- * @throws Throws an IOException if the URI cannot be opened.
- */
- public OutputStream openOutputStream(Uri uri, boolean append) throws IOException {
- assertBackgroundThread();
- switch (getUriType(uri)) {
- case URI_TYPE_FILE: {
- File localFile = new File(uri.getPath());
- File parent = localFile.getParentFile();
- if (parent != null) {
- parent.mkdirs();
- }
- return new FileOutputStream(localFile, append);
- }
- case URI_TYPE_CONTENT:
- case URI_TYPE_RESOURCE: {
- AssetFileDescriptor assetFd = contentResolver.openAssetFileDescriptor(uri, append ? "wa" : "w");
- return assetFd.createOutputStream();
- }
- }
- throw new FileNotFoundException("URI not supported by CordovaResourceApi: " + uri);
- }
-
- public HttpURLConnection createHttpConnection(Uri uri) throws IOException {
- assertBackgroundThread();
- return (HttpURLConnection)new URL(uri.toString()).openConnection();
- }
-
- // Copies the input to the output in the most efficient manner possible.
- // Closes both streams.
- public void copyResource(OpenForReadResult input, OutputStream outputStream) throws IOException {
- assertBackgroundThread();
- try {
- InputStream inputStream = input.inputStream;
- if (inputStream instanceof FileInputStream && outputStream instanceof FileOutputStream) {
- FileChannel inChannel = ((FileInputStream)input.inputStream).getChannel();
- FileChannel outChannel = ((FileOutputStream)outputStream).getChannel();
- long offset = 0;
- long length = input.length;
- if (input.assetFd != null) {
- offset = input.assetFd.getStartOffset();
- }
- // transferFrom()'s 2nd arg is a relative position. Need to set the absolute
- // position first.
- inChannel.position(offset);
- outChannel.transferFrom(inChannel, 0, length);
- } else {
- final int BUFFER_SIZE = 8192;
- byte[] buffer = new byte[BUFFER_SIZE];
-
- for (;;) {
- int bytesRead = inputStream.read(buffer, 0, BUFFER_SIZE);
-
- if (bytesRead <= 0) {
- break;
- }
- outputStream.write(buffer, 0, bytesRead);
- }
- }
- } finally {
- input.inputStream.close();
- if (outputStream != null) {
- outputStream.close();
- }
- }
- }
-
- public void copyResource(Uri sourceUri, OutputStream outputStream) throws IOException {
- copyResource(openForRead(sourceUri), outputStream);
- }
-
- // Added in 3.5.0.
- public void copyResource(Uri sourceUri, Uri dstUri) throws IOException {
- copyResource(openForRead(sourceUri), openOutputStream(dstUri));
- }
-
- private void assertBackgroundThread() {
- if (threadCheckingEnabled) {
- Thread curThread = Thread.currentThread();
- if (curThread == Looper.getMainLooper().getThread()) {
- throw new IllegalStateException("Do not perform IO operations on the UI thread. Use CordovaInterface.getThreadPool() instead.");
- }
- if (curThread == jsThread) {
- throw new IllegalStateException("Tried to perform an IO operation on the WebCore thread. Use CordovaInterface.getThreadPool() instead.");
- }
- }
- }
-
- private String getDataUriMimeType(Uri uri) {
- String uriAsString = uri.getSchemeSpecificPart();
- int commaPos = uriAsString.indexOf(',');
- if (commaPos == -1) {
- return null;
- }
- String[] mimeParts = uriAsString.substring(0, commaPos).split(";");
- if (mimeParts.length > 0) {
- return mimeParts[0];
- }
- return null;
- }
-
- private OpenForReadResult readDataUri(Uri uri) {
- String uriAsString = uri.getSchemeSpecificPart();
- int commaPos = uriAsString.indexOf(',');
- if (commaPos == -1) {
- return null;
- }
- String[] mimeParts = uriAsString.substring(0, commaPos).split(";");
- String contentType = null;
- boolean base64 = false;
- if (mimeParts.length > 0) {
- contentType = mimeParts[0];
- }
- for (int i = 1; i < mimeParts.length; ++i) {
- if ("base64".equalsIgnoreCase(mimeParts[i])) {
- base64 = true;
- }
- }
- String dataPartAsString = uriAsString.substring(commaPos + 1);
- byte[] data;
- if (base64) {
- data = Base64.decode(dataPartAsString, Base64.DEFAULT);
- } else {
- try {
- data = dataPartAsString.getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- data = dataPartAsString.getBytes();
- }
- }
- InputStream inputStream = new ByteArrayInputStream(data);
- return new OpenForReadResult(uri, inputStream, contentType, data.length, null);
- }
-
- private static void assertNonRelative(Uri uri) {
- if (!uri.isAbsolute()) {
- throw new IllegalArgumentException("Relative URIs are not supported.");
- }
- }
-
- public static final class OpenForReadResult {
- public final Uri uri;
- public final InputStream inputStream;
- public final String mimeType;
- public final long length;
- public final AssetFileDescriptor assetFd;
-
- public OpenForReadResult(Uri uri, InputStream inputStream, String mimeType, long length, AssetFileDescriptor assetFd) {
- this.uri = uri;
- this.inputStream = inputStream;
- this.mimeType = mimeType;
- this.length = length;
- this.assetFd = assetFd;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java
deleted file mode 100644
index 62e53a0..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova;
-
-import java.util.List;
-import java.util.Map;
-
-import android.content.Context;
-import android.content.Intent;
-import android.view.View;
-import android.webkit.WebChromeClient.CustomViewCallback;
-
-/**
- * Main interface for interacting with a Cordova webview - implemented by CordovaWebViewImpl.
- * This is an interface so that it can be easily mocked in tests.
- * Methods may be added to this interface without a major version bump, as plugins & embedders
- * are not expected to implement it.
- */
-public interface CordovaWebView {
- public static final String CORDOVA_VERSION = "6.2.1";
-
- void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
-
- boolean isInitialized();
-
- View getView();
-
- void loadUrlIntoView(String url, boolean recreatePlugins);
-
- void stopLoading();
-
- boolean canGoBack();
-
- void clearCache();
-
- /** Use parameter-less overload */
- @Deprecated
- void clearCache(boolean b);
-
- void clearHistory();
-
- boolean backHistory();
-
- void handlePause(boolean keepRunning);
-
- void onNewIntent(Intent intent);
-
- void handleResume(boolean keepRunning);
-
- void handleStart();
-
- void handleStop();
-
- void handleDestroy();
-
- /**
- * Send JavaScript statement back to JavaScript.
- *
- * Deprecated (https://issues.apache.org/jira/browse/CB-6851)
- * Instead of executing snippets of JS, you should use the exec bridge
- * to create a Java->JS communication channel.
- * To do this:
- * 1. Within plugin.xml (to have your JS run before deviceready):
- * <js-module><runs/></js-module>
- * 2. Within your .js (call exec on start-up):
- * require('cordova/channel').onCordovaReady.subscribe(function() {
- * require('cordova/exec')(win, null, 'Plugin', 'method', []);
- * function win(message) {
- * ... process message from java here ...
- * }
- * });
- * 3. Within your .java:
- * PluginResult dataResult = new PluginResult(PluginResult.Status.OK, CODE);
- * dataResult.setKeepCallback(true);
- * savedCallbackContext.sendPluginResult(dataResult);
- */
- @Deprecated
- void sendJavascript(String statememt);
-
- /**
- * Load the specified URL in the Cordova webview or a new browser instance.
- *
- * NOTE: If openExternal is false, only whitelisted URLs can be loaded.
- *
- * @param url The url to load.
- * @param openExternal Load url in browser instead of Cordova webview.
- * @param clearHistory Clear the history stack, so new page becomes top of history
- * @param params Parameters for new app
- */
- void showWebPage(String url, boolean openExternal, boolean clearHistory, Map<String, Object> params);
-
- /**
- * Deprecated in 4.0.0. Use your own View-toggling logic.
- */
- @Deprecated
- boolean isCustomViewShowing();
-
- /**
- * Deprecated in 4.0.0. Use your own View-toggling logic.
- */
- @Deprecated
- void showCustomView(View view, CustomViewCallback callback);
-
- /**
- * Deprecated in 4.0.0. Use your own View-toggling logic.
- */
- @Deprecated
- void hideCustomView();
-
- CordovaResourceApi getResourceApi();
-
- void setButtonPlumbedToJs(int keyCode, boolean override);
- boolean isButtonPlumbedToJs(int keyCode);
-
- void sendPluginResult(PluginResult cr, String callbackId);
-
- PluginManager getPluginManager();
- CordovaWebViewEngine getEngine();
- CordovaPreferences getPreferences();
- ICordovaCookieManager getCookieManager();
-
- String getUrl();
-
- // TODO: Work on deleting these by removing refs from plugins.
- Context getContext();
- void loadUrl(String url);
- Object postMessage(String id, Object data);
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewEngine.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewEngine.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewEngine.java
deleted file mode 100644
index c8e5a55..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewEngine.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova;
-
-import android.view.KeyEvent;
-import android.view.View;
-import android.webkit.ValueCallback;
-
-/**
- * Interface for all Cordova engines.
- * No methods will be added to this class (in order to be compatible with existing engines).
- * Instead, we will create a new interface: e.g. CordovaWebViewEngineV2
- */
-public interface CordovaWebViewEngine {
- void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client,
- CordovaResourceApi resourceApi, PluginManager pluginManager,
- NativeToJsMessageQueue nativeToJsMessageQueue);
-
- CordovaWebView getCordovaWebView();
- ICordovaCookieManager getCookieManager();
- View getView();
-
- void loadUrl(String url, boolean clearNavigationStack);
-
- void stopLoading();
-
- /** Return the currently loaded URL */
- String getUrl();
-
- void clearCache();
-
- /** After calling clearHistory(), canGoBack() should be false. */
- void clearHistory();
-
- boolean canGoBack();
-
- /** Returns whether a navigation occurred */
- boolean goBack();
-
- /** Pauses / resumes the WebView's event loop. */
- void setPaused(boolean value);
-
- /** Clean up all resources associated with the WebView. */
- void destroy();
-
- /** Add the evaulate Javascript method **/
- void evaluateJavascript(String js, ValueCallback<String> callback);
-
- /**
- * Used to retrieve the associated CordovaWebView given a View without knowing the type of Engine.
- * E.g. ((CordovaWebView.EngineView)activity.findViewById(android.R.id.webView)).getCordovaWebView();
- */
- public interface EngineView {
- CordovaWebView getCordovaWebView();
- }
-
- /**
- * Contains methods that an engine uses to communicate with the parent CordovaWebView.
- * Methods may be added in future cordova versions, but never removed.
- */
- public interface Client {
- Boolean onDispatchKeyEvent(KeyEvent event);
- void clearLoadTimeoutTimer();
- void onPageStarted(String newUrl);
- void onReceivedError(int errorCode, String description, String failingUrl);
- void onPageFinishedLoading(String url);
- boolean onNavigationAttempt(String url);
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewImpl.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewImpl.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewImpl.java
deleted file mode 100644
index 85a0b5f..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CordovaWebViewImpl.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.WebChromeClient;
-import android.widget.FrameLayout;
-
-import org.apache.cordova.engine.SystemWebViewEngine;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Main class for interacting with a Cordova webview. Manages plugins, events, and a CordovaWebViewEngine.
- * Class uses two-phase initialization. You must call init() before calling any other methods.
- */
-public class CordovaWebViewImpl implements CordovaWebView {
-
- public static final String TAG = "CordovaWebViewImpl";
-
- private PluginManager pluginManager;
-
- protected final CordovaWebViewEngine engine;
- private CordovaInterface cordova;
-
- // Flag to track that a loadUrl timeout occurred
- private int loadUrlTimeout = 0;
-
- private CordovaResourceApi resourceApi;
- private CordovaPreferences preferences;
- private CoreAndroid appPlugin;
- private NativeToJsMessageQueue nativeToJsMessageQueue;
- private EngineClient engineClient = new EngineClient();
- private boolean hasPausedEver;
-
- // The URL passed to loadUrl(), not necessarily the URL of the current page.
- String loadedUrl;
-
- /** custom view created by the browser (a video player for example) */
- private View mCustomView;
- private WebChromeClient.CustomViewCallback mCustomViewCallback;
-
- private Set<Integer> boundKeyCodes = new HashSet<Integer>();
-
- public static CordovaWebViewEngine createEngine(Context context, CordovaPreferences preferences) {
- String className = preferences.getString("webview", SystemWebViewEngine.class.getCanonicalName());
- try {
- Class<?> webViewClass = Class.forName(className);
- Constructor<?> constructor = webViewClass.getConstructor(Context.class, CordovaPreferences.class);
- return (CordovaWebViewEngine) constructor.newInstance(context, preferences);
- } catch (Exception e) {
- throw new RuntimeException("Failed to create webview. ", e);
- }
- }
-
- public CordovaWebViewImpl(CordovaWebViewEngine cordovaWebViewEngine) {
- this.engine = cordovaWebViewEngine;
- }
-
- // Convenience method for when creating programmatically (not from Config.xml).
- public void init(CordovaInterface cordova) {
- init(cordova, new ArrayList<PluginEntry>(), new CordovaPreferences());
- }
-
- @Override
- public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences) {
- if (this.cordova != null) {
- throw new IllegalStateException();
- }
- this.cordova = cordova;
- this.preferences = preferences;
- pluginManager = new PluginManager(this, this.cordova, pluginEntries);
- resourceApi = new CordovaResourceApi(engine.getView().getContext(), pluginManager);
- nativeToJsMessageQueue = new NativeToJsMessageQueue();
- nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode());
- nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.LoadUrlBridgeMode(engine, cordova));
-
- if (preferences.getBoolean("DisallowOverscroll", false)) {
- engine.getView().setOverScrollMode(View.OVER_SCROLL_NEVER);
- }
- engine.init(this, cordova, engineClient, resourceApi, pluginManager, nativeToJsMessageQueue);
- // This isn't enforced by the compiler, so assert here.
- assert engine.getView() instanceof CordovaWebViewEngine.EngineView;
-
- pluginManager.addService(CoreAndroid.PLUGIN_NAME, "org.apache.cordova.CoreAndroid");
- pluginManager.init();
-
- }
-
- @Override
- public boolean isInitialized() {
- return cordova != null;
- }
-
- @Override
- public void loadUrlIntoView(final String url, boolean recreatePlugins) {
- LOG.d(TAG, ">>> loadUrl(" + url + ")");
- if (url.equals("about:blank") || url.startsWith("javascript:")) {
- engine.loadUrl(url, false);
- return;
- }
-
- recreatePlugins = recreatePlugins || (loadedUrl == null);
-
- if (recreatePlugins) {
- // Don't re-initialize on first load.
- if (loadedUrl != null) {
- appPlugin = null;
- pluginManager.init();
- }
- loadedUrl = url;
- }
-
- // Create a timeout timer for loadUrl
- final int currentLoadUrlTimeout = loadUrlTimeout;
- final int loadUrlTimeoutValue = preferences.getInteger("LoadUrlTimeoutValue", 20000);
-
- // Timeout error method
- final Runnable loadError = new Runnable() {
- public void run() {
- stopLoading();
- LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
-
- // Handle other errors by passing them to the webview in JS
- JSONObject data = new JSONObject();
- try {
- data.put("errorCode", -6);
- data.put("description", "The connection to the server was unsuccessful.");
- data.put("url", url);
- } catch (JSONException e) {
- // Will never happen.
- }
- pluginManager.postMessage("onReceivedError", data);
- }
- };
-
- // Timeout timer method
- final Runnable timeoutCheck = new Runnable() {
- public void run() {
- try {
- synchronized (this) {
- wait(loadUrlTimeoutValue);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- // If timeout, then stop loading and handle error
- if (loadUrlTimeout == currentLoadUrlTimeout) {
- cordova.getActivity().runOnUiThread(loadError);
- }
- }
- };
-
- final boolean _recreatePlugins = recreatePlugins;
- cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- if (loadUrlTimeoutValue > 0) {
- cordova.getThreadPool().execute(timeoutCheck);
- }
- engine.loadUrl(url, _recreatePlugins);
- }
- });
- }
-
-
- @Override
- public void loadUrl(String url) {
- loadUrlIntoView(url, true);
- }
-
- @Override
- public void showWebPage(String url, boolean openExternal, boolean clearHistory, Map<String, Object> params) {
- LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap)", url, openExternal, clearHistory);
-
- // If clearing history
- if (clearHistory) {
- engine.clearHistory();
- }
-
- // If loading into our webview
- if (!openExternal) {
- // Make sure url is in whitelist
- if (pluginManager.shouldAllowNavigation(url)) {
- // TODO: What about params?
- // Load new URL
- loadUrlIntoView(url, true);
- } else {
- LOG.w(TAG, "showWebPage: Refusing to load URL into webview since it is not in the <allow-navigation> whitelist. URL=" + url);
- }
- }
- if (!pluginManager.shouldOpenExternalUrl(url)) {
- LOG.w(TAG, "showWebPage: Refusing to send intent for URL since it is not in the <allow-intent> whitelist. URL=" + url);
- return;
- }
- try {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- // To send an intent without CATEGORY_BROWSER, a custom plugin should be used.
- intent.addCategory(Intent.CATEGORY_BROWSABLE);
- Uri uri = Uri.parse(url);
- // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
- // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
- if ("file".equals(uri.getScheme())) {
- intent.setDataAndType(uri, resourceApi.getMimeType(uri));
- } else {
- intent.setData(uri);
- }
- cordova.getActivity().startActivity(intent);
- } catch (android.content.ActivityNotFoundException e) {
- LOG.e(TAG, "Error loading url " + url, e);
- }
- }
-
- @Override
- @Deprecated
- public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
- // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
- LOG.d(TAG, "showing Custom View");
- // if a view already exists then immediately terminate the new one
- if (mCustomView != null) {
- callback.onCustomViewHidden();
- return;
- }
-
- // Store the view and its callback for later (to kill it properly)
- mCustomView = view;
- mCustomViewCallback = callback;
-
- // Add the custom view to its container.
- ViewGroup parent = (ViewGroup) engine.getView().getParent();
- parent.addView(view, new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT,
- Gravity.CENTER));
-
- // Hide the content view.
- engine.getView().setVisibility(View.GONE);
-
- // Finally show the custom view container.
- parent.setVisibility(View.VISIBLE);
- parent.bringToFront();
- }
-
- @Override
- @Deprecated
- public void hideCustomView() {
- // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
- if (mCustomView == null) return;
- LOG.d(TAG, "Hiding Custom View");
-
- // Hide the custom view.
- mCustomView.setVisibility(View.GONE);
-
- // Remove the custom view from its container.
- ViewGroup parent = (ViewGroup) engine.getView().getParent();
- parent.removeView(mCustomView);
- mCustomView = null;
- mCustomViewCallback.onCustomViewHidden();
-
- // Show the content view.
- engine.getView().setVisibility(View.VISIBLE);
- }
-
- @Override
- @Deprecated
- public boolean isCustomViewShowing() {
- return mCustomView != null;
- }
-
- @Override
- @Deprecated
- public void sendJavascript(String statement) {
- nativeToJsMessageQueue.addJavaScript(statement);
- }
-
- @Override
- public void sendPluginResult(PluginResult cr, String callbackId) {
- nativeToJsMessageQueue.addPluginResult(cr, callbackId);
- }
-
- @Override
- public PluginManager getPluginManager() {
- return pluginManager;
- }
- @Override
- public CordovaPreferences getPreferences() {
- return preferences;
- }
- @Override
- public ICordovaCookieManager getCookieManager() {
- return engine.getCookieManager();
- }
- @Override
- public CordovaResourceApi getResourceApi() {
- return resourceApi;
- }
- @Override
- public CordovaWebViewEngine getEngine() {
- return engine;
- }
- @Override
- public View getView() {
- return engine.getView();
- }
- @Override
- public Context getContext() {
- return engine.getView().getContext();
- }
-
- private void sendJavascriptEvent(String event) {
- if (appPlugin == null) {
- appPlugin = (CoreAndroid)pluginManager.getPlugin(CoreAndroid.PLUGIN_NAME);
- }
-
- if (appPlugin == null) {
- LOG.w(TAG, "Unable to fire event without existing plugin");
- return;
- }
- appPlugin.fireJavascriptEvent(event);
- }
-
- @Override
- public void setButtonPlumbedToJs(int keyCode, boolean override) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- case KeyEvent.KEYCODE_VOLUME_UP:
- case KeyEvent.KEYCODE_BACK:
- case KeyEvent.KEYCODE_MENU:
- // TODO: Why are search and menu buttons handled separately?
- if (override) {
- boundKeyCodes.add(keyCode);
- } else {
- boundKeyCodes.remove(keyCode);
- }
- return;
- default:
- throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
- }
- }
-
- @Override
- public boolean isButtonPlumbedToJs(int keyCode) {
- return boundKeyCodes.contains(keyCode);
- }
-
- @Override
- public Object postMessage(String id, Object data) {
- return pluginManager.postMessage(id, data);
- }
-
- // Engine method proxies:
- @Override
- public String getUrl() {
- return engine.getUrl();
- }
-
- @Override
- public void stopLoading() {
- // Clear timeout flag
- loadUrlTimeout++;
- }
-
- @Override
- public boolean canGoBack() {
- return engine.canGoBack();
- }
-
- @Override
- public void clearCache() {
- engine.clearCache();
- }
-
- @Override
- @Deprecated
- public void clearCache(boolean b) {
- engine.clearCache();
- }
-
- @Override
- public void clearHistory() {
- engine.clearHistory();
- }
-
- @Override
- public boolean backHistory() {
- return engine.goBack();
- }
-
- /////// LifeCycle methods ///////
- @Override
- public void onNewIntent(Intent intent) {
- if (this.pluginManager != null) {
- this.pluginManager.onNewIntent(intent);
- }
- }
- @Override
- public void handlePause(boolean keepRunning) {
- if (!isInitialized()) {
- return;
- }
- hasPausedEver = true;
- pluginManager.onPause(keepRunning);
- sendJavascriptEvent("pause");
-
- // If app doesn't want to run in background
- if (!keepRunning) {
- // Pause JavaScript timers. This affects all webviews within the app!
- engine.setPaused(true);
- }
- }
- @Override
- public void handleResume(boolean keepRunning) {
- if (!isInitialized()) {
- return;
- }
-
- // Resume JavaScript timers. This affects all webviews within the app!
- engine.setPaused(false);
- this.pluginManager.onResume(keepRunning);
-
- // In order to match the behavior of the other platforms, we only send onResume after an
- // onPause has occurred. The resume event might still be sent if the Activity was killed
- // while waiting for the result of an external Activity once the result is obtained
- if (hasPausedEver) {
- sendJavascriptEvent("resume");
- }
- }
- @Override
- public void handleStart() {
- if (!isInitialized()) {
- return;
- }
- pluginManager.onStart();
- }
- @Override
- public void handleStop() {
- if (!isInitialized()) {
- return;
- }
- pluginManager.onStop();
- }
- @Override
- public void handleDestroy() {
- if (!isInitialized()) {
- return;
- }
- // Cancel pending timeout timer.
- loadUrlTimeout++;
-
- // Forward to plugins
- this.pluginManager.onDestroy();
-
- // TODO: about:blank is a bit special (and the default URL for new frames)
- // We should use a blank data: url instead so it's more obvious
- this.loadUrl("about:blank");
-
- // TODO: Should not destroy webview until after about:blank is done loading.
- engine.destroy();
- hideCustomView();
- }
-
- protected class EngineClient implements CordovaWebViewEngine.Client {
- @Override
- public void clearLoadTimeoutTimer() {
- loadUrlTimeout++;
- }
-
- @Override
- public void onPageStarted(String newUrl) {
- LOG.d(TAG, "onPageDidNavigate(" + newUrl + ")");
- boundKeyCodes.clear();
- pluginManager.onReset();
- pluginManager.postMessage("onPageStarted", newUrl);
- }
-
- @Override
- public void onReceivedError(int errorCode, String description, String failingUrl) {
- clearLoadTimeoutTimer();
- JSONObject data = new JSONObject();
- try {
- data.put("errorCode", errorCode);
- data.put("description", description);
- data.put("url", failingUrl);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- pluginManager.postMessage("onReceivedError", data);
- }
-
- @Override
- public void onPageFinishedLoading(String url) {
- LOG.d(TAG, "onPageFinished(" + url + ")");
-
- clearLoadTimeoutTimer();
-
- // Broadcast message that page has loaded
- pluginManager.postMessage("onPageFinished", url);
-
- // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
- if (engine.getView().getVisibility() != View.VISIBLE) {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- Thread.sleep(2000);
- cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- pluginManager.postMessage("spinner", "stop");
- }
- });
- } catch (InterruptedException e) {
- }
- }
- });
- t.start();
- }
-
- // Shutdown if blank loaded
- if (url.equals("about:blank")) {
- pluginManager.postMessage("exit", null);
- }
- }
-
- @Override
- public Boolean onDispatchKeyEvent(KeyEvent event) {
- int keyCode = event.getKeyCode();
- boolean isBackButton = keyCode == KeyEvent.KEYCODE_BACK;
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- if (isBackButton && mCustomView != null) {
- return true;
- } else if (boundKeyCodes.contains(keyCode)) {
- return true;
- } else if (isBackButton) {
- return engine.canGoBack();
- }
- } else if (event.getAction() == KeyEvent.ACTION_UP) {
- if (isBackButton && mCustomView != null) {
- hideCustomView();
- return true;
- } else if (boundKeyCodes.contains(keyCode)) {
- String eventName = null;
- switch (keyCode) {
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- eventName = "volumedownbutton";
- break;
- case KeyEvent.KEYCODE_VOLUME_UP:
- eventName = "volumeupbutton";
- break;
- case KeyEvent.KEYCODE_SEARCH:
- eventName = "searchbutton";
- break;
- case KeyEvent.KEYCODE_MENU:
- eventName = "menubutton";
- break;
- case KeyEvent.KEYCODE_BACK:
- eventName = "backbutton";
- break;
- }
- if (eventName != null) {
- sendJavascriptEvent(eventName);
- return true;
- }
- } else if (isBackButton) {
- return engine.goBack();
- }
- }
- return null;
- }
-
- @Override
- public boolean onNavigationAttempt(String url) {
- // Give plugins the chance to handle the url
- if (pluginManager.onOverrideUrlLoading(url)) {
- return true;
- } else if (pluginManager.shouldAllowNavigation(url)) {
- return false;
- } else if (pluginManager.shouldOpenExternalUrl(url)) {
- showWebPage(url, true, false, null);
- return true;
- }
- LOG.w(TAG, "Blocked (possibly sub-frame) navigation to non-allowed URL: " + url);
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CoreAndroid.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CoreAndroid.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CoreAndroid.java
deleted file mode 100755
index e384f8d..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/CoreAndroid.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-package org.apache.cordova;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.telephony.TelephonyManager;
-import android.view.KeyEvent;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-
-/**
- * This class exposes methods in Cordova that can be called from JavaScript.
- */
-public class CoreAndroid extends CordovaPlugin {
-
- public static final String PLUGIN_NAME = "CoreAndroid";
- protected static final String TAG = "CordovaApp";
- private BroadcastReceiver telephonyReceiver;
- private CallbackContext messageChannel;
- private PluginResult pendingResume;
- private final Object messageChannelLock = new Object();
-
- /**
- * Send an event to be fired on the Javascript side.
- *
- * @param action The name of the event to be fired
- */
- public void fireJavascriptEvent(String action) {
- sendEventMessage(action);
- }
-
- /**
- * Sets the context of the Command. This can then be used to do things like
- * get file paths associated with the Activity.
- */
- @Override
- public void pluginInitialize() {
- this.initTelephonyReceiver();
- }
-
- /**
- * Executes the request and returns PluginResult.
- *
- * @param action The action to execute.
- * @param args JSONArry of arguments for the plugin.
- * @param callbackContext The callback context from which we were invoked.
- * @return A PluginResult object with a status and message.
- */
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- PluginResult.Status status = PluginResult.Status.OK;
- String result = "";
-
- try {
- if (action.equals("clearCache")) {
- this.clearCache();
- }
- else if (action.equals("show")) {
- // This gets called from JavaScript onCordovaReady to show the webview.
- // I recommend we change the name of the Message as spinner/stop is not
- // indicative of what this actually does (shows the webview).
- cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- webView.getPluginManager().postMessage("spinner", "stop");
- }
- });
- }
- else if (action.equals("loadUrl")) {
- this.loadUrl(args.getString(0), args.optJSONObject(1));
- }
- else if (action.equals("cancelLoadUrl")) {
- //this.cancelLoadUrl();
- }
- else if (action.equals("clearHistory")) {
- this.clearHistory();
- }
- else if (action.equals("backHistory")) {
- this.backHistory();
- }
- else if (action.equals("overrideButton")) {
- this.overrideButton(args.getString(0), args.getBoolean(1));
- }
- else if (action.equals("overrideBackbutton")) {
- this.overrideBackbutton(args.getBoolean(0));
- }
- else if (action.equals("exitApp")) {
- this.exitApp();
- }
- else if (action.equals("messageChannel")) {
- synchronized(messageChannelLock) {
- messageChannel = callbackContext;
- if (pendingResume != null) {
- sendEventMessage(pendingResume);
- pendingResume = null;
- }
- }
- return true;
- }
-
- callbackContext.sendPluginResult(new PluginResult(status, result));
- return true;
- } catch (JSONException e) {
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
- return false;
- }
- }
-
- //--------------------------------------------------------------------------
- // LOCAL METHODS
- //--------------------------------------------------------------------------
-
- /**
- * Clear the resource cache.
- */
- public void clearCache() {
- cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- webView.clearCache(true);
- }
- });
- }
-
- /**
- * Load the url into the webview.
- *
- * @param url
- * @param props Properties that can be passed in to the Cordova activity (i.e. loadingDialog, wait, ...)
- * @throws JSONException
- */
- public void loadUrl(String url, JSONObject props) throws JSONException {
- LOG.d("App", "App.loadUrl("+url+","+props+")");
- int wait = 0;
- boolean openExternal = false;
- boolean clearHistory = false;
-
- // If there are properties, then set them on the Activity
- HashMap<String, Object> params = new HashMap<String, Object>();
- if (props != null) {
- JSONArray keys = props.names();
- for (int i = 0; i < keys.length(); i++) {
- String key = keys.getString(i);
- if (key.equals("wait")) {
- wait = props.getInt(key);
- }
- else if (key.equalsIgnoreCase("openexternal")) {
- openExternal = props.getBoolean(key);
- }
- else if (key.equalsIgnoreCase("clearhistory")) {
- clearHistory = props.getBoolean(key);
- }
- else {
- Object value = props.get(key);
- if (value == null) {
-
- }
- else if (value.getClass().equals(String.class)) {
- params.put(key, (String)value);
- }
- else if (value.getClass().equals(Boolean.class)) {
- params.put(key, (Boolean)value);
- }
- else if (value.getClass().equals(Integer.class)) {
- params.put(key, (Integer)value);
- }
- }
- }
- }
-
- // If wait property, then delay loading
-
- if (wait > 0) {
- try {
- synchronized(this) {
- this.wait(wait);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- this.webView.showWebPage(url, openExternal, clearHistory, params);
- }
-
- /**
- * Clear page history for the app.
- */
- public void clearHistory() {
- cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- webView.clearHistory();
- }
- });
- }
-
- /**
- * Go to previous page displayed.
- * This is the same as pressing the backbutton on Android device.
- */
- public void backHistory() {
- cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- webView.backHistory();
- }
- });
- }
-
- /**
- * Override the default behavior of the Android back button.
- * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
- *
- * @param override T=override, F=cancel override
- */
- public void overrideBackbutton(boolean override) {
- LOG.i("App", "WARNING: Back Button Default Behavior will be overridden. The backbutton event will be fired!");
- webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_BACK, override);
- }
-
- /**
- * Override the default behavior of the Android volume buttons.
- * If overridden, when the volume button is pressed, the "volume[up|down]button" JavaScript event will be fired.
- *
- * @param button volumeup, volumedown
- * @param override T=override, F=cancel override
- */
- public void overrideButton(String button, boolean override) {
- LOG.i("App", "WARNING: Volume Button Default Behavior will be overridden. The volume event will be fired!");
- if (button.equals("volumeup")) {
- webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_UP, override);
- }
- else if (button.equals("volumedown")) {
- webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_DOWN, override);
- }
- else if (button.equals("menubutton")) {
- webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_MENU, override);
- }
- }
-
- /**
- * Return whether the Android back button is overridden by the user.
- *
- * @return boolean
- */
- public boolean isBackbuttonOverridden() {
- return webView.isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK);
- }
-
- /**
- * Exit the Android application.
- */
- public void exitApp() {
- this.webView.getPluginManager().postMessage("exit", null);
- }
-
-
- /**
- * Listen for telephony events: RINGING, OFFHOOK and IDLE
- * Send these events to all plugins using
- * CordovaActivity.onMessage("telephone", "ringing" | "offhook" | "idle")
- */
- private void initTelephonyReceiver() {
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
- //final CordovaInterface mycordova = this.cordova;
- this.telephonyReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(Context context, Intent intent) {
-
- // If state has changed
- if ((intent != null) && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
- if (intent.hasExtra(TelephonyManager.EXTRA_STATE)) {
- String extraData = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
- if (extraData.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
- LOG.i(TAG, "Telephone RINGING");
- webView.getPluginManager().postMessage("telephone", "ringing");
- }
- else if (extraData.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
- LOG.i(TAG, "Telephone OFFHOOK");
- webView.getPluginManager().postMessage("telephone", "offhook");
- }
- else if (extraData.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
- LOG.i(TAG, "Telephone IDLE");
- webView.getPluginManager().postMessage("telephone", "idle");
- }
- }
- }
- }
- };
-
- // Register the receiver
- webView.getContext().registerReceiver(this.telephonyReceiver, intentFilter);
- }
-
- private void sendEventMessage(String action) {
- JSONObject obj = new JSONObject();
- try {
- obj.put("action", action);
- } catch (JSONException e) {
- LOG.e(TAG, "Failed to create event message", e);
- }
- sendEventMessage(new PluginResult(PluginResult.Status.OK, obj));
- }
-
- private void sendEventMessage(PluginResult payload) {
- payload.setKeepCallback(true);
- if (messageChannel != null) {
- messageChannel.sendPluginResult(payload);
- }
- }
-
- /*
- * Unregister the receiver
- *
- */
- public void onDestroy()
- {
- webView.getContext().unregisterReceiver(this.telephonyReceiver);
- }
-
- /**
- * Used to send the resume event in the case that the Activity is destroyed by the OS
- *
- * @param resumeEvent PluginResult containing the payload for the resume event to be fired
- */
- public void sendResumeEvent(PluginResult resumeEvent) {
- // This operation must be synchronized because plugin results that trigger resume
- // events can be processed asynchronously
- synchronized(messageChannelLock) {
- if (messageChannel != null) {
- sendEventMessage(resumeEvent);
- } else {
- // Might get called before the page loads, so we need to store it until the
- // messageChannel gets created
- this.pendingResume = resumeEvent;
- }
- }
- }
-
- /*
- * This needs to be implemented if you wish to use the Camera Plugin or other plugins
- * that read the Build Configuration.
- *
- * Thanks to Phil@Medtronic and Graham Borland for finding the answer and posting it to
- * StackOverflow. This is annoying as hell!
- *
- */
-
- public static Object getBuildConfigValue(Context ctx, String key)
- {
- try
- {
- Class<?> clazz = Class.forName(ctx.getPackageName() + ".BuildConfig");
- Field field = clazz.getField(key);
- return field.get(null);
- } catch (ClassNotFoundException e) {
- LOG.d(TAG, "Unable to get the BuildConfig, is this built with ANT?");
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- LOG.d(TAG, key + " is not a valid field. Check your build.gradle");
- } catch (IllegalAccessException e) {
- LOG.d(TAG, "Illegal Access Exception: Let's print a stack trace.");
- e.printStackTrace();
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d164a88f/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java b/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java
deleted file mode 100644
index acc65c6..0000000
--- a/spec-plugman/projects/android/CordovaLib/src/org/apache/cordova/ExposedJsApi.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-package org.apache.cordova;
-
-import org.json.JSONException;
-
-/*
- * Any exposed Javascript API MUST implement these three things!
- */
-public interface ExposedJsApi {
- public String exec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException;
- public void setNativeToJsBridgeMode(int bridgeSecret, int value) throws IllegalAccessException;
- public String retrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException;
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org