diff options
author | Nathan Harold <nharold@google.com> | 2016-02-05 12:29:08 -0800 |
---|---|---|
committer | Nathan Harold <nharold@google.com> | 2016-02-05 12:30:30 -0800 |
commit | 9b4e3a1e8d40d4f81ce56a5d0fade3b822e304ec (patch) | |
tree | 7eca87481153e719be9b95ccf41eaacf0fb8be88 | |
parent | a037f745f414cccfab230c4f3db1714ae830ef4c (diff) | |
download | platform_packages_apps_Test_connectivity-9b4e3a1e8d40d4f81ce56a5d0fade3b822e304ec.tar.gz platform_packages_apps_Test_connectivity-9b4e3a1e8d40d4f81ce56a5d0fade3b822e304ec.tar.bz2 platform_packages_apps_Test_connectivity-9b4e3a1e8d40d4f81ce56a5d0fade3b822e304ec.zip |
Removing the now-unusable HtmlInterpreter
-Because Webview security was increased in API level 21, views
can no longer be launched external to apps. Thus this capability
no longer works. Leaving it in will cause SL4A to throw security
exceptions.
Bug: 26984426
Change-Id: I1532b9bef615e8ceb2d14210bfe376ce2538cf2d
6 files changed, 2 insertions, 167 deletions
diff --git a/sl4a/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java b/sl4a/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java index ccd509e..7eb4e02 100644 --- a/sl4a/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java +++ b/sl4a/Common/src/com/googlecode/android_scripting/facade/ui/UiFacade.java @@ -32,8 +32,6 @@ import com.googlecode.android_scripting.FutureActivityTaskExecutor; import com.googlecode.android_scripting.Log; import com.googlecode.android_scripting.facade.EventFacade; import com.googlecode.android_scripting.facade.FacadeManager; -import com.googlecode.android_scripting.interpreter.html.HtmlActivityTask; -import com.googlecode.android_scripting.interpreter.html.HtmlInterpreter; import com.googlecode.android_scripting.jsonrpc.RpcReceiver; import com.googlecode.android_scripting.rpc.Rpc; import com.googlecode.android_scripting.rpc.RpcDefault; @@ -450,31 +448,6 @@ public class UiFacade extends RpcReceiver { } } - /** - * See <a href=http://code.google.com/p/android-scripting/wiki/UsingWebView>wiki page</a> for more - * detail. - */ - @Rpc(description = "Display a WebView with the given URL.") - public void webViewShow( - @RpcParameter(name = "url") String url, - @RpcParameter(name = "wait", description = "block until the user exits the WebView") @RpcOptional Boolean wait) - throws IOException { - String jsonSrc = FileUtils.readFromAssetsFile(mService, HtmlInterpreter.JSON_FILE); - String AndroidJsSrc = FileUtils.readFromAssetsFile(mService, HtmlInterpreter.ANDROID_JS_FILE); - HtmlActivityTask task = new HtmlActivityTask(mManager, AndroidJsSrc, jsonSrc, url, false); - mTaskQueue.execute(task); - if (wait != null && wait) { - try { - task.getResult(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - } - - /** - * Context menus are used primarily with {@link #webViewShow} - */ @Rpc(description = "Adds a new item to context menu.") public void addContextMenuItem( @RpcParameter(name = "label", description = "label for this menu item") String label, @@ -707,7 +680,6 @@ public class UiFacade extends RpcReceiver { @Override public void shutdown() { fullDismiss(); - HtmlActivityTask.shutdown(); } private class UiMenuItem { @@ -733,4 +705,4 @@ public class UiFacade extends RpcReceiver { }; } } -}
\ No newline at end of file +} diff --git a/sl4a/Common/src/com/googlecode/android_scripting/interpreter/InterpreterConfiguration.java b/sl4a/Common/src/com/googlecode/android_scripting/interpreter/InterpreterConfiguration.java index 02bd654..27f9b7a 100644 --- a/sl4a/Common/src/com/googlecode/android_scripting/interpreter/InterpreterConfiguration.java +++ b/sl4a/Common/src/com/googlecode/android_scripting/interpreter/InterpreterConfiguration.java @@ -31,7 +31,6 @@ import android.net.Uri; import com.googlecode.android_scripting.Log; import com.googlecode.android_scripting.SingleThreadExecutor; -import com.googlecode.android_scripting.interpreter.html.HtmlInterpreter; import com.googlecode.android_scripting.interpreter.shell.ShellInterpreter; import java.io.IOException; @@ -216,11 +215,6 @@ public class InterpreterConfiguration { mContext = context; mInterpreterSet = new CopyOnWriteArraySet<Interpreter>(); mInterpreterSet.add(new ShellInterpreter()); - try { - mInterpreterSet.add(new HtmlInterpreter(mContext)); - } catch (IOException e) { - Log.e("Failed to instantiate HtmlInterpreter.", e); - } mObserverSet = new CopyOnWriteArraySet<ConfigurationObserver>(); IntentFilter filter = new IntentFilter(); filter.addAction(InterpreterConstants.ACTION_INTERPRETER_ADDED); diff --git a/sl4a/Common/src/com/googlecode/android_scripting/interpreter/html/HtmlInterpreter.java b/sl4a/Common/src/com/googlecode/android_scripting/interpreter/html/HtmlInterpreter.java deleted file mode 100644 index 3f86ff0..0000000 --- a/sl4a/Common/src/com/googlecode/android_scripting/interpreter/html/HtmlInterpreter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2016 Google Inc. - * - * Licensed 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 com.googlecode.android_scripting.interpreter.html; - -import android.content.Context; - -import com.googlecode.android_scripting.FileUtils; -import com.googlecode.android_scripting.interpreter.Interpreter; -import com.googlecode.android_scripting.language.HtmlLanguage; - -import java.io.IOException; - -public class HtmlInterpreter extends Interpreter { - - public static final String HTML = "html"; - public static final String HTML_EXTENSION = ".html"; - - public static final String JSON_FILE = "json2.js"; - public static final String ANDROID_JS_FILE = "android.js"; - public static final String HTML_NICE_NAME = "HTML and JavaScript"; - - private final String mJson; - private final String mAndroidJs; - - public HtmlInterpreter(Context context) throws IOException { - setExtension(HTML_EXTENSION); - setName(HTML); - setNiceName(HTML_NICE_NAME); - setInteractiveCommand(""); - setScriptCommand("%s"); - setLanguage(new HtmlLanguage()); - setHasInteractiveMode(false); - mJson = FileUtils.readFromAssetsFile(context, JSON_FILE); - mAndroidJs = FileUtils.readFromAssetsFile(context, ANDROID_JS_FILE); - } - - public boolean hasInterpreterArchive() { - return false; - } - - public boolean hasExtrasArchive() { - return false; - } - - public boolean hasScriptsArchive() { - return false; - } - - public int getVersion() { - return 0; - } - - @Override - public boolean isUninstallable() { - return false; - } - - @Override - public boolean isInstalled() { - return true; - } - - public String getJsonSource() { - return mJson; - } - - public String getAndroidJsSource() { - return mAndroidJs; - } -} diff --git a/sl4a/ScriptingLayer/src/com/googlecode/android_scripting/ScriptLauncher.java b/sl4a/ScriptingLayer/src/com/googlecode/android_scripting/ScriptLauncher.java index 865f077..a0f3eb8 100644 --- a/sl4a/ScriptingLayer/src/com/googlecode/android_scripting/ScriptLauncher.java +++ b/sl4a/ScriptingLayer/src/com/googlecode/android_scripting/ScriptLauncher.java @@ -24,8 +24,6 @@ import com.googlecode.android_scripting.facade.FacadeManager; import com.googlecode.android_scripting.interpreter.Interpreter; import com.googlecode.android_scripting.interpreter.InterpreterConfiguration; import com.googlecode.android_scripting.interpreter.InterpreterProcess; -import com.googlecode.android_scripting.interpreter.html.HtmlActivityTask; -import com.googlecode.android_scripting.interpreter.html.HtmlInterpreter; import java.io.File; @@ -35,28 +33,6 @@ public class ScriptLauncher { // Utility class. } - public static HtmlActivityTask launchHtmlScript(File script, Service service, Intent intent, - InterpreterConfiguration config) { - if (!script.exists()) { - throw new RuntimeException("No such script to launch."); - } - HtmlInterpreter interpreter = - (HtmlInterpreter) config.getInterpreterByName(HtmlInterpreter.HTML); - if (interpreter == null) { - throw new RuntimeException("HtmlInterpreter is not available."); - } - final FacadeManager manager = - new FacadeManager(FacadeConfiguration.getSdkLevel(), service, intent, - FacadeConfiguration.getFacadeClasses()); - FutureActivityTaskExecutor executor = - ((BaseApplication) service.getApplication()).getTaskExecutor(); - final HtmlActivityTask task = - new HtmlActivityTask(manager, interpreter.getAndroidJsSource(), - interpreter.getJsonSource(), script.getAbsolutePath(), true); - executor.execute(task); - return task; - } - public static InterpreterProcess launchInterpreter(final AndroidProxy proxy, Intent intent, InterpreterConfiguration config, Runnable shutdownHook) { Interpreter interpreter; @@ -95,4 +71,4 @@ public class ScriptLauncher { } return process; } -}
\ No newline at end of file +} diff --git a/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/InterpreterManager.java b/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/InterpreterManager.java index dcba601..1cd2fc2 100644 --- a/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/InterpreterManager.java +++ b/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/InterpreterManager.java @@ -47,7 +47,6 @@ import com.googlecode.android_scripting.R; import com.googlecode.android_scripting.interpreter.Interpreter; import com.googlecode.android_scripting.interpreter.InterpreterConfiguration; import com.googlecode.android_scripting.interpreter.InterpreterConfiguration.ConfigurationObserver; -import com.googlecode.android_scripting.interpreter.html.HtmlInterpreter; import java.net.URL; import java.util.ArrayList; @@ -172,9 +171,6 @@ public class InterpreterManager extends ListActivity { } private void launchTerminal(Interpreter interpreter) { - if (interpreter instanceof HtmlInterpreter) { - return; - } Intent intent = new Intent(this, ScriptingLayerService.class); intent.setAction(Constants.ACTION_LAUNCH_INTERPRETER); intent.putExtra(Constants.EXTRA_INTERPRETER_NAME, interpreter.getName()); diff --git a/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/ScriptingLayerService.java b/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/ScriptingLayerService.java index b39c984..80b7aae 100644 --- a/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/ScriptingLayerService.java +++ b/sl4a/ScriptingLayerForAndroid/src/com/googlecode/android_scripting/activity/ScriptingLayerService.java @@ -39,7 +39,6 @@ import com.googlecode.android_scripting.ScriptLauncher; import com.googlecode.android_scripting.ScriptProcess; import com.googlecode.android_scripting.interpreter.InterpreterConfiguration; import com.googlecode.android_scripting.interpreter.InterpreterProcess; -import com.googlecode.android_scripting.interpreter.html.HtmlInterpreter; import com.googlecode.android_scripting.interpreter.shell.ShellInterpreter; import org.connectbot.ConsoleActivity; @@ -173,19 +172,6 @@ public class ScriptingLayerService extends ForegroundService { return START_REDELIVER_INTENT; } - String name = intent.getStringExtra(Constants.EXTRA_SCRIPT_PATH); - if (name != null && name.endsWith(HtmlInterpreter.HTML_EXTENSION)) { - if (Integer.valueOf(android.os.Build.VERSION.SDK) > 21) { - Log.e(LOG_TAG, "Starting a WebViewClient not permitted for your SDK Version."); - } else { - launchHtmlScript(intent); - } - if (mProcessMap.isEmpty()) { - stopSelf(startId); - } - return START_REDELIVER_INTENT; - } - //TODO: b/26538940 We need to go back to a strict policy and fix the problems StrictMode.ThreadPolicy sl4aPolicy = new StrictMode.ThreadPolicy.Builder() .detectAll() @@ -252,11 +238,6 @@ public class ScriptingLayerService extends ForegroundService { return androidProxy; } - private void launchHtmlScript(Intent intent) { - File script = new File(intent.getStringExtra(Constants.EXTRA_SCRIPT_PATH)); - ScriptLauncher.launchHtmlScript(script, this, intent, mInterpreterConfiguration); - } - private ScriptProcess launchScript(Intent intent, AndroidProxy proxy) { final int port = proxy.getAddress().getPort(); File script = new File(intent.getStringExtra(Constants.EXTRA_SCRIPT_PATH)); |