Cordova Android app and user permissions - android

I have an Android Cordova app and I'm using GPS, check the network state, read/write on the Documents folder and taking camera pictures. Here my permissions on the manifest XML file:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
The manifest file is auto generated by the Cordova framework. For some reason I don't see camera permissions. Permissions are not asked at installation time anymore (that's since Android 6) but instead they should be asked before usage.
I correctly get the GPS access permission popup but not the read/write Documents folder permission. I also never get the camera permission albeit I'm able to use it without ever being asked for permission. Same story for the Network status permissions (never being asked).
I find Android permissions scheme extremely confusing, under application manager my app has got Location and Storage as expected, Camera and Network status are missing though.
To recap, inside the app, on the actual code, I'm using at least once those devices
GPS fine grained
GPS coarse (probably the Wifi SSID triangulation trick)
Write on Documents
Read on Documents
Read network status (Offline / Wifi / 3G etc..)
Take picture from the camera
Cordova framework wrote this manifest file:
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_FINE_LOCATION
android.hardware.location.gps (why is it not a .permission?)
android.permission.ACCESS_NETWORK_STATE
android.permission.WRITE_EXTERNAL_STORAGE
On application manager I get those options:
Location
Storage
So basically I get three different sets of permissions :-(

I found this in the this cordova plugin that you mentioned in comments.
So somehow this <uses-permission android:name="android.permission.CAMERA/> have to be in your code so as this plugin can use it.
Maybe you didn't check the right program to see its permissions, or if the camera permission is not shown in application permissions on device, you can't be able to use camera in this application. Please do a check again because I really want to know what is the situation.

Related

how to get gps data without permission reguesting in android8.0 above?

I 'm developing a certain app.
I 'm trying to get GPS data in samsung galaxy s8 - android 8.0.
App runs in foreground service, but it doesn't works well.
It returns error string like below.
java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
Permissions in Android Manifest file:
"uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" "
"uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" "
Is there any way to get gps location without runtime permission request?
No, there is no way to acquire permissions without asking at the run time. However, from API 22 and lower, all the permissions are automatically granted at install time.

App getting network issue on latest android real device

In my app I am asking user to access below permission on runtime
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
at my Activity file I used Easypermission library to enable runtime permission
My app shows user current location after launch. Getting user permission fetch user contact list and then store into firebase database. see device1 pic
Note : Device1 android version : 5.1.1
But fetching problem on another device. where application not getting internet. show as device2 below pic
Note : Device2 android version is 9. Except this app all are working fine on device2
I don't get any clue where is the problem. both device are connected on same wifi.
code is fine except you are fetching location and move camera to current location if internet is connected. see your condition :
if(Connectivity.isConnected(this)) { }
if device doesn't have internet connection it will not proceed inside loop.

Android Oreo 8.0+ Disable Network Permissions Problems

I'm building a Cordova app that needs to access WiFi on Android and disable the currently connected network in order to prevent automatic disconnection from the network i'm having it connect to (since there is no internet).
The problem is that when testing on Android Oreo 8.0+ I am getting this error in adb logcat and I can't figure out what I need to do to fix this:
E/WifiConfigManager: UID 10315 does not have permission to update configuration "Test SSID"WPA_PSK
E/WifiStateMachine: Failed to disable network
These are the perms listed in manifest:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
<uses-permission android:name="android.permission.INTERNET" />
The OVERRIDE_WIFI_CONFIG perm I found on this post, but that doesn't seem to help in my specific situation: Changing Android hotspot settings
I found this specific error located in this file:
https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/master/service/java/com/android/server/wifi/WifiConfigManager.java#984
Which calls canModifyNetwork which I found here:
https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/master/service/java/com/android/server/wifi/WifiConfigManager.java#651
Can anybody more experienced with Android help me to resolve this issue, and what needs to be done in order to allow my app to disable networks?
Does this mean that apps are not allowed to disable a network if it wasn't created by the app?? Please help I don't know where to go from here!
I did find this post as well, which references 6.0, but is this true that we're basically completely locked out of disabling networks we didn't create? Android 6.0 Cannot add WifiConfiguration if there is already another WifiConfiguration for that SSID
I am not able to answer your question per se, but I can answer this
Does this mean that apps are not allowed to disable a network if it
wasn't created by the app?
That's correct, as according the documentation of the method disableNetwork:
Disable a configured network. The specified network will not be a
candidate for associating. This may result in the asynchronous
delivery of state change events. Applications are not allowed to
disable networks created by other applications.
So if the user has already connected to this network using the Android system, in Oreo you won't be able to disable the network.
Though the method disableNetwork returns true or false in the case of success or failure

Android internet permission ignored

I have an application that requires the internet permission but it doesn't seem to be working for me.
I added:
<uses-permission android:name="android.permission.INTERNET"/>
To the manifest (above the application tag) and when I install the app my phone says: "No permissions requested" and the permission dialog doesn't show up.
However when I replace INTERNET with CAMERA like so:
<uses-permission android:name="android.permission.CAMERA"/>
It works fine and shows up under the permissions tab in settings.
Any ideas?
Thanks
If the device is running Android 6.0 (API level 23) and the app's targetSdkVersion is 23 or higher if an app declares in its manifest that it needs a normal permission, the system automatically grants the app that permission at install time.
The system does not prompt the user to grant normal permissions, and users cannot revoke these permissions.
As you can check in the official doc the INTERNET permission is normal.
Instead the CAMERA permission is dangerous.
You're running your app in Android SDK>=23.
Internet permission is under Normal permission so it not show any permission prompt but Camera permission is under Dangerous Permission so it show permission prompt.
If an app declares that it needs a normal permission, the system automatically grants the permission to the app.
https://developer.android.com/guide/topics/permissions/requesting.html
Android only puts the dangerous permissions there. And since Camera is a dangerous permissions you see it in the list, and since Internet is not, you don't see it in the list.
Android differentiates between normal permissions (e.g. INTERNET) and dangerous permissions (e.g. CAMERA). The User is only asked in case of dangerous permissions. So the behavior you see is perfectly normal.
https://developer.android.com/guide/topics/permissions/normal-permissions.html
Only Selected permissions can be asked for user
check here which permissions can be asked by Permission manager
This usually does the trick for me:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Mi5 'It seems that your device does not support camera(or it is locked) Application will be closed' issue

I tried to run a simple camera OpenCV on mi 5. I installed the OpenCV_2.4.3_Manager_2.0_armeabi.apk but my mobile screen displayed 'It seems that your device does not support camera(or it is locked). Application will be closed' at the time of opening the app. How to resolve this issue?
Android 6.0 has introduced a new permission model. Application has to request the user for granting some permissions manually, declaration in Manifest is not enough.
More info here: https://developer.android.com/training/permissions/requesting.html
Going to: Settings -> Apps -> Your app -> Permissions and enabling the Camera permission
should also work, but might not be too elegant solution
Check in your manifest:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-feature android:name="android.hardware.camera.front"/>
<uses-feature android:name="android.hardware.camera.front.autofocus"/>
or, check in your device
Settings -> Apps -> Your app -> Permissions and enabling the Camera permission
or,
kill any other apps that are using the camera.
If those doesn't work! You device doesn't support openCV, not all devices support it!

Categories

Resources