I need to have control over some admin features of android device.
Is it possible to acquire control over hardware not specified in android.app.admin.DevicePolicyManager like disabling access to microphone?
Also it will be good to find ability to track network connections or attempts to use network adapters by apps.
Maybe some command for root console or other way exist - how I can search for?
As far as i know there is no way to block any other hardware except camera with device manager. I believe that if your app takes control of microphone it will be unavailable to other apps, but i am not sure. Note that from android 8.0 no app is allowed to take control of microphone while in background.
About tracking network activity you could open vpn to monitor all packets that are sent and received.
Please keep in mind that i am not familiar with root methods so you should do some more research on this.
Related
The situation:
I'm developing an android app for some hardware that has a BlueGiga WT12 bluetooth modem. The hardware device sends 56 byte packets at around 240hz. I'm testing on a Samsung S5 and S8. A fully functional app has already been created for IOS and PC so we know the hardware device works.
I use a separate thread to read in the data and then dispatch it to the main thread.
Issue:
The issue I'm having is when I send the command to the device telling it to start streaming, it starts to stream but very shortly after I start receiving packets at a very slow rate 10-60hz.
After some examination I realized that the device was experiencing a bufferoverflow.
After talking to our hardware guy he said the only real thing that could cause that is something on the phone side not reading fast enough, resulting in the hardware device not wanting to send more packets because it thinks the phone can't receive anymore and then the buffer overflows on the hardware device.
The WT12 has flow control enabled so maybe this is an issue with Android not giving a clear-to-send signal to the WT12. But to my knowledge we don't have access to all of the flow control stuff.
What I've tried:
My first line of attack was to simply remove any code that I thought was slowing down the reads but that seemed to have no effect.
I also tried basically every bluetooth serial terminal app I could get my hands on, all with the same result.
So then I questioned if it was some weird problem relating to the hardware device but after using pc based (bluetooth) serial terminals I had no issues at all on the pc.
The hardware device can also operate over USB as opposed to bluetooth so I tried reading the data from it exactly the same as I had with the bluetooth connection but over USB. Using the USB serial connection I had no issues at all.
My thoughts:
So this leads me to believe the problem must be with the bluetooth modem on the phone side. I was thinking maybe it was a flow control issue as we have flow control enabled on the WT12. Maybe android isn't sending a clear to receive signal?
The problem is to my knowledge the flow control is implemented in the bluetooth stack and we as developers have no control over it if I'm not mistaken?
Other then flow control I don't really have much idea what could be causing the hardware device to not want to send me data.
I've just now been experiencing the same issues with flow control. Then I see that in case of RN4678 BT module, that it's best to disable the flow in the MCU FW and pull the cts pin low on the module. That worked for us.
I am developing an application in which i have to sync time of multiple devices without giving application root access. Since i can't programmatically change the time of device on android without getting root access, i have one device acting as the true source of time and other devices need to somehow connect to it and get the time and save the local offset.
For this purpose i am using Bluetooth low energy. The master device plays the peripheral role where it advertises a custom service containing the characteristic 'current time', and other devices acting as centrals will look for that advertisement, connect with master, read the current time. So far i have only been able to make it work for one peripheral and one central.
Can a peripheral device connect to multiple central devices, if so then what is the limit to the number of connections?
Is there a better way to address this use case of syncing time of multiple devices?
It's a bit SoC specific, but you should check out this blog:
https://devzone.nordicsemi.com/b/blog/posts/wireless-timer-synchronization-among-nrf5-devices
A max jitter of 220ns over a 30min period is quite an achievement. Although it does not use BLE, but proprietary 2.4GHz the idea can be applied for BLE as well, but not with the same performance.
I'm working on a project that can help optimize multicast. More precisely an implementation of Network Coding.
I have a great deal of it done in simulators, but now that I want to implement it on actual mobile phones, I'm facing this problem: How can I send data between them phones without the need for access points between them?
Can I open sockets programmatically and listen to them? Or is there something like an AdHoc network (those are no longer supported in android) that I can use?
EDIT: If needed I can rely on a server/access point for DHCP and such (for the phones to know of each other) . But the data needs to flow between the phones independently of the access point.
An access point is just a 1st-level ISO/OSI device that permits to one or more WiFi compliant devices to communicate wirelessly. Unless you can use Bluetooth or IR as a fallback, there's no way you could make it without an AP.
Have one of your phones act as a "mobile hotspot" (a wifi access point) for the other phones. Share the name of the access point and passphrase with the other phones and they will all be connected on the same network (and the internet through the "hotspot" phone's cellular data connection.
In this way, you have all the normal networking capabilities and security available to you without requiring an additional/external access point.
However, this will not result in direct connectivity between the many phones that are not the access point; all (non-multicast) network communication will bounce through the phone that is acting as an access point for your network.
I'm looking for guidance on how to achieve (build) the following:
I have a native App (supported on both Android and iOS)
I have a user 'A' who has the app installed on his phone.
I want another user 'B' to be able to remotely (on a browser) be able to "view" or "take control" of the app being used by user 'A'. So, User A could say "Share with User B" and User B starts seeing a virtual view of the app on User A's phone, and follows as User A navigates around the app.
Basically, some sort of screen sharing on phone, but only limited to my app.
Note that I do not want the user 'A' to install any separate app to share my app. It should be a capability existing/built within my app itself.
To achieve your goal there are smaller problems to take care about, from screen change detection to P2P communication between network nodes.
For iOS there's a Hierarchy Viewer github project that setups HTTP service on device, allowing to preview snapshots of app window using a web browser. Making use of that, you'd still need custom protocols to notify about user touch events and screen changes, which in turn requires effective screen change detector.
Note that this solution assumes no NAT stays between controlling and controlled devices, which is usually a case for local networks. To use the Internet as a medium, you should consider P2P protocols capable of NAT traversal (reffer to STUN protocol for endpoint address recognition and hole punching as a NAT traversal technique).
As a suggestion, how about this? Please note I'm not into this myself, so I might be suggesting something very hard to do.
Create a website that shows the same information as the phone
Make the app have a "server" component
Have the website authenticate and connect to the phone
Have the phone to send over the data from the app to the website, which can then show it in the appropriate fields/positions.
I think what you're looking for is some kind of VNC-like server that would be integrated into your application and serves the content of your application ui on the network. It should be technically feasible, yet it certainly won't be easy !
There are several VNC servers for android ; most but not all requires root access though, probably because they serve the phone screen and not one specific application.
In Android, I can monitor if certain events are triggered through the use of Broadcast Receivers. Are there any tools which let me view ALL events on an android device I am debugging instead of having to add a broadcast receiver to listen to them?
For example, in a Broadcast receiver, I can monitor for a call forwarding event. Is there a way to debug such events outside of having to write additional Android code? My goal is to test that certain events are triggered after UI state changes, and I am not seeing anything obvious in Logcat that communicates which events are being fired.
For example,
with call forwarding I only see cases like below in Logcat.
START u0 {act=android.intent.action.MAIN cmp=com.android.phone/.GsmUmtsCallForwardOptions}
The machine where you run an Android remotely can be any system supported by the Android SDK: Windows, Mac OS X, or Linux. The socket connections is forward from a specified local port to a specified remote port on the device instance.
It is recommended that this machine is on the same network as your development PC, for performance and configuration reasons, but it is also possible to use any remotely located machine if firewalls and routing are configured correctly. You have to follow specified steps that provide you with the necessary settings in your environment configuration that will allow you to have remote debugging.
Alternatively you can also consider using Google chrome remote debugging for Android. The jsHybugger can also offers you a similar tool that will equally allow Android remote debugging.
Indeed you can choose the approach that suits you better.
Otherwise, if what you meant is to listen to event in some application, then this has to be done by yourself by hand, including it to the respective app you want to listen for every single event. Further details on this direction you find here:
Android listen for all events in application
As you can see, Android has a lot of capabilities, but everything come at some cost - i.e. you have to code it. Otherwise, something that could be done according to your suggestion would be kind of an App or an API that would monitor every single event from all Apps currently in your mobile. But if this is what you really want, then in my view such approach would be cumbersome and overload your mobile.