I am exploring about using Android Management API to restrict the use of Camera for my company device. So what I need is disable all camera access except for 1 application that my company made to take picture using camera.
So what I want to ask is it possible to restrict all camera access using android management api except for 1 application that my company made?
There are some workarounds depending on the use case:
By setting the device to fully manage mode, you can disable camera access on the entire device using the policy "cameraDisabled": true. In this case, there is no way you can allow exceptions for specific custom app since the policy is device-wide and cannot be overridden with "permissionGrants": [ {object ([PermissionGrant])} ].
With that being said there are a few things we can do depending on the use case:
Making the camera app the default app that responds to android.media.action.IMAGE_CAPTURE intent using PersistentPreferredActivity
Setting up the device in kiosk mode and expose the camera app to the user.
Related
I have application signed by platform key and I need to move device to kiosk mode.
What kiosk mode mean in my case:
Set user restrictions (change default activities, set VPN etc...)
Prevent user access to third party apps, some system apps etc...
Set custom Activity as Home activity without user interaction
Move application to lock task mode
I know that DevicePolicyManager could do that. But device doesn't have any google's provisioning system (like NFC or QR). Is exist any way to set device owner using application signed by platform key or use such application with benefits of device owner App?
I find out that application with system privileges could do al lot of thing that could be done with DevicePolicyManager. But some of functionality provided as hide API:
Set user restrictions - could be done with UserManager
Prevent user access to third party apps - could be done be disabling such apps with package manager
Set custom Activity as Home activity without user interaction - could be done with PackageManager
Move application to lock task mode - could be done by disabling UI components in status bar and system navigation bar with StatusBarService
The platform key only gives you certain permissions to take a certain role or to make some system settings, but for your task you are mainly right with the DevicePolicyManager. I do not see why you need NFC or QR for that, you could implement a simple code to unlock the kiosk mode.
There are of course finished applications to do that and you would not need to re-invent the wheel as this kind of application is not trivial.
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.
For example, it's for promotions or events. Therefore I want users not able to leave our app. For iOS, i guess I can make a frame to physically block the main button. But for Android, i don't know how.
This is currently not possible. It is scheduled to be included in the upcoming L release. See Task locking.
"The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode."
Is that possible to enable camera setting pragrammatically? I want to enable camera setting page programmatically and enable the user to do something from that page. I have searched so far, cant able to get proper reference.
I'm going to assume you want to open the Camera preferences activity and set location tagging on, in a similar way that Google Maps directs the user to a system preferences activity for switching on GPS. Unfortunately this isn't possible for the camera application, mainly because the camera app isn't standard across android devices.
Personally I have three camera apps on phone, not including apps like Eyem and Instagram, and I don't think this is unusual. None of them have the same activity for setting the preferences, and even the built in app doesn't have a standard preferences activity.
If you want to go down this route the best you can probably do is first check for location services being available (see How to check if Location Services are enabled? for an example if you are unsure) before invoking the intent to take the picture. Direct the user to turn them on if necessary and also, warn them that you require location tagging turned on in their camera app of choice.
if you are talking about Camera.Parameters when you say settings, yes of course you can.
All possibilities are listed here:
http://developer.android.com/reference/android/hardware/Camera.Parameters.html
You will have to write your own user interface to get the desired parameters and pass them to the camera-objekt before you start a preview.
I want to enable/disable camera programmatically in my application.
You cannot do this from a regular app. You can do it from a device administrator, but the user has to explicitly enable it and it is only available on ICS. Here's the reference: http://developer.android.com/guide/topics/admin/device-admin.html
The OP is asking for any ideas, I got one idea and it could possibly work even without using the API provided by ICS.
for lower API version than ICS, you can Start a service that will lock the Camera when the screen is On and Release it when the Screen is Off. This is to minimize the usage of battery.
Since, only one process can use the Camera at a time, other applications like the Camera App will not be able to use the Camera.
The challenge now is how to ensure that the Service Hogging the Camera is always Running and prevent it from being uninstalled by the user.
Well, just a thought ;)
Yes, you can use DeviceAdministration class and control the camera source(block and unblock). This is a repo with an example.
Yes you can disable or enable camera but your app must device admin enabled.Following enables or disable camera:-
devicePolicyManager.setCameraDisabled(compName, isCameraOn);
**isCameraOn** is boolean true or false