mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
CB-11828: Adding dirty userAgent checking to see if we're running Jellybean or not for bridge modes
This commit is contained in:
parent
deea0f7e4f
commit
dc0bfeb0cc
18
bin/templates/project/assets/www/cordova.js
vendored
18
bin/templates/project/assets/www/cordova.js
vendored
@ -1,5 +1,5 @@
|
|||||||
// Platform: android
|
// Platform: android
|
||||||
// d403ce434788ffe1937711d6ebcbcc837fcbcb14
|
// 2fd4bcb84048415922d13d80d35b8d1668e8e150
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
or more contributor license agreements. See the NOTICE file
|
or more contributor license agreements. See the NOTICE file
|
||||||
@ -901,7 +901,7 @@ var cordova = require('cordova'),
|
|||||||
EVAL_BRIDGE: 3
|
EVAL_BRIDGE: 3
|
||||||
},
|
},
|
||||||
jsToNativeBridgeMode, // Set lazily.
|
jsToNativeBridgeMode, // Set lazily.
|
||||||
nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
|
nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
|
||||||
pollEnabled = false,
|
pollEnabled = false,
|
||||||
bridgeSecret = -1;
|
bridgeSecret = -1;
|
||||||
|
|
||||||
@ -933,7 +933,6 @@ function androidExec(success, fail, service, action, args) {
|
|||||||
|
|
||||||
var callbackId = service + cordova.callbackId++,
|
var callbackId = service + cordova.callbackId++,
|
||||||
argsJson = JSON.stringify(args);
|
argsJson = JSON.stringify(args);
|
||||||
|
|
||||||
if (success || fail) {
|
if (success || fail) {
|
||||||
cordova.callbacks[callbackId] = {success:success, fail:fail};
|
cordova.callbacks[callbackId] = {success:success, fail:fail};
|
||||||
}
|
}
|
||||||
@ -953,6 +952,17 @@ function androidExec(success, fail, service, action, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
androidExec.init = function() {
|
androidExec.init = function() {
|
||||||
|
//CB-11828
|
||||||
|
//This failsafe checks the version of Android and if it's Jellybean, it switches it to
|
||||||
|
//using the Online Event bridge for communicating from Native to JS
|
||||||
|
//
|
||||||
|
//It's ugly, but it's necessary.
|
||||||
|
var check = navigator.userAgent.toLowerCase().match(/android\s[0-9].[0-9]/);
|
||||||
|
var version_code = check[0].match(/4.[0-3].*/);
|
||||||
|
if (version_code != null && nativeToJsBridgeMode == nativeToJsModes.EVAL_BRIDGE) {
|
||||||
|
nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
|
bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
|
||||||
channel.onNativeReady.fire();
|
channel.onNativeReady.fire();
|
||||||
};
|
};
|
||||||
@ -2084,7 +2094,7 @@ utils.clone = function(obj) {
|
|||||||
|
|
||||||
retVal = {};
|
retVal = {};
|
||||||
for(i in obj){
|
for(i in obj){
|
||||||
if((!(i in retVal) || retVal[i] != obj[i]) && typeof obj[i] != 'undefined') {
|
if(!(i in retVal) || retVal[i] != obj[i]) {
|
||||||
retVal[i] = utils.clone(obj[i]);
|
retVal[i] = utils.clone(obj[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
cordova-js-src/exec.js
vendored
14
cordova-js-src/exec.js
vendored
@ -55,7 +55,7 @@ var cordova = require('cordova'),
|
|||||||
EVAL_BRIDGE: 3
|
EVAL_BRIDGE: 3
|
||||||
},
|
},
|
||||||
jsToNativeBridgeMode, // Set lazily.
|
jsToNativeBridgeMode, // Set lazily.
|
||||||
nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT,
|
nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
|
||||||
pollEnabled = false,
|
pollEnabled = false,
|
||||||
bridgeSecret = -1;
|
bridgeSecret = -1;
|
||||||
|
|
||||||
@ -87,7 +87,6 @@ function androidExec(success, fail, service, action, args) {
|
|||||||
|
|
||||||
var callbackId = service + cordova.callbackId++,
|
var callbackId = service + cordova.callbackId++,
|
||||||
argsJson = JSON.stringify(args);
|
argsJson = JSON.stringify(args);
|
||||||
|
|
||||||
if (success || fail) {
|
if (success || fail) {
|
||||||
cordova.callbacks[callbackId] = {success:success, fail:fail};
|
cordova.callbacks[callbackId] = {success:success, fail:fail};
|
||||||
}
|
}
|
||||||
@ -107,6 +106,17 @@ function androidExec(success, fail, service, action, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
androidExec.init = function() {
|
androidExec.init = function() {
|
||||||
|
//CB-11828
|
||||||
|
//This failsafe checks the version of Android and if it's Jellybean, it switches it to
|
||||||
|
//using the Online Event bridge for communicating from Native to JS
|
||||||
|
//
|
||||||
|
//It's ugly, but it's necessary.
|
||||||
|
var check = navigator.userAgent.toLowerCase().match(/android\s[0-9].[0-9]/);
|
||||||
|
var version_code = check[0].match(/4.[0-3].*/);
|
||||||
|
if (version_code != null && nativeToJsBridgeMode == nativeToJsModes.EVAL_BRIDGE) {
|
||||||
|
nativeToJsBridgeMode = nativeToJsModes.ONLINE_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
|
bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
|
||||||
channel.onNativeReady.fire();
|
channel.onNativeReady.fire();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user