Android Marshmallow uses permissions migration - android

I am trying to follow the guide from google to implements permissions in my app to work with Android M. ( http://developer.android.com/training/permissions/requesting.html )
However, I am NOT able to check the <uses-permission>, my questions is: should I migrate the <uses-permission> into <permission> ?
int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.WRITE_CALENDAR);
My manifest permissions are this:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
To be more explicit I am able to call only this method:
int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.MEDIA_CONTENT_CONTROL);
I can't check the internet, wake_lock or other <uses-permission>

I can't check the internet, wake_lock or other
That is because those are not dangerous permissions. The dangerous permissions, for Android 6.0, are:
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
ADD_VOICEMAIL
BODY_SENSORS
CALL_PHONE
CAMERA
GET_ACCOUNTS
PROCESS_OUTGOING_CALLS
READ_CALENDAR
READ_CALL_LOG
READ_CELL_BROADCASTS
READ_CONTACTS
READ_EXTERNAL_STORAGE
READ_PHONE_STATE
READ_SMS
RECEIVE_MMS
RECEIVE_SMS
RECEIVE_WAP_PUSH
RECORD_AUDIO
SEND_SMS
USE_SIP
WRITE_CALENDAR
WRITE_CALL_LOG
WRITE_CONTACTS
WRITE_EXTERNAL_STORAGE
You get normal permissions, like WAKE_LOCK and INTERNET, automatically. MEDIA_CONTENT_CONTROL is a signature-level permission; ordinary Android apps cannot hold it.
I need to use <uses-permission-sdk-23> for marshmallow ?
That is for permissions that you only want to request on API Level 23+ devices, but want to skip on older devices.
should I migrate the <uses-permission> into <permission> ?
No. The framework defines the framework permissions. You would use <permission> only if you are defining some custom permission for use by third-party clients of your app's API.

Related

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" />

android api 23 dialog alert permission does not appear

in my app i need the android internet permission.
I have insert the permission in the file AndroidManifest.xml (with others permissions)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
the build.gradle defaul config have the correct api level:
defaultConfig {
applicationId "com.mytry"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
and the activity with the internet call is this:
public class ActivityLoginScreen extends Activity{
final int REQUEST_INTERNET = 1;
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.INTERNET)) {
//permesso giĆ  richiesto in precedenza. Negato dall'utente
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.INTERNET}, REQUEST_INTERNET);
}
}
}
#Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case REQUEST_INTERNET: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "GRANTED", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "NO GRANTED", Toast.LENGTH_SHORT).show();
}
return;
}
}
}
But when i launch my app and go to the activity nothing appare.
If i go in the app settings emulator, i can see only 2 permissions.
Possible solution for this problem? Where i am in wrong?
I have use this type of request in other apps without problems
Thank you.
EDIT:
For all the comments type this:
"no necessary the request because: If an app declares that it needs a normal permission, the system automatically grants the permission to the app"
this is correct.
sorry for this stupid question.
I knew the matter of default permission but my appa did not work anyway because it gave error in Internet permission.
I created a new emulator and now seems to be going.
Not all permission need to be granted by user. According to Android Documentation
System permissions are divided into two categories, normal and dangerous:
Normal permissions do not directly risk the user's privacy. If your app lists a normal permission in its manifest, the system grants the permission automatically.
Dangerous permissions can give the app access to the user's confidential data. If your app lists a normal permission in its manifest, the system grants the permission automatically. If you list a dangerous permission, the user has to explicitly give approval to your app.
You only need to check for permission if the permission is belong to dangerous permission category (Ex: Location, Storage, Camera etc)
Internet permission are granted by default.
It does not require user to grant it, so you already have internet permission just enable your internet.
Normal permissions cover areas where your app needs to access data or
resources outside the app's sandbox, but where there's very little
risk to the user's privacy or the operation of other apps. For
example, permission to set the time zone is a normal permission. If an
app declares that it needs a normal permission, the system
automatically grants the permission to the app. For a full listing of
the current normal permissions, see Normal permissions.
As of API level 23, the following permissions are classified as PROTECTION_NORMAL:
For these no dailog will shown to user system will automatically grant the permission.
ACCESS_LOCATION_EXTRA_COMMANDS
ACCESS_NETWORK_STATE
ACCESS_NOTIFICATION_POLICY
ACCESS_WIFI_STATE
BLUETOOTH
BLUETOOTH_ADMIN
BROADCAST_STICKY
CHANGE_NETWORK_STATE
CHANGE_WIFI_MULTICAST_STATE
CHANGE_WIFI_STATE
DISABLE_KEYGUARD
EXPAND_STATUS_BAR
GET_PACKAGE_SIZE
INSTALL_SHORTCUT
INTERNET
KILL_BACKGROUND_PROCESSES
MODIFY_AUDIO_SETTINGS
NFC
READ_SYNC_SETTINGS
READ_SYNC_STATS
RECEIVE_BOOT_COMPLETED
REORDER_TASKS
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
REQUEST_INSTALL_PACKAGES
SET_ALARM
SET_TIME_ZONE
SET_WALLPAPER
SET_WALLPAPER_HINTS
TRANSMIT_IR
UNINSTALL_SHORTCUT
USE_FINGERPRINT
VIBRATE
WAKE_LOCK
WRITE_SYNC_SETTINGS
All dangerous Android system permissions belong to permission groups.
If the device is running Android 6.0 (API level 23)
PROTECTION_DANGEROUS permissions :
These permissions will show dialog to users.Sample Code
READ_CALENDAR
WRITE_CALENDAR
CAMERA
READ_CONTACTS
WRITE_CONTACTS
GET_ACCOUNTS
ACCESS_FINE_LOCATION
ACCESS_COARSE_LOCATION
RECORD_AUDIO
READ_PHONE_STATE
CALL_PHONE
READ_CALL_LOG
WRITE_CALL_LOG
ADD_VOICEMAIL
USE_SIP
PROCESS_OUTGOING_CALLS
BODY_SENSORS
SEND_SMS
RECEIVE_SMS
READ_SMS
RECEIVE_WAP_PUSH
RECEIVE_MMS
READ_EXTERNAL_STORAGE
WRITE_EXTERNAL_STORAGE

Android Marshmallow ReadPhoneState permission

I have an Android application which need the permissions: READ_PHONE_STATE & CALL_PHONE. I've declared these permissions in the Manifest and it works fine for SDK < 23.
Now in Android 6 (SDK 23) I'm asking the user to grant this permission in runtime.
In the documentation, they say the if the user has granted one of the above permission, he actually granted all the permissions that are found in the same group permissions, in this case all the permission that are related to the phone group permissions.
But I'm facing with a problem, when I'm using telephony manager to get the deviceid, I'm getting a security exceptions that says that I don't have any access, even though the user has granted the "call phone" permission, why is that?
Update:
I'm requesting multiple permissions
In Manifest.xml
<uses-permission android:name="android.permission.CALL_PHONE">
<uses-permission android:name="android.permission.READ_PHONE_STATE">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE">
In Activity:
ActivityCompat.requestPermissions(this,new String[]
{
Manifest.permission.CALL_PHONE,
Manifest.permission.READ_EXTERNAL_STORAGE
},
permissionRequestcode);

Where is the App permission for "identity" in android marshmallow

I am trying to use an emulator with which comes with Android Studio, to see what permissions a user can enable / disable from this device.
While a developer can declare he needs access to "Identity" or contact card, it seems that in the emulator, there is no option to display the apps that have disabled access to "identity".
Does this mean that there is no option for a user to refuse access to identity ? Or is it just that it does not appear in the emulator unless you create an app that requests identity ?
If you are using an API 23 emulator, the grouping of Android permissions has changed for the new runtime permissions model. The full list of dangerous permissions and their associated groups can be found on this table.
You'll note that most of the permissions in the old Identity bucket have either been removed entirely or moved to the 'Contacts' group (as is the case for GET_ACCOUNTS).
Only "dangerous" permissions need to be requested from user in Android 6.0. Others are granted automatically when they are declared in the manifest.
List of dangerous permissions can be found here: http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous - they are divided in groups, which are:
CALENDAR
READ_CALENDAR
WRITE_CALENDAR
CAMERA
CAMERA
CONTACTS
READ_CONTACTS
WRITE_CONTACTS
GET_ACCOUNTS
LOCATION
ACCESS_FINE_LOCATION
ACCESS_COARSE_LOCATION
MICROPHONE
RECORD_AUDIO
PHONE
READ_PHONE_STATE
CALL_PHONE
READ_CALL_LOG
WRITE_CALL_LOG
ADD_VOICEMAIL
USE_SIP
PROCESS_OUTGOING_CALLS
SENSORS
BODY_SENSORS
SMS
SEND_SMS
RECEIVE_SMS
READ_SMS
RECEIVE_WAP_PUSH
RECEIVE_MMS
STORAGE
READ_EXTERNAL_STORAGE
WRITE_EXTERNAL_STORAGE

How to ask for android.permission.CALL_PHONE but still install on tablet? [duplicate]

This question already has an answer here:
Optional permissions so an app can show on all devices and enable optional features on some?
(1 answer)
Closed 7 years ago.
I have an app I just published to the Play Store, that's showing up as "This app is incompatible with all of your devices" when I try to access it from tablets that lack telephony. It installs just fine on actual Android phones.
Here's the thing - we want users to be able to install the app on tablets and other devices that don't have phones, and to simply have the telephone functions not work. But if I include the CALL_PHONE permission in the manifest, the Play Store simply won't allow it to be installed.
<uses-permission android:name="android.permission.CALL_PHONE" />
How do I get Google Play to allow an app that asks for the CALL_PHONE permission to install on a device that doesn't have a phone?
You can specify that Telephony is optional:
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
The documentation says:
The table below lists permissions that imply feature requirements
equivalent to those declared in elements. Note that
declarations, including any declared android:required
attribute, always take precedence over features implied by the
permissions below.
For any of the permissions below, you can disable filtering based on
the implied feature by explicitly declaring the implied feature
explicitly, in a element, with an
android:required="false" attribute. For example, to disable any
filtering based on the CAMERA permission, you would add this
declaration to the manifest file:
<uses-feature android:name="android.hardware.camera" android:required="false" />
In your case, the relevant portion of the table is:
Cateegory This permission... Implies This Feature Requirement
Telephony CALL_PHONE android.hardware.telephony
CALL_PRIVILEGED android.hardware.telephony
MODIFY_PHONE_STATE android.hardware.telephony
PROCESS_OUTGOING_CALLS android.hardware.telephony
READ_SMS android.hardware.telephony
RECEIVE_SMS android.hardware.telephony
RECEIVE_MMS android.hardware.telephony
RECEIVE_WAP_PUSH android.hardware.telephony
SEND_SMS android.hardware.telephony
WRITE_APN_SETTINGS android.hardware.telephony
WRITE_SMS android.hardware.telephony

Categories

Resources