Permission Denial: reading com.android.providers.c

2019-07-19 05:06发布

问题:

I'm getting this exception on a specific phone and carrier: Samsung Galaxy S3 on Verizon. I've tested in an Evo with Sprint and a Galaxy Nexus with AT&T and none give me this error. I'm wondering if the phone carrier has done any modifications to the OS that now requires additional special permissions. I recorded the following stack trace remotely from a customer who has a Galaxy S3:

Stack Trace:

    Permission Denial: reading com.android.providers.contacts.CallLogProvider 
uri content://call_log/calls from pid=23104, uid=10233 
requires android.permission.READ_CALL_LOG, or grantUriPermission()
java.lang.SecurityException: Permission Denial: reading 
com.android.providers.contacts.CallLogProvider 
uri content://call_log/calls from pid=23104, uid=10233 
requires android.permission.READ_CALL_LOG, or grantUriPermission()  
at android.os.Parcel.readException(Parcel.java:1430)  at 
android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)  at 
android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)  at 
android.content.ContentProviderProxy.query(ContentProviderNative.java:423)  at 
android.content.ContentResolver.query(ContentResolver.java:375)  at 
android.content.ContentResolver.query(ContentResolver.java:318)

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xyz"
    android:installLocation="auto"
    android:versionCode="1"
    android:versionName="1" >

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_MMS" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
    <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
    <uses-permission android:name="android.permission.RESTART_PACKAGES" />
    <uses-permission android:name="android.permission.READ_CALL_LOG" />    
    <uses-permission android:name="android.permission.WRITE_CALL_LOG" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="9">
    </uses-sdk>

回答1:

Allows an application to read the user's call log.

Note: If your app uses the READ_CONTACTS permission and both your minSdkVersion and targetSdkVersion values are set to 15 or lower, the system implicitly grants your app this permission. If you don't need this permission, be sure your targetSdkVersion is 16 or higher.

Constant Value: "android.permission.READ_CALL_LOG"

According to your manifest:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="9"></uses-sdk>

Maybe you should try removing the READ_CONTACTS permission, or set targetSdkVersion="9"

Source: Manifest.permissions #READ_CALL_LOG