Rhodes - gem shows no error but does not work - android

I am using this SSDP gem
It depends on ipaddr, socket
I have addedd ipaddr to the main Rhodes gem framework.
I modified the ssdp gem and included the contents inside its lib folder to the main framework as well.
Upon compilation of the app, it shows no error. Neither the adb log shows any error. But there is no output.
Wonder if the gem functionality is not supported or there is some system error?
The SSDP gem creates a UDP socket to listen to Upnp devices on a network.
That is my goal. To build a Upnp control point in Rhodes.
It requires access to native HTTP services, like sending requests over TCP/IP and UDP.
It also needs to serve music files from the phone over network.
It would also need to handle custom HTTP methods apart from GET/POST, like NOTIFY and SUBSCRIBE
As of now I am attempting task 1 and I dont see any errors in the adb. But it is not working.
This is the adb log - https://paste.ubuntu.com/26328082/
Testing on Android 6
EDIT
In application.rb
require 'socket'
require 'ipaddr'
require 'ssdp'
In index.erb
<%= finder = SSDP::Consumer.new :timeout => 3 %> <br />
<%= result = finder.search :service => 'ssdp:all' %> <br />
<%= IPAddr.new('239.255.255.250').hton + IPAddr.new('0.0.0.0').hton %> <br />
<%= Rho::Network.hasNetwork %> <br />
<%= result %>
The above code returns nothing in the Rhodes app.
Except IPAddr, which returns gibberish symbols. Only that works.

Related

Unable to upload APKs to App Center to perform Espresso UI testing

I'll try being as detailed as I possibly can. Please excuse any formatting or language issues.
What I'm trying to do?
I'm trying to make an app to upload APKs to Appcenter to execute UI test cases on whatever devices a user provided. When finished, my app will show the results of the UI tests executed.
How am I doing it?
App center has provided a lot of APIs which may be viewed here. Executing a UI test is a 4 step process.
Create a new test run. This is working
Create hashses of files to be uploaded. This is working
Upload the actual files. I keep getting a 400 bad request OR "payload is too big" error. My APK file is only 1 MB & the upload works through Appcenter CLI.
Execute the test run created. This API is not working. Probably due to failure of 3rd step.
What do I need help with?
Step 3. above is not working for me. I keep getting the following error when I try to upload the APK file through curl/postman.
Curl command :
curl -i -F "data=#app-debug-androidTest.apk" -H "X-API-Token:API_TOKEN_HERE" -H "Content-Type:application/json" -X POST https://api.appcenter.ms/v0.1/apps/{ORG_NAME}/{APP_NAME}/test_runs/{TEST_RUN_ID_CREATED_IN_STEP_1}/files
Error received :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Payload Too Large</pre>
</body>
</html>
The irony is, when the exact same API is executed by the Appcenter CLI, it works. If UI tests are executed as part of the build step, App center uses the exact same procedure & set of APIs to upload the APK. Please view the complete log here. For formatting purposes, I did not add in inline.
What am I doing wrong?
Your curl command in step 3 is trying to upload the binary file as multipart form data (in a param data that doesn't exist in the API spec). The /files endpoint expects no file upload, but is preparing the upload internally and then returns the upload URL to you. See here in the App Center CLI's code:
const directUrl = await this.getDirectUploadUrl(this._client, testRunId, file);
await this.makeDirectUpload(directUrl, file);
Remove -F "data=#app-debug-androidTest.apk" from your curl command, then check the response for the upload URL for this test run.
After a day and half, possibly two I was able to resolve this issue. I've posted an elaborate document here & below is the shorter version.
Once you've created a new test run, you need to upload your file hashes for the APKs generated from the gradle command $ ./gradlew clean assembleDebug assembleAndroidTest. The URL is mentioned in the location key in the response of /hashes/batch API. The body of the API will be similar to :
[{
"file_type":"app-file",
"checksum":"df798b4d07597db804546b8ca723780992811111", //Calculate your file's SHA-1 by using shasum util
"relative_path":"app-debug.apk"
}]
Now we upload the file on the URL received in response to the /hashes/batch API with the following body params in form-data format.
relative_path //The name of the file is adequate
file //The actual file
file_type //app-file for build APK and test-file for APK containing espresso tests
If the files upload properly, you may execute the test run by /start API end point.

WebRTC Red5Pro not working on mobile browsers

I'm trying to include a streaming service inside of an cordova hybrid app for iOS and Android. We chose red5pro because it is an 1 broadcaster to n subscriber situation and theirfor we need a server which is broadcasting to the subscribers. The broadcasting is simply done via webbrowser on a laptop and there is no problem with that but the recieving is going to be inside of the app.
red5pro has 3 example usecases for HTML streaming, native Android and native iOS. We are developing a hybrid mobile app, so we chose the HTML method.
We did a test setup on which you can open an URL in any webbrowser and see the steam, which works fine on firefox, chrome and safari. However, if we try to open the stream via chrome on an android device, we get the following error message:
2017-11-10T15:57:26.862Z - [red5pro-sdk] error: (RTCSubscriber) [onsdperror] red5pro-sdk.min.js:9
2017-11-10T15:57:26.877Z - [red5pro-sdk] error: (OperationError: Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set remote video description send parameters..) undefined red5pro-sdk.min.js:9
Uncaught (in promise) Invalid SDP.
value # red5pro-sdk.min.js:9
(anonymous) # red5pro-sdk.min.js:9
Promise rejected (async)
value # red5pro-sdk.min.js:9
value # red5pro-sdk.min.js:9
value # red5pro-sdk.min.js:9
value # red5pro-sdk.min.js:9
e.onmessage # red5pro-sdk.min.js:9
2017-11-10T15:57:26.889Z - [red5pro-sdk] error: (RTCSubscriber)[onsdperror] red5pro-sdk.min.js:9
2017-11-10T15:57:26.892Z - [red5pro-sdk] error: (OperationError: Failed to set local sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set remote video description send parameters..) undefined red5pro-sdk.min.js:9
2017-11-10T15:57:31.059Z - [red5pro-sdk] error: (RTCSubscriber) Error in stream subscription: Session start failed for lukas.
"Invalid SDP" this message appears after the subscription to the stream is done.
My sample code for the client:
HTML:
<!doctype html>
<html>
<head>
<!-- Recommended shim for cross-browser WebRTC support. -->
<script src="https://webrtc.github.io/adapter/adapter-latest.js">
</script>
<!-- Default Red5 Pro Playback Control styles. -->
<link href="lib/red5pro/red5pro-media.css" rel="stylesheet">
<!-- Fullscreen shim. -->
<script src="lib/screenfull/screenfull.min.js"></script>
</head>
<body>
<video id="red5pro-subscriber"
class="red5pro-media red5pro-media-background"
autoplay controls>
</video>
<!-- Exposes `red5prosdk` on the window global. -->
<script src="lib/red5pro/red5pro-sdk.min.js"></script>
<!-- Example script below. -->
<script src="js/main.js"></script>
</body>
</html>
And the Main.js:
(function (red5prosdk) {
// Create a new instance of the WebRTC subcriber.
var subscriber = new red5prosdk.RTCSubscriber();
// Initialize
subscriber.init({
protocol: 'wss',
port: 8083,
host: 'our.host.url',
app: 'live',
streamName: 'chosenStreamname',
iceServers: [{urls: 'stun:stun2.l.google.com:19302'}],
bandwidth: {
audio: 56,
video: 128
}
})
.then(function(subscriber) {
// `subcriber` is the WebRTC Subscriber instance.
subscriber.subscribe();
})
.then(function(subscriber) {
// subscription is complete.
// playback should begin immediately due to
// declaration of `autoplay` on the `video` element.
})
.catch(function(error) {
// A fault occurred while trying to initialize and playback the stream.
console.error(error)
});
})(window.red5prosdk);
The stream is neither working on iOS safari nor on android chrome. Does someone has experience with such an setup and can help?

Webview Localhost Connection refused using 10.0.2.2 address

I'm just making a basic Webview app on an android emulator and cannot connect to a website hosted on my computer.
Here is my code:
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.emswebviewer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
Main Activity Java file:
public class MainActivity extends Activity {
private WebView webView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
System.out.println("*** My thread is now configured to allow connection");
}
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
webView.loadUrl("http://10.0.2.2:8080");
}
Terminal (Starting website on local host port 8080):
Michaels-MacBook-Pro-5:web michael$ php -S localhost:8080
PHP 5.5.14 Development Server started at Mon Dec 22 14:08:01 2014
Listening on http://localhost:8080
httpd.conf File (Under Apache Folder):
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/Applications/MAMP/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options All
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
I am using Mamp and AVD as the emulator.
When I run my app, it returns net::ERR_CONNECTION_REFUSED on the Main activity page.
Do I need to allow external connections somewhere? OR is there something inherently wrong with what I am trying to do?
localhost on your emulator it's not localhost on your desktop. On your desktop you need to run php server with php -S 10.0.2.2:8080 (if that it's your IP). And than access that IP from the emulator with WebView at your app. You can't access desktop's localhost from the emulator (no directly at least). Don't start your server on localhost only.
Look for this file ports.conf and add Listen 8080 if necessary and restart the server.
Using 10.0.2.2 is correct and not wrong in anyway as such. You can see why in the below answer
why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client
The issue may be related to your application listening to 127.0.0.1 only and not all interfaces. You need to make sure you use something like below
php -S 0.0.0.0:8080
I saw your bounty question as well, which also answers that you need run your Django server as below
python manage.py runserver 0.0.0.0:8000
PS: And next time your post a bounty #kingraphaII, be kind enough to respond to people and don't just be a ghost
What worked for me was to replace localhost address with my pc laptop, 192.168.2.7, in my case. #gorlok comment helped me towards my solution.
Android Emulator is a separate device. Emulator isn't part You Computer. Emulator cann't access your Local Server.
So Emulator return net::ERR_CONNECTION_REFUSED error.
I found a Simpal way to solve the issue.
Get my local IP address as like 192.168.99.112
To get your IP address open your Tarminal/cmd type ipconfig
Ensure your internet permission in AndroidManifest File
<uses-permission android:name="android.permission.INTERNET"/>
Then
WebView browser = (WebView)findViewById(R.id.webview);
webView.loadUrl("http://192.168.99.112/projectName");

phonegap http error 404

I am trying to connect to server for fetching data using ajax call inside phonegap app.
But I am getting status 404 for every request I tried google.com, 10.0.2.2 (localhost on android).
Here are steps I followed for creating application
I created template application using phonegap command line as phonegap create my-app
Running application using phonegap run android ( This shows "device is ready" screen on emulator )
Added following code for making an Ajax call to index.js - receivedEvent function
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
console.log('rdy state - '+ xmlhttp.readyState);
console.log('status - '+ xmlhttp.status);
console.log('text status - '+ xmlhttp.statusText);
console.log('Response Text - '+ xmlhttp.responseText);
}
xmlhttp.open("GET","http://10.0.2.2/", true);
xmlhttp.send();
I can access http://10.0.2.2 from emulator browser.
Here is Enviornment I am using
Phonegap version - 3.4.0-0.19.8
Android version - 4.4.2
-- Vishal
Did you put an access token in your config.xml? Try to put
<access origin="*"/>
into your config.xml.
* gives access to all domain.
Look up http://docs.phonegap.com/en/3.4.0/guide_appdev_whitelist_index.md.html#Whitelist%20Guide for further information.
Despite you have:
<pre> <access origin="*"/> </pre> in config.xml
You need to add the whitelist to your phonegap(cordova) project:
phonegap plugin add cordova-plugin-whitelist
After this your app will no longer give 404.

Run python Script in android application

I want to get list of installed software on remote computer.For that I want to use python script in my android application.Now,I have a python script which is getting the list of installed software on remote computer.But,I don't know how to make it supported in android.
For this, I found SL4A android Scripting here . So, I tried to run my python script in android device using SL4A.But,It's not working and giving me error because some packages like win32.client is missing.I don't know more about SL4A so I don't know how to convert my python script in Android supported form.So,anyone have any idea or code please suggest me.....
Also If anyone have another way to get installed software list from remote Pc then please suggest...
Below is my python script
import wmi
from winreg import (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, OpenKey, EnumValue, QueryValueEx)
c = wmi.WMI(computer="PC02",user="admin",password="a#1",namespace="root/default").StdRegProv
result, names = c.EnumKey (hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=r"Software\Microsoft\Windows\CurrentVersion\Uninstall")
print('These subkeys are found under "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"\n\n')
separator = "*" * 80
keyPath = r"Software\Microsoft\Windows\CurrentVersion\Uninstall"
count = 0
while count < len(names):
try:
print(separator+'\n')
path = keyPath + "\\" + names[count]
key = OpenKey(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS)
temp = QueryValueEx(key, 'DisplayName')
display = str(temp[0])
print (" Name: "+display+'\n',"key:",names[count])
count += 1
except:
print ("Key:",names[count])
count += 1
continue
Run the script on your remote computer, and expose the list of installed software on HTTP, a good way to write this simple web app is to use flask and its development server to serve the list of installed software, then write a python script which uses the native android web interface to fetch the list and display it.
You are having problems with missing libraries because you are importing windows specific ones. At any rate, this isn't the correct script to be running. This script seems to be for a computer, not an android phone.
You're trying to use a Python script that uses Windows Management Instrumentation (WMI), on a device that doesn't have that library.
Sadly, WMI on Python requires the win32 library, which is only available on Windows. I don't think you're going to have much success on checking the installed programs on remote Windows computer from an Android device in this way.
Since WMI is based on WBEM, you may be able to use wbem to access it; you might want to try using pywbem, a pure python wbem library.
Running python scripts is now achievable in gradle system using Tasks
task pythonFile(type:Exec) {
workingDir 'src_path'
commandLine 'python', 'my_script.py'
}

Categories

Resources