Is it possible to monitor all camera activity on Android - android

I have a requirement to develop an application which will monitor the usage of the phone cameras and record information about when/where a photo was taken. I am aware that this information is typically recorded in the image metadata but I have a need to add additional information to this and record it separately from the image.
In essence, I would like to know:
Any time the camera is opened, closed, activated (brought to front), deactivated (user switches to another app)
Any time the camera saes a file; either a photo or a video
Know the above regardless of whether the camera was launched directly or via another app
Know the above regardless of whether the caller used an intent or the camera APIs.
Are there good APIs to use for this? Is it possible to replace low-level interfaces to act as a man-in-the-middle? Is it possible from Java or would this necessarily be in C/C++?
At the moment my only solution would be to monitor the logs in a continuous service to identify everything I could from the above and implement a FileObserver to check for file creation/modification times.

Are there good APIs to use for this?
There are no APIs for this, for obvious privacy and security reasons.
Is it possible to replace low-level interfaces to act as a man-in-the-middle?
On a rooted device, perhaps. In a custom ROM, definitely. In an ordinary Android device, no, for obvious privacy and security reasons.
would be to monitor the logs in a continuous service to identify everything I could from the above
You have no access to logs, other than those generated by your own process, on Android 4.1+, except on rooted devices or from a custom ROM.
and implement a FileObserver to check for file creation/modification times
There is no requirement for a camera app to store a file in a place for which you have filesystem access.

Related

Is there any way in Android 12 to observe Camera and Mic toggle state to prevent stream blank frame or silent audio? [duplicate]

With the new Android 12 operating system, the user now has the ability to completely disable microphone and camera usage from ALL apps. This is actually a good thing, letting users easily control privacy.
If an app starts and has permission to use the microphone and the camera AND the user has disabled all access to either of these hardware, Android 12 automatically pops up an alert asking the user to re-enable the microphone or camera, or to continue with the hardware disabled for the app.
Also, on creation, the app can simply check when starting to see if the needed hardware is enabled, and can also prompt the user further or handle the condition as the app sees fit.
But what if the user disables the microphone or camera while the app is running? I can't seem to find any interfaces for something like onMicrophoneEnabled() or even a Broadcast of such an event.
It's possible to check every time onResume() is called, but I was hoping there'd be a more elegant solution.
If anyone knows of something that my app can use to capture this when the user has made changes either way, please let me know.
After carefully reading the google docs (https://developer.android.com/training/permissions/explaining-access#toggles) on their implementation of the user enable/disable of the camera and microphone I discovered something very interesting:
Apps are explicitly forbidden from knowing if the user has done any of these actions. So of course there is no way to get notified of these changes: it is by design.
If the user turns off the camera this way, the app will still get a camera feed, but it will be black. Similarly the microphone will still work, but we'll get only silence. This is a feature--a way to ensure privacy.
The operating system will remind users that they have disabled the microphone or camera and provide a chance to re-enable the hardware, which is nice. But the app is completely in the dark (hehe).
Another way to think of it: Just like putting a piece of tape over your camera or your thumb over the microphone. Only this time it's done by the operating system. This way a spy program or some other nefarious software will still think it's working and not try to bypass or give up.
This also explains why testing during onResume() or onWindowFocusChanged() didn't work either. I was getting results that didn't align with the settings (they aligned with current permissions).
So to answer my question: There is no way to be notified. That is the point.

How to let other apps take over microphone access?

Is there any way to know when another app is trying to access the microphone so i can let the other app use it?
My current app keeps recording in the background but it blocks other apps access to the microphone, is there a way to let other apps take over microphone access?
It all depends on your use case. Theoretically you cannot "borrow" the permission from other apps for security reasons but nothing would prevent the app that already holds the permission to expose recording as "service". I do not mean Android Service here, but rather ability of letting other apps to ask your app (i.e. via special Intent or any other way) to do the recording and then return recorded data back.
And as already mentioned, keep in mind, this won't work on Android P as no longer available when app is not in foreground.
And we talk about non-rooted devices, because on rooted, you may do not care the permissions that much.

Can an android application get information from other applications?

I am new to android development. I came to know that Intent and Intent filters can be used to share data among applications but I wonder if it is possible to design an android application which can extract some specific information from other applications while running in the background. For example, if the user is using whatsapp it may get know the call drop rate or if a video is being played at user terminal in YouTube, Facebook or Netflix, it will get buffer playtime, video bitrate etc. I will be very grateful if answer to this question is provided with an example.
No, mostly no.
However, as wrote Tim Castelijns, if the 'target' app allows it, like via a content provider, its possible.
On a rooted device, after long hours of reverse engineering the targeted apps, it MAY also be possible to get some info. Only from rooted devices too.
Other case is you write several app and design that they can communicate together, like via intents, content providers.
There is also possible to get the list of running apps (user must permit it)
In Android, each application is running on its own "sandbox" that is supposed to be isolated from the rest of the applications running on the device.
In order for an application to communicate with other applications, the Android framework supplies several mechanisms to send/receive data to/from other applications: Intents, IPC (AIDL), Content Providers etc...
Each application that wants to expose its data to other applications on the device needs to implement an interface using one or more of the mechanisms described above.
That means that if an application doesn't implement an interface to expose its data or inner workings, it won't be possible for another application to access this information.
Keep in mind that some applications choose to save some of their data on publicly available disk spaces (i.e. a camera that takes pictures might save them on the SDcard that is accessible by all applications). In that case, if you know what to look for, you can tell certain things about certain applications.
In addition, the Android operation system exposes the states of several global settings such as: Device's connectivity state, Battery state, currently opened Bluetooth interfaces, running applications, last executed apps etc...
This configurations might give you an overall idea of what is happening on the device.
As indicated in other answers, you're mostly limited to what apps will explicitly make available to you; in fact, well-engineered apps will generally try to prevent "information leakage" beyond what they actually want to make available.
Some other people mentioned Content Providers but the one other construct to look into is Broadcasts. If an app broadcasts an intent locally (i.e. is using the Local Broadcast Manager) you won't be able to see it but if they're using a "system-wide" broadcast or receiving another "system-wide" broadcast you can receive the same event.

Android permissions

For start I must say that I´m new to Android.
I´m a Msc Student and for my Msc thesis I've to develop a system that collects all user inputs on the touchscreen, regardless of the applications that are being used, and it must be done in background.
The objective is to use that data to establish a user profile and then apply an algorithm that continuously compare the new inputs with that old ones to grant the legitimate user authentication.
In other words I've to develop a touchlogger, but not for malicious purposes.
My question is: Are the initial permissions, that a user accepts in the installation process, enough to allow my app to collect the touch inputs from other applications, or it will be blocked because of the sandbox?
Note: The system is to be used for a regular person in a regular device, so rooting the device must not be an option.
Thanks for your help.
Best Regards
This is not possible, especially in newer versions of Android.
This is because even though there are system overlays allow you to display things like chat heads over any other app, you cannot capture touch events and pass them down to the app below. So even if you manage to capture the events, you will end up rendering the device useless, as nothing below your layover will work.

How to make GSM calls via code

I have a requirement where I would want to initiate and manage GSM calls (Like the ones we make via Phone)
I will be connecting to a GSM Module/DTMF Module (context: robotics) via this method and would be sending instructions via DTMF tones.
I don't want to open up the phone dialer via an Intent with tel: data, would rather want to manage the telephony myself.
First thought that the system might not allow a third-party app, without a signature matching system's signature, to do telephony stuff, but then I wondered how some of the apps available in the market are doing it. (I'll attach links as soon as I find suitable ones)
EDIT: The apps that I had seen, were launchers and call manager apps, and once installed, had replaced my default phone apps (and thus were making calls instead of the default phone app doing it)
EDIT: I have found this question asking something similar, and also has an answer: Android Dialer application. I'll try this out and post back if I get any success.
Any pointers will be greatly appreciated.

Categories

Resources