com.android.deskclock意外停止,Permission Denial: opening provider com.android.deskclock.provider.ClockPr...

在通过读取系统闹铃的provider获取闹铃时间列表时,出现了这个异常:

Caused by: java.lang.SecurityException: Permission Denial:

opening provider com.android.deskclock.provider.ClockProvider from

ProcessRecord{65f49190 8676:com.wisesean.heartbeat.alarm/u0a185}

(pid=8676, uid=10185) that is not exported from uid 10014

at

android.os.Parcel.readException(Parcel.java:1465)

at

android.os.Parcel.readException(Parcel.java:1419)

at

android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2848)

at

android.app.ActivityThread.acquireProvider(ActivityThread.java:4415)

at

android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2207)

at

android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1425)

at

android.content.ContentResolver.query(ContentResolver.java:445)

at

android.content.ContentResolver.query(ContentResolver.java:404)

看到异常以为是某个权限没有,经过查证发现是系统闹铃数据并不允许,其他的进程读取。

AlarmProvider在定义时有android:exported="false"这个标签:

android:exported

Whether the content provider is available for

other applications to use:

true:

The provider is available to other applications. Any application

can use the provider's content URI to access it, subject to the

permissions specified for the provider.

false:

The provider is not available to other applications.

Set android:exported="false" to

limit access to the provider to your applications. Only

applications that have the same user ID (UID) as the provider will

have access to it.

The default value is "true" for

applications that set either orto "16" or

lower. For applications that set either of these attributes

to"17" or

higher, the default is "false".

You can set android:exported="false" and

still limit access to your provider by setting permissions with

the attribute.

看了这里我再到源码里查看了,Alarm的AndroidManifest.xml中的定义,Provider定义如下:

android:authorities="com.android.deskclock"

android:exported="false"

/>

设置为不允许其他应用使用AlarmProvider,因此才报了这个异常,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值