Can pills make calls? (Telephony)

I have permission in the manifest:

 <uses-feature 
   android:name="android.permission.READ_PHONE_STATE"  android:required="false" />

Code that checks if the phone is in use is likely to trigger a security exception for devices such as tablets that cannot receive calls. So, I made this method to check if the device can use TelephonyManager:

private boolean doesUserHavePermission(){
    PackageManager pm = getPackageManager();
    final boolean deviceHasPhone = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    return deviceHasPhone;
}

And in the code where I really check if the call is received, I put an if statement to find out if the device has a phone or not:

private PhoneStateListener phoneStateListener = new PhoneStateListener() {
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        if (doesUserHavePermission()) { //I ADDED THIS
            if (state == TelephonyManager.CALL_STATE_RINGING) {
                onPhoneCallInterrupt(); //Method I made that mutes audio for phone call
            } else if (state == TelephonyManager.CALL_STATE_IDLE) {
            } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                onPhoneCallInterrupt(); //Method I made that mutes audio for phone call
            }
        }
    }
};

I made a toast to check the return value of this boolean method doesUserHavePermission(), and it always returns true, even on my emulator tablet ... this is strange because tablets cannot make / receive calls ...

The emulator device on which I tested this was:

enter image description here

?

+4
1

, . , , , .

, . , , , .

0

All Articles