Unable to run worklight application without internet connection - android

I have a big problem with running worklight application without enabled wifi or mobile data connections. The application starts and then quit, i need to get to the home screen and then implement some logic.
wlCommonInit is never called in that case. I debugged application and saw that something is sending message "onMessage(exit,null)" and then calls onDestroy()
Steps to reproduce:
- Turn off wifi and mobile data and start the application
Used environments:
- Worklight 6.2
- Android

In Worklight 6.2.0.01 I've created a new Hybrid application with the Android environment.
This application performs the below. The application was installed in an Android Nexus 5 device running Android OS 5. The device was set to Airplane mode (no WiFi, no 3G). Upon launching the application the onFailure function was invoked, as expected. No crash.
Provide your implementation so that it could be debugged.
function wlCommonInit(){
WL.Client.connect({onSuccess: success, onFailure: failure});
}
function success() {
alert ("success");
}
function failure() {
alert ("failure");
}

Related

Android Auto DHU - Waiting for phone

I'm trying to run desktop head unit on my pc. I set up everything exactly as this guide specifies: https://developer.android.com/training/cars/testing, (tried both 2.0 and 1.1 with the same result). It appears to connect correctly, but I can't get it do display anything other than "Waiting for phone". Console displays following:
Android Auto - Desktop Head Unit
Build: 2020-09-20-332761970
Version: 2.0-windows-beta
[W]: No configuration specified - using default values.
[E]: Could not load configuration from 'C:\Users\kkowalczyk\.android\headunit.ini'.
BoringSSL is the SSL implementation used in the receiver-lib.
Starting link. Requested protocol version: 1.6 (snapshot 314970161)
[I]: Connecting over ADB to localhost:5277...
[I]: connected.
> Phone reported protocol version 1.6
ssl state=TLS client read_server_hello -1
ssl state=TLS client process_change_cipher_spec -1
ssl state=SSL negotiation finished successfully 1
SSL version=TLSv1.2 Cipher name=ECDHE-RSA-AES128-GCM-SHA256
Verify returned: ok
I'm trying to connect to Pixel 5 (with most recent update), is there anything else I can try?
In my case, I also saw the same issue but resolve by following below steps:
Close the DHU emulator.
In the AA app, stop the HU server. Wait for a couple of seconds, start the HU server.
Stop the HU server again. Wait for a couple of seconds, start the HU server.
Start the DHU emulator.
The OOBE screen shows up on the AA app in phone. Complete the flow. While you are completing the flow, the emulator will be on the 'waiting for phone' screen.
Stop and start the emulator. It will start with the black screen with 'waiting for phone' message but after 2-3 seconds the emulator screen comes up.
Hope it can resolve your issue too.
I ran into the same issue (stuck on the "Waiting for phone..." screen) and was able to fix it by changing Application Mode to Developer on the Developer Settings screen of Android Auto.
Make sure to restart the head unit server on the phone after that in case it was already running, then reconnect/restart desktop-head-unit.
I ran into similar issues initially and for me the issue was that the "Accept terms" screen of the Android Auto App running on the device that is triggered on connecting to the Emulated HUD was not visible and noticed until I scanned through the recent apps in the Task Switcher.
This is mentioned in step 11 of the Test Android apps for cars - DHU setup instructions here
If this is the first time you are connecting the mobile device to the DHU, check the mobile device's screen to accept the terms of service and adjust permission settings as needed.
So just note that this screen may not be immediately visible to you unless you switch the relevant screen from the Task Switcher.
Try to test your phone on a real car to make sure phone actually works with Android Auto. I have two phones (Huawei p20 and Xiaomi Mi10): xiaomi works fine but p20 doesn't work with multiple settings and/or option neither in car or DHU, however both of them are considered as compatible with Android Auto.

chromedriver not reachable after close and launch app. WebDriverException

I made test which close mobile app and after 2 seconds launch it.
self.welcome_page.confirm_continue()
self.driver.close_app()
sleep(2)
self.driver.launch_app()
sleep(1)
after than I get WebDriverException for every interaction with driver. (e.g. find_element, current_url, refresh ...)
On the screenshot and in the video I see that the app is in expected state and obviously launched successfully.
I am running tests against BrowserStack. with following BrowserCapabilities
[Android]
app=$APP_ID_ANDROID
AppfileName=$APP_NAME_ANDROID
AppCustomID=Corkscrew_andorid
autoAcceptAlerts=true
autoGrantPermissions=true
browserstack.debug=true
device=Samsung Galaxy Note 9
deviceName=Android Emulator
deviceOrientation=portrait
name=cs_test
os=android
os_version=8.1
no-reset=true
full-reset=false
autoWebview=true
response from Webdriver has old version of chromedriver.
'status': 100, 'value': {'message': 'chrome not reachable\n ...o: chromedriver=2.42.591071
appium logs: HERE
probably (I guess) the driver is not active anymore and new one was created by launching app. But how can I get the new driver?

MobileFirst and Werable

I've found a problem during the integration between IBM MobileFirst 7.1 Apps and wearable devices (Android Wear / Samsung Gear) like companion apps.
We are working on IBM MobileFirst 7.1 Hybrid Application that work with wearable watch devices as an Host for Web services integration via adapters invocation.
We implemented an Android Service in Java using native MobileFirst SDK for Android using these class: WL.Connect, WL.Client and WL.invokeProcedure to call Mobile First Adapters.
Below the code used into Android Service used for initializing the client (smartphone host):
final WLClient clientC = WLClient.createInstance(this.getApplicationContext());
clientC.connect(new WatchConnectListener(adapterName, procedureName,parameters))
The connection was done successfull but the WL.InvokeProcedure raise an error.
Below the error received during the execution:
Calling startActivity() from outside of an Activity
After an investigation we realized that this error is related to the Context passed to the create WLClient.createInstance, the context passed need to be an Activity but in this case the context is an Android Service.
Could somebody suggest how to use WL.Client() into an Android Service for wearable communication ?
I suggest that you will make a feature request (RFE) for enhancing the Android SDK with support for running on watches so you could implement such scenarios. Right now this is not supported.
Make the request, here: https://www.ibm.com/developerworks/rfe/ and let your IBM representative know.

Cordova App on Android not connecting to internet page?

I have an app that works fine on iOS. It uses Cordova and uses remote requests for some of its functions, however, on android, only on a device, it sometimes (pretty frequently) will not connect. It almost always works on the Genymotion emulator, except once, where I saw "NET CACHE ERR" or something similar to that in the Chrome dev tools console. (The default Android emulator cannot connect however.)
The calls are simple jQuery ajax post requests that work fine in the Genymotion emulator (all times except once), and fine in a browser and in the iOS Cordova app. Networking permissions are enabled and asked upon installation. Interestingly, it can still get the device id used for push notifications (which requires a network response, from what I can tell, however it could be misleading I suppose).
Example for the obligatory request:
function connect(){
$.post('https://example.com/stuff.php', {
'var': 'a variable!'
}, function(data) {
//internet request complete, confirm connection successful
window.connected = true;
});
}
window.connected = false;
setInterval(
function(){
if(window.connected==true){
//yeah you connected
}else{
//naw you not connected homie
connect();
}
},
3500
);

Android App continous receiving data via USB

I'm developing an Android App which i want to communicate with a device connected via USB. This device is delivering data all the time. These data are visible with a programm on the android linux shell.
My goal is to see those data in my App and after that deliver them via a Service to other Apps.
So my question is: Can i "open" a connection from my Android App to the USB-Port so im continuesly receiveing the data in my app, which are sent by the usb-device? And if yes, how would the code look like?
*Edit
Thank you for your answers, the app itself doesn't run on the commandline any more. So its no executable anymore but a shared library getting load by my android app.
It did before, but i want to be able to initiate the connection using NDK methods in my App to be able to see the data in my App itself. So I've tried to see if a connection is allready open.
I've added some functions to my code, so i can see if the usb-connection is open and i have the permission to that usb device.
UsbManager.hasPermission(device)
returns true, because I'm using an itent filter.
UsbManager.openDevice(device)
returns an UsbDeviceConnection, so i seem to have the access to use that device.
What im not capable of so far is receiving either iniciating the bus connection to by usb-device and of course either getting data input of that device.
Since my native code allready has a while(true)-method which is only using callbacks to send data to my app when actually data getting sent trough my usb-device i want to keep the work done in my c-code.
The only job my app should do is open the bus-connection once and after that be ready for callback from the c-code.
Is that possible?
If you have the app that runs on the command line, you can actually run a command line from within your app. Take a look at the Process class and the ProcessBuilder docs for full details. The example given is below
To run /system/bin/ping to ping android.com:
Process process = new ProcessBuilder()
.command("/system/bin/ping", "android.com")
.redirectErrorStream(true)
.start();
try {
InputStream in = process.getInputStream();
OutputStream out = process.getOutputStream();
readStream(in);
finally {
process.destroy();
}
}

Categories

Resources