mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-27 04:10:11 +08:00
ci: Set up CodeQL analysis w/ fixes (#1711)
* ci: Set up CodeQL analysis * spec: disable allowBackup in testing * ci: do not check cordova.js - convered in cordova-js repo * chore: add missing @Override annotation
This commit is contained in:
parent
7fa4a65d0a
commit
ed8e5d2f0a
26
.github/workflows/ci.yml
vendored
26
.github/workflows/ci.yml
vendored
@ -31,15 +31,12 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
- name: set up JDK 11
|
- uses: actions/setup-java@v4
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
@ -50,6 +47,21 @@ jobs:
|
|||||||
npm --version
|
npm --version
|
||||||
gradle --version
|
gradle --version
|
||||||
|
|
||||||
|
# "bin/templates/platform_www/cordova.js" is ignored because it is a generated file.
|
||||||
|
# It contains mixed content from the npm package "cordova-js" and "./cordova-js-src".
|
||||||
|
# The report might not be resolvable because of the external package.
|
||||||
|
# If the report is related to this repository, it would be detected when scanning "./cordova-js-src".
|
||||||
|
- uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: javascript, java-kotlin
|
||||||
|
queries: security-and-quality
|
||||||
|
config: |
|
||||||
|
paths-ignore:
|
||||||
|
- coverage
|
||||||
|
- node_modules
|
||||||
|
- templates/project/assets/www/cordova.js
|
||||||
|
- test/androidx/app/src/main/assets/www/cordova.js
|
||||||
|
|
||||||
- name: npm install and test
|
- name: npm install and test
|
||||||
run: |
|
run: |
|
||||||
npm i
|
npm i
|
||||||
@ -57,6 +69,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
|
|
||||||
|
- uses: github/codeql-action/analyze@v3
|
||||||
|
|
||||||
- uses: codecov/codecov-action@v4
|
- uses: codecov/codecov-action@v4
|
||||||
if: success()
|
if: success()
|
||||||
with:
|
with:
|
||||||
|
@ -391,6 +391,7 @@ public class CordovaActivity extends AppCompatActivity {
|
|||||||
if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
|
if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
|
||||||
// Load URL on UI thread
|
// Load URL on UI thread
|
||||||
me.runOnUiThread(new Runnable() {
|
me.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
me.appView.showWebPage(errorUrl, false, true, null);
|
me.appView.showWebPage(errorUrl, false, true, null);
|
||||||
}
|
}
|
||||||
@ -400,6 +401,7 @@ public class CordovaActivity extends AppCompatActivity {
|
|||||||
else {
|
else {
|
||||||
final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
|
final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
|
||||||
me.runOnUiThread(new Runnable() {
|
me.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (exit) {
|
if (exit) {
|
||||||
me.appView.getView().setVisibility(View.GONE);
|
me.appView.getView().setVisibility(View.GONE);
|
||||||
@ -416,6 +418,7 @@ public class CordovaActivity extends AppCompatActivity {
|
|||||||
public void displayError(final String title, final String message, final String button, final boolean exit) {
|
public void displayError(final String title, final String message, final String button, final boolean exit) {
|
||||||
final CordovaActivity me = this;
|
final CordovaActivity me = this;
|
||||||
me.runOnUiThread(new Runnable() {
|
me.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
AlertDialog.Builder dlg = new AlertDialog.Builder(me);
|
AlertDialog.Builder dlg = new AlertDialog.Builder(me);
|
||||||
@ -424,6 +427,7 @@ public class CordovaActivity extends AppCompatActivity {
|
|||||||
dlg.setCancelable(false);
|
dlg.setCancelable(false);
|
||||||
dlg.setPositiveButton(button,
|
dlg.setPositiveButton(button,
|
||||||
new AlertDialog.OnClickListener() {
|
new AlertDialog.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if (exit) {
|
if (exit) {
|
||||||
@ -488,6 +492,7 @@ public class CordovaActivity extends AppCompatActivity {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
cordovaInterface.onSaveInstanceState(outState);
|
cordovaInterface.onSaveInstanceState(outState);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
@ -41,6 +41,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
|
|||||||
* Cancel this request
|
* Cancel this request
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public void cancel()
|
public void cancel()
|
||||||
{
|
{
|
||||||
request.cancel();
|
request.cancel();
|
||||||
@ -50,6 +51,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
|
|||||||
* Returns the host name of the server requesting the certificate.
|
* Returns the host name of the server requesting the certificate.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public String getHost()
|
public String getHost()
|
||||||
{
|
{
|
||||||
return request.getHost();
|
return request.getHost();
|
||||||
@ -59,6 +61,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
|
|||||||
* Returns the acceptable types of asymmetric keys (can be null).
|
* Returns the acceptable types of asymmetric keys (can be null).
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public String[] getKeyTypes()
|
public String[] getKeyTypes()
|
||||||
{
|
{
|
||||||
return request.getKeyTypes();
|
return request.getKeyTypes();
|
||||||
@ -68,6 +71,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
|
|||||||
* Returns the port number of the server requesting the certificate.
|
* Returns the port number of the server requesting the certificate.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public int getPort()
|
public int getPort()
|
||||||
{
|
{
|
||||||
return request.getPort();
|
return request.getPort();
|
||||||
@ -77,6 +81,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
|
|||||||
* Returns the acceptable certificate issuers for the certificate matching the private key (can be null).
|
* Returns the acceptable certificate issuers for the certificate matching the private key (can be null).
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public Principal[] getPrincipals()
|
public Principal[] getPrincipals()
|
||||||
{
|
{
|
||||||
return request.getPrincipals();
|
return request.getPrincipals();
|
||||||
@ -86,6 +91,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
|
|||||||
* Ignore the request for now. Do not remember user's choice.
|
* Ignore the request for now. Do not remember user's choice.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public void ignore()
|
public void ignore()
|
||||||
{
|
{
|
||||||
request.ignore();
|
request.ignore();
|
||||||
@ -98,6 +104,7 @@ public class CordovaClientCertRequest implements ICordovaClientCertRequest {
|
|||||||
* @param chain The certificate chain
|
* @param chain The certificate chain
|
||||||
*/
|
*/
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public void proceed(PrivateKey privateKey, X509Certificate[] chain)
|
public void proceed(PrivateKey privateKey, X509Certificate[] chain)
|
||||||
{
|
{
|
||||||
request.proceed(privateKey, chain);
|
request.proceed(privateKey, chain);
|
||||||
|
@ -43,18 +43,21 @@ public class CordovaDialogsHelper {
|
|||||||
dlg.setCancelable(true);
|
dlg.setCancelable(true);
|
||||||
dlg.setPositiveButton(android.R.string.ok,
|
dlg.setPositiveButton(android.R.string.ok,
|
||||||
new AlertDialog.OnClickListener() {
|
new AlertDialog.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
result.gotResult(true, null);
|
result.gotResult(true, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.setOnCancelListener(
|
dlg.setOnCancelListener(
|
||||||
new DialogInterface.OnCancelListener() {
|
new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
result.gotResult(false, null);
|
result.gotResult(false, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||||
//DO NOTHING
|
//DO NOTHING
|
||||||
|
@Override
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK)
|
if (keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
{
|
{
|
||||||
@ -75,24 +78,28 @@ public class CordovaDialogsHelper {
|
|||||||
dlg.setCancelable(true);
|
dlg.setCancelable(true);
|
||||||
dlg.setPositiveButton(android.R.string.ok,
|
dlg.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
result.gotResult(true, null);
|
result.gotResult(true, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.setNegativeButton(android.R.string.cancel,
|
dlg.setNegativeButton(android.R.string.cancel,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
result.gotResult(false, null);
|
result.gotResult(false, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.setOnCancelListener(
|
dlg.setOnCancelListener(
|
||||||
new DialogInterface.OnCancelListener() {
|
new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
result.gotResult(false, null);
|
result.gotResult(false, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||||
//DO NOTHING
|
//DO NOTHING
|
||||||
|
@Override
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK)
|
if (keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
{
|
{
|
||||||
@ -126,6 +133,7 @@ public class CordovaDialogsHelper {
|
|||||||
dlg.setCancelable(false);
|
dlg.setCancelable(false);
|
||||||
dlg.setPositiveButton(android.R.string.ok,
|
dlg.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String userText = input.getText().toString();
|
String userText = input.getText().toString();
|
||||||
result.gotResult(true, userText);
|
result.gotResult(true, userText);
|
||||||
@ -133,6 +141,7 @@ public class CordovaDialogsHelper {
|
|||||||
});
|
});
|
||||||
dlg.setNegativeButton(android.R.string.cancel,
|
dlg.setNegativeButton(android.R.string.cancel,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
result.gotResult(false, null);
|
result.gotResult(false, null);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ public class CordovaHttpAuthHandler implements ICordovaHttpAuthHandler {
|
|||||||
/**
|
/**
|
||||||
* Instructs the WebView to cancel the authentication request.
|
* Instructs the WebView to cancel the authentication request.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void cancel () {
|
public void cancel () {
|
||||||
this.handler.cancel();
|
this.handler.cancel();
|
||||||
}
|
}
|
||||||
@ -45,6 +46,7 @@ public class CordovaHttpAuthHandler implements ICordovaHttpAuthHandler {
|
|||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void proceed (String username, String password) {
|
public void proceed (String username, String password) {
|
||||||
this.handler.proceed(username, password);
|
this.handler.proceed(username, password);
|
||||||
}
|
}
|
||||||
|
@ -223,18 +223,21 @@ public class CordovaInterfaceImpl implements CordovaInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void requestPermission(CordovaPlugin plugin, int requestCode, String permission) {
|
public void requestPermission(CordovaPlugin plugin, int requestCode, String permission) {
|
||||||
String[] permissions = new String [1];
|
String[] permissions = new String [1];
|
||||||
permissions[0] = permission;
|
permissions[0] = permission;
|
||||||
requestPermissions(plugin, requestCode, permissions);
|
requestPermissions(plugin, requestCode, permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions) {
|
public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions) {
|
||||||
int mappedRequestCode = permissionResultCallbacks.registerCallback(plugin, requestCode);
|
int mappedRequestCode = permissionResultCallbacks.registerCallback(plugin, requestCode);
|
||||||
getActivity().requestPermissions(permissions, mappedRequestCode);
|
getActivity().requestPermissions(permissions, mappedRequestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasPermission(String permission)
|
public boolean hasPermission(String permission)
|
||||||
{
|
{
|
||||||
return PackageManager.PERMISSION_GRANTED == activity.checkSelfPermission(permission);
|
return PackageManager.PERMISSION_GRANTED == activity.checkSelfPermission(permission);
|
||||||
|
@ -149,6 +149,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
|
|
||||||
// Timeout error method
|
// Timeout error method
|
||||||
final Runnable loadError = new Runnable() {
|
final Runnable loadError = new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
stopLoading();
|
stopLoading();
|
||||||
LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
|
LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!");
|
||||||
@ -168,6 +169,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
|
|
||||||
// Timeout timer method
|
// Timeout timer method
|
||||||
final Runnable timeoutCheck = new Runnable() {
|
final Runnable timeoutCheck = new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@ -189,6 +191,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
if (cordova.getActivity() != null) {
|
if (cordova.getActivity() != null) {
|
||||||
final boolean _recreatePlugins = recreatePlugins;
|
final boolean _recreatePlugins = recreatePlugins;
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (loadUrlTimeoutValue > 0) {
|
if (loadUrlTimeoutValue > 0) {
|
||||||
cordova.getThreadPool().execute(timeoutCheck);
|
cordova.getThreadPool().execute(timeoutCheck);
|
||||||
@ -579,11 +582,13 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
|||||||
// Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
|
// 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) {
|
if (engine.getView().getVisibility() != View.VISIBLE) {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
if (cordova.getActivity() != null) {
|
if (cordova.getActivity() != null) {
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pluginManager.postMessage("spinner", "stop");
|
pluginManager.postMessage("spinner", "stop");
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ public class CoreAndroid extends CordovaPlugin {
|
|||||||
* @param callbackContext The callback context from which we were invoked.
|
* @param callbackContext The callback context from which we were invoked.
|
||||||
* @return A PluginResult object with a status and message.
|
* @return A PluginResult object with a status and message.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||||
PluginResult.Status status = PluginResult.Status.OK;
|
PluginResult.Status status = PluginResult.Status.OK;
|
||||||
String result = "";
|
String result = "";
|
||||||
@ -86,6 +87,7 @@ public class CoreAndroid extends CordovaPlugin {
|
|||||||
// I recommend we change the name of the Message as spinner/stop is not
|
// I recommend we change the name of the Message as spinner/stop is not
|
||||||
// indicative of what this actually does (shows the webview).
|
// indicative of what this actually does (shows the webview).
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webView.getPluginManager().postMessage("spinner", "stop");
|
webView.getPluginManager().postMessage("spinner", "stop");
|
||||||
}
|
}
|
||||||
@ -144,6 +146,7 @@ public class CoreAndroid extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webView.clearCache();
|
webView.clearCache();
|
||||||
}
|
}
|
||||||
@ -215,6 +218,7 @@ public class CoreAndroid extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
public void clearHistory() {
|
public void clearHistory() {
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webView.clearHistory();
|
webView.clearHistory();
|
||||||
}
|
}
|
||||||
@ -227,6 +231,7 @@ public class CoreAndroid extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
public void backHistory() {
|
public void backHistory() {
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webView.backHistory();
|
webView.backHistory();
|
||||||
}
|
}
|
||||||
@ -353,6 +358,7 @@ public class CoreAndroid extends CordovaPlugin {
|
|||||||
* Unregister the receiver
|
* Unregister the receiver
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onDestroy()
|
public void onDestroy()
|
||||||
{
|
{
|
||||||
webView.getContext().unregisterReceiver(this.telephonyReceiver);
|
webView.getContext().unregisterReceiver(this.telephonyReceiver);
|
||||||
|
@ -302,6 +302,7 @@ public class NativeToJsMessageQueue {
|
|||||||
@Override
|
@Override
|
||||||
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
|
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String js = queue.popAndEncodeAsJs();
|
String js = queue.popAndEncodeAsJs();
|
||||||
if (js != null) {
|
if (js != null) {
|
||||||
@ -330,6 +331,7 @@ public class NativeToJsMessageQueue {
|
|||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
delegate.runOnUiThread(new Runnable() {
|
delegate.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
online = false;
|
online = false;
|
||||||
// If the following call triggers a notifyOfFlush, then ignore it.
|
// If the following call triggers a notifyOfFlush, then ignore it.
|
||||||
@ -342,6 +344,7 @@ public class NativeToJsMessageQueue {
|
|||||||
@Override
|
@Override
|
||||||
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
|
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
|
||||||
delegate.runOnUiThread(new Runnable() {
|
delegate.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!queue.isEmpty()) {
|
if (!queue.isEmpty()) {
|
||||||
ignoreNextFlush = false;
|
ignoreNextFlush = false;
|
||||||
@ -372,6 +375,7 @@ public class NativeToJsMessageQueue {
|
|||||||
@Override
|
@Override
|
||||||
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
|
public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
|
||||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String js = queue.popAndEncodeAsJs();
|
String js = queue.popAndEncodeAsJs();
|
||||||
if (js != null) {
|
if (js != null) {
|
||||||
|
@ -41,22 +41,27 @@ class SystemCookieManager implements ICordovaCookieManager {
|
|||||||
cookieManager.setAcceptFileSchemeCookies(true);
|
cookieManager.setAcceptFileSchemeCookies(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setCookiesEnabled(boolean accept) {
|
public void setCookiesEnabled(boolean accept) {
|
||||||
cookieManager.setAcceptCookie(accept);
|
cookieManager.setAcceptCookie(accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setCookie(final String url, final String value) {
|
public void setCookie(final String url, final String value) {
|
||||||
cookieManager.setCookie(url, value);
|
cookieManager.setCookie(url, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getCookie(final String url) {
|
public String getCookie(final String url) {
|
||||||
return cookieManager.getCookie(url);
|
return cookieManager.getCookie(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void clearCookies() {
|
public void clearCookies() {
|
||||||
cookieManager.removeAllCookies(null);
|
cookieManager.removeAllCookies(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
cookieManager.flush();
|
cookieManager.flush();
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,19 @@ class SystemExposedJsApi implements ExposedJsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
|
@Override
|
||||||
public String exec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException {
|
public String exec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException {
|
||||||
return bridge.jsExec(bridgeSecret, service, action, callbackId, arguments);
|
return bridge.jsExec(bridgeSecret, service, action, callbackId, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
|
@Override
|
||||||
public void setNativeToJsBridgeMode(int bridgeSecret, int value) throws IllegalAccessException {
|
public void setNativeToJsBridgeMode(int bridgeSecret, int value) throws IllegalAccessException {
|
||||||
bridge.jsSetNativeToJsBridgeMode(bridgeSecret, value);
|
bridge.jsSetNativeToJsBridgeMode(bridgeSecret, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
|
@Override
|
||||||
public String retrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException {
|
public String retrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException {
|
||||||
return bridge.jsRetrieveJsMessages(bridgeSecret, fromOnlineEvent);
|
return bridge.jsRetrieveJsMessages(bridgeSecret, fromOnlineEvent);
|
||||||
}
|
}
|
||||||
|
@ -321,6 +321,7 @@ public class SystemWebChromeClient extends WebChromeClient {
|
|||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPermissionRequest(final PermissionRequest request) {
|
public void onPermissionRequest(final PermissionRequest request) {
|
||||||
LOG.d(LOG_TAG, "onPermissionRequest: " + Arrays.toString(request.getResources()));
|
LOG.d(LOG_TAG, "onPermissionRequest: " + Arrays.toString(request.getResources()));
|
||||||
request.grant(request.getResources());
|
request.grant(request.getResources());
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
package="com.example.anis.myapplication">
|
package="com.example.anis.myapplication">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="false"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
@ -69,30 +69,35 @@ public class BackButtonMultipageTest {
|
|||||||
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
||||||
|
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webInterface.sendJavascript("window.location = 'sample2.html';");
|
webInterface.sendJavascript("window.location = 'sample2.html';");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertPageSample(SAMPLE2_URL);
|
assertPageSample(SAMPLE2_URL);
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webInterface.sendJavascript("window.location = 'sample3.html';");
|
webInterface.sendJavascript("window.location = 'sample3.html';");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertPageSample(SAMPLE3_URL);
|
assertPageSample(SAMPLE3_URL);
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertTrue(webInterface.backHistory());
|
assertTrue(webInterface.backHistory());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertPageSample(SAMPLE2_URL);
|
assertPageSample(SAMPLE2_URL);
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertTrue(webInterface.backHistory());
|
assertTrue(webInterface.backHistory());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertFalse(webInterface.backHistory());
|
assertFalse(webInterface.backHistory());
|
||||||
}
|
}
|
||||||
@ -105,30 +110,35 @@ public class BackButtonMultipageTest {
|
|||||||
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
||||||
|
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webInterface.loadUrl(SAMPLE2_URL);
|
webInterface.loadUrl(SAMPLE2_URL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertPageSample(SAMPLE2_URL);
|
assertPageSample(SAMPLE2_URL);
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webInterface.loadUrl(SAMPLE3_URL);
|
webInterface.loadUrl(SAMPLE3_URL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertPageSample(SAMPLE3_URL);
|
assertPageSample(SAMPLE3_URL);
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertTrue(webInterface.backHistory());
|
assertTrue(webInterface.backHistory());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertPageSample(SAMPLE2_URL);
|
assertPageSample(SAMPLE2_URL);
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertTrue(webInterface.backHistory());
|
assertTrue(webInterface.backHistory());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertFalse(webInterface.backHistory());
|
assertFalse(webInterface.backHistory());
|
||||||
}
|
}
|
||||||
@ -141,12 +151,14 @@ public class BackButtonMultipageTest {
|
|||||||
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
||||||
|
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webInterface.loadUrl(SAMPLE2_URL);
|
webInterface.loadUrl(SAMPLE2_URL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertPageSample(SAMPLE2_URL);
|
assertPageSample(SAMPLE2_URL);
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
webInterface.loadUrl(SAMPLE3_URL);
|
webInterface.loadUrl(SAMPLE3_URL);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ public class ErrorUrlTest {
|
|||||||
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
|
||||||
assertEquals(ERROR_URL, mActivity.onPageFinishedUrl.take());
|
assertEquals(ERROR_URL, mActivity.onPageFinishedUrl.take());
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
assertEquals(ERROR_URL, mActivity.getWebInterface().getUrl());
|
assertEquals(ERROR_URL, mActivity.getWebInterface().getUrl());
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ public class MessageChannelMultipageTest {
|
|||||||
//load a page - this resets the plugin manager and nulls cordovaWebViewImpl.appPlugin
|
//load a page - this resets the plugin manager and nulls cordovaWebViewImpl.appPlugin
|
||||||
//(previously this resets plugin manager but did not null cordovaWebViewImpl.appPlugin, leading to the issue)
|
//(previously this resets plugin manager but did not null cordovaWebViewImpl.appPlugin, leading to the issue)
|
||||||
mActivityRule.runOnUiThread(new Runnable() {
|
mActivityRule.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
cordovaWebView.loadUrl(START_URL);
|
cordovaWebView.loadUrl(START_URL);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="false"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
@ -93,6 +93,7 @@ public class EmbeddedWebViewActivity extends AppCompatActivity {
|
|||||||
* @param permissions
|
* @param permissions
|
||||||
* @param grantResults
|
* @param grantResults
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String permissions[],
|
public void onRequestPermissionsResult(int requestCode, String permissions[],
|
||||||
int[] grantResults) {
|
int[] grantResults) {
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user