Codename one wi-fi detection - android-wifi

Im working with "Codename one" (Android developer) and I would like to know how can I detect if the phone has wi-fi activated or not. In this way, I can decide store data locally, and transmit it only when WI-FI is active. Otherwise, if I want to send pictures, without WI-FI, could be very expensive.
As a related question, do I have to setup some kind of cron or similar (in my code) in order to ask to my device if the WI-FI has been turned on?
Thank you very much for your help.
Kindly regards,
Gustavo

Normally to detect network you will need to use a check of whether you can connect to a specific server since a WiFi might be an airport wifi or something where you aren't authorized to connect outside. This will make it seem like wifi is connected but won't really work.
We have an APN API that allows you to detect the connection type (wifi/3g etc.) but it only works on Android/Blackberry and thus won't work (at this time) on iOS etc. Look at NetworkManager specifically: isAPSupported, getCurrentAccessPoint, getAPType.

Related

Is it possible to use the webHID API over and RDP connection?

We recently implemented the webHID API for one of our sites (it is such a godsend) and have the client asking if they can use the devices over a Microsoft RDP connection?
I imagine this would depend on the RDP client and whether they can/do send HID events over the RDP connection.
From some initial research it looks like you can redirect USB over RDP but don't think this will work for us as I couldn't get my device mapping done with the webUSB API.
If anyone has any input on this it would be greatly appreciated.
Thx
WebUSB, WebHID and Web Serial should work with a remoted USB device.
That said, there may be bugs if these devices don't appear to applications like Chrome in quite the same way they do when connected locally. If they don't, it would be interesting to get logs from chrome://device-log and see how the device appears in the Windows Device Manager.
Please file a bug at https://crbug.com/new and let us know so that we can keep track of this issue.

Windows Phone control tv over wifi

I'd like to create a Windows Phone 8.1 app to connect to a TV and have basic controls (change channels, turn on/off).
I know It's hard to have an universal remote for every TV, but I'm just testing so It could work to a specific model/maker.
My first guess is to connect to a smart tv over wifi connection, but I can't find any site to describe how to do this or how do I start researching. I only got links to apps already made, but not on how to build it.
Anyone knows how this connection works?
Thanks!
i dont think this is really related to Windows phone specific. but here is what you can do:
find out what kind of API the TV has. it's probably some Rest or SOAP based webservice you can call. if there are existing apps (maybe for other platforms) you can use Fiddler to check the network traffic from these apps to the TV if you set your pc as "man in the middle" with fiddler.
as soon as you have what you need look into HttpClient examples on how to send these requests toward your TV.
fiddler :http://www.telerik.com/fiddler
HttpClient: https://msdn.microsoft.com/library/windows/apps/dn298639

Detect Internet Connectivity

I am trying to figure out a way to do an internet connectivity check for an AIR for iOS app. Previously, I was using (against my better judgement) a URLMonitor that checked Google once every 30 seconds. I did not like putting that load onto Google and neither did they; this morning, our network got flagged as a possible DDoS attacker simply from testing the app. So I had to disable this type of check and move on.
I have thought about using the NetworkInfo ANE from Adobe, but that presents its own issues in determining internet connectivity. The only way I can think of doing it is to check for interfaces "en0" and "pdpxx" (which correspond to WiFi and Cellular interfaces, respectively) and check their IPs to ensure they are not in the 192.168.x.x, 10.10.x.x, or 127.0.x.x ranges. However, I am not entirely sure those are the only static router/localhost IPs out there and there is always the possibility that the network interface names will change in the future, which would render this monitor useless. There is also the issue of IPv6 possibly throwing a wrench into this method as well.
Is there another way to check if the user is connected to the internet? I've searched multiple times and it seems that these are the only two ways to check. If that is the case, what is the best way to check?
I'm surprised that you got flagged as a DDoS attacker, are you sure that's what happened?
In any case, if your not happy with putting the load onto someone else's server, then make your own server, just a basic setup that you use with the URLMonitor. You don't have to use google's url with the URLMonitor, you can pass it another URLRequest, which could point to your own server.
monitor = new URLMonitor(new URLRequest("http://www.you-own-server.com"));
This might also be useful if you decide that you want to pass more data between the app and the server. It's your server, so can do what you want with it.
I don't think there's any other way to check if the user is connected to the internet. To be honest, I don't see why there would be. Checking for the users interfaces/wan0 etc... probably would be possible, but you'd need another program, maybe a simple python or c++ program, that Air could use to check these things, but that sounds like the long way round.

Peer-To-Peer connection via WiFi

Is it possible ?
Peer-To-Peer connection via WiFi (same Access Point) , how would multiple devices talk on this layer.
Any API available or sources that can be looked into ?
Thanks
Yogurt
The Wi-Fi Alliance on Monday announced that its direct peer-to-peer networking version of WiFi, called WiFi Direct, is now available on several new WiFi devices. The Alliance is also announcing that it has begun the process of certifying devices for WiFi Direct compatibility.
Try researching the state of Bonjour / Avahi / Zeroconf on android. I'm seeing some pages that indicate people have made some progress for certain purposes but nothing like a generic howto or ready to use library.
Unless you know the IP address assigned to the other peer already, you'd have to somehow have devices inform other devices that they exist.
Are these devices definitely going to be on the same subnet? If so you can try messing around with having the devices send out 'broadcast' packets. I have no idea if the Android API lets actual applications receive these though.
The more reliable approach would probably be to run some centralised server somewhere that devices register with when they go online, and give their IP address when they register. Then they can query that server for which other devices are nearby and what their IP addresses are. If this is to be a central server out on the wider internet, then it means that unfortunately that the device discovery part isn't peer to peer - there is some privacy implication. Another thing if this is a central server is that you'll have to design the querying process to cope with NAT so that querying for other devices on your local network is restricted to the right network, but that you also get their IP address.

What are the approaches to restrict the access to a group of machines in a web system?

My bank website has a security feature that let me register the machines that are allowed to make banking transactions. If someone steals my password, he won't be able to transfer my money from his computer. Only my personal computers are allowed to make transcations from my account. So...
What are the approaches to restrict the access to a group of machines in a web system?
In other words, how to identify the computer who made the http request in the web server?
Why not using a clients certificate inside the certificate store of an authorized host or inside a cryptographic token such as smartcard that can be plugged into any desired computer?
Update: You should take into account that uniquely identifying a computer means obtaining something that is at a relative low level, unaccessable to code embeded in an html page (Javascript, not signed applet or activeX), unless you install something in the desired computer (or executing something signed such as an applet or activeX).
One thing that is unique per computer is the MAC address of the Ethernet card, that is almost ubiquitous on every rather modern (and not so modern) computer. However that couldn't be secure enough since many cards allow changing its MAC address.
Pentium III used to have an unique serial number inside CPU, that could fit perfect for your use. The downside is that no newer CPUs come with such a thing due to privacy concerns from most users.
You could also combine many elements of the computer such as CPU id (model, speed, etc.), motherboard model, hard disk space, memory installed and so on. I think Windows XP used to gather such type of information to feed a hash to uniquely identify a computer for activation purposes.
Update 2: Hard disks also come with serial numbers that can be retrieved by software. Here is an example of how to get it for activation purposes (your case). However it will work if sb takes the HD to another computer. Nonetheless you can still combine it with more unique data from computer (such as MAC address as I said before). I would also add a unique key generated for a user and kept in a database of your own would (that could be retrieved online from a server) along with the rest to feed a hash function that identifies the system.
Did you actually install something?
Over and above what Mark Brittingham mentions about IP addresses, I suppose some kind of hash code that is known only to your bank's computer and your computer(s) would work, provided you installed something. However, if you don't have a very strong password to begin with, what would stop someone from "registering" their computer to steal money from you?
I would guess your bank was doing it by using a trusted applet - my bank used to have a similar approach (honestly I thought it was a bit of a hassle - now they're using a calculator-like code generator instead). The trusted applet has access to your file system, so it can write some sort of identifier to a file on your system and retrieve this later.
A tutorial on using trusted applets.
I'm thinking about using Gears to store locally a hash-something to flag that the computer is registered.
If you are looking for the IP address of the computer that makes an account-creation request, you can easily pull that from the Request. In ASP.NET, you'd use:
string IPAddress = Request.UserHostAddress;
You could then store that with the account record and only accept logins for that account from that IP address. The problem, of course, is that this will not work for a public site at all. Most people come through an ISP that assigns IP addresses dynamically. Even with an always-on internet connection, the ISP will occasionally drop and re-open the connection, resulting in a change of IP address.
Anyway, is this what you are looking for?
Update: if you are looking to register a specific computer, have you considered using cookies? The drawback, of course, is that someone may clear their cookies and thus "unregister" their computer. The problem is, the web only has so much access to your computer (not much) so there is no fool-proof way to "register" a computer. Even if you install an ActiveX control, they could uninstall or delete it (although this is more persistent than a cookie). In the end, you'll always have to provide the end-user with some method for re-registering. And, if you do that, then you might as well have then log in anyway.