Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why READ_PHONE_STATE permission asked "make and manage phone call"?

For getting the IMEI i using from this code:

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
       if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 1);
        } else { 
                iMEI = tm.getDeviceId(); 
        }

But when my app is running this dialog box coming up:

enter image description here

The program asks to grant permission To make and manage phone calls which can scary users from using app.

And now my question is:

Why READ_PHONE_STATE permission asked "make and manage phone call"? While I have not make phone call and manage phone call in my app.

like image 362
Saeed Avatar asked Dec 23 '22 22:12

Saeed


2 Answers

READ_PHONE_STATE permission is listed as Dangerous permission and provides access to read phone state. It comes under the Phone permission group. If dangerous permission is asked, the system shows dialog related to its group. in your case, Phone. and That is the reason- the user is asked for "make and manage phone call" permission. This is how the permissions are asked- https://developer.android.com/training/permissions/requesting

To make it more clear, see https://developer.android.com/guide/topics/permissions/overview

It says -

If the device is running Android 6.0 (API level 23) and the app's targetSdkVersion is 23 or higher, the following system behavior applies when your app requests a dangerous permission:

  • If the app doesn't currently have any permissions in the permission group, the system shows the permission request dialog to the user
    describing the permission group that the app wants access to. The
    dialog doesn't describe the specific permission within that group.
    For example, if an app requests the READ_CONTACTS permission, the
    system dialog just says the app needs access to the device's
    contacts. If the user grants approval, the system gives the app just
    the permission it requested.

  • If the app has already been granted another dangerous permission in the same permission group, the system immediately grants the
    permission without any interaction with the user. For example, if an
    app had previously requested and been granted the READ_CONTACTS
    permission, and it then requests WRITE_CONTACTS, the system
    immediately grants that permission without showing the permissions
    dialog to the user.

There are a lot of better ways to get a unique identifier. For example-

String android_id = Settings.Secure.getString(getApplicationContext().getContentResolver(),
                Settings.Secure.ANDROID_ID);
like image 96
Deˣ Avatar answered Dec 25 '22 23:12

Deˣ


Why READ_PHONE_STATE permission asked "make and manage phone call"? While I have not make phone call and manage phone call in my app.

After Marshmallow we need to explicitly call the permissions which come under Dangerous permission.

READ_PHONE_STATE comes under Permission Group Called Phone

like image 33
Madhur Avatar answered Dec 26 '22 00:12

Madhur