Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.HEADSET_PLUG

crash information:
Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.HEADSET_PLUG from
    at android.os.Parcel.readException(Parcel.java:1465) 
    at android.os.Parcel.readException(Parcel.java:1419)

ActivityManagerService.java:
               if (AppGlobals.getPackageManager().isProtectedBroadcast( //whether the protected broadcastion
                        intent.getAction())) {                          //判断是否是受保护的广播
                    String msg = "Permission Denial: not allowed to send broadcast "
                            + intent.getAction() + " from pid="
                            + callingPid + ", uid=" + callingUid;
                    Slog.w(TAG, msg);
                    throw new SecurityException(msg);
                } else if (AppWidgetManager.ACTION_APPWIDGET_CONFIGURE.equals(intent.getAction())) {
                     .....
                    }
                }

This is protected intent that can only be sent by the system.

frameworks/base/core/res/AndroidManifest.xml
    <!-- ================================================ -->
    <!-- Special broadcasts that only the system can send -->
    <!-- ================================================ -->
<protected-broadcast android:name="android.intent.action.HEADSET_PLUG" />

    <protected-broadcast android:name="android.intent.action.SCREEN_OFF" />
    <protected-broadcast android:name="android.intent.action.SCREEN_ON" />
    <protected-broadcast android:name="android.intent.action.USER_PRESENT" />
    <protected-broadcast android:name="android.intent.action.TIME_SET" />
    <protected-broadcast android:name="android.intent.action.TIME_TICK" />
    <protected-broadcast android:name="android.intent.action.TIMEZONE_CHANGED" />
    <protected-broadcast android:name="android.intent.action.DATE_CHANGED" />
    <protected-broadcast android:name="android.intent.action.BOOT_COMPLETED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_INSTALL" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_ADDED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_REPLACED" />
    <protected-broadcast android:name="android.intent.action.MY_PACKAGE_REPLACED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_REMOVED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_CHANGED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_RESTARTED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_DATA_CLEARED" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_FIRST_LAUNCH" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_NEEDS_VERIFICATION" />
    <protected-broadcast android:name="android.intent.action.PACKAGE_VERIFIED" />
    <protected-broadcast android:name="android.intent.action.UID_REMOVED" />
    <protected-broadcast android:name="android.intent.action.QUERY_PACKAGE_RESTART" />
    <protected-broadcast android:name="android.intent.action.CONFIGURATION_CHANGED" />
    <protected-broadcast android:name="android.intent.action.LOCALE_CHANGED" />
    <protected-broadcast android:name="android.intent.action.BATTERY_CHANGED" />
    <protected-broadcast android:name="android.intent.action.BATTERY_LOW" />
    <protected-broadcast android:name="android.intent.action.BATTERY_OKAY" />
    <protected-broadcast android:name="android.intent.action.ACTION_POWER_CONNECTED" />
    <protected-broadcast android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
    <protected-broadcast android:name="android.intent.action.ACTION_SHUTDOWN" />
    <protected-broadcast android:name="android.intent.action.DEVICE_STORAGE_LOW" />
    <protected-broadcast android:name="android.intent.action.DEVICE_STORAGE_OK" />
    <protected-broadcast android:name="android.intent.action.DEVICE_STORAGE_FULL" />
    <protected-broadcast android:name="android.intent.action.DEVICE_STORAGE_NOT_FULL" />
    <protected-broadcast android:name="android.intent.action.NEW_OUTGOING_CALL" />
    <protected-broadcast android:name="android.intent.action.REBOOT" />
    <protected-broadcast android:name="android.intent.action.DOCK_EVENT" />
    <protected-broadcast android:name="android.intent.action.MASTER_CLEAR_NOTIFICATION" />
    <protected-broadcast android:name="android.intent.action.USER_ADDED" />
    <protected-broadcast android:name="android.intent.action.USER_REMOVED" />
    <protected-broadcast android:name="android.intent.action.USER_STARTING" />
    <protected-broadcast android:name="android.intent.action.USER_STARTED" />
    <protected-broadcast android:name="android.intent.action.USER_STOPPING" />
    <protected-broadcast android:name="android.intent.action.USER_STOPPED" />
    <protected-broadcast android:name="android.intent.action.USER_BACKGROUND" />
    <protected-broadcast android:name="android.intent.action.USER_FOREGROUND" />
    <protected-broadcast android:name="android.intent.action.USER_SWITCHED" />

    <protected-broadcast android:name="android.app.action.ENTER_CAR_MODE" />
    <protected-broadcast android:name="android.app.action.EXIT_CAR_MODE" />
    <protected-broadcast android:name="android.app.action.ENTER_DESK_MODE" />
    <protected-broadcast android:name="android.app.action.EXIT_DESK_MODE" />

    <protected-broadcast android:name="android.appwidget.action.APPWIDGET_UPDATE_OPTIONS" />
    <protected-broadcast android:name="android.appwidget.action.APPWIDGET_DELETED" />
    <protected-broadcast android:name="android.appwidget.action.APPWIDGET_DISABLED" />
    <protected-broadcast android:name="android.appwidget.action.APPWIDGET_ENABLED" />

    <protected-broadcast android:name="android.backup.intent.RUN" />
    <protected-broadcast android:name="android.backup.intent.CLEAR" />
    <protected-broadcast android:name="android.backup.intent.INIT" />

    <protected-broadcast android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.adapter.action.SCAN_MODE_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.adapter.action.DISCOVERY_STARTED" />
    <protected-broadcast android:name="android.bluetooth.adapter.action.DISCOVERY_FINISHED" />
    <protected-broadcast android:name="android.bluetooth.adapter.action.LOCAL_NAME_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.UUID" />
    <protected-broadcast android:name="android.bluetooth.device.action.ALIAS_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.FOUND" />
    <protected-broadcast android:name="android.bluetooth.device.action.DISAPPEARED" />
    <protected-broadcast android:name="android.bluetooth.device.action.CLASS_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.ACL_CONNECTED" />
    <protected-broadcast android:name="android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED" />
    <protected-broadcast android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
    <protected-broadcast android:name="android.bluetooth.device.action.NAME_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.BOND_STATE_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.device.action.NAME_FAILED" />
    <protected-broadcast android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
    <protected-broadcast android:name="android.bluetooth.device.action.PAIRING_CANCEL" />
    <protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_REPLY" />
    <protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_CANCEL" />
    <protected-broadcast android:name="android.bluetooth.device.action.CONNECTION_ACCESS_REQUEST" />
    <protected-broadcast android:name="android.bluetooth.devicepicker.action.LAUNCH" />
    <protected-broadcast android:name="android.bluetooth.devicepicker.action.DEVICE_SELECTED" />
    <protected-broadcast
        android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" />
    <protected-broadcast
        android:name="android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED" />
    <protected-broadcast
        android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" />
    <protected-broadcast
        android:name="android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED" />
    <protected-broadcast
        android:name="android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED" />
    <protected-broadcast
        android:name="android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED" />
    <protected-broadcast
        android:name="android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED" />
    <protected-broadcast
        android:name="android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS" />
    <protected-broadcast
        android:name="android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED" />
    <protected-broadcast android:name="android.bluetooth.pbap.intent.action.PBAP_STATE_CHANGED" />
    <protected-broadcast android:name="android.btopp.intent.action.INCOMING_FILE_NOTIFICATION" />
    <protected-broadcast android:name="android.btopp.intent.action.BT_OPP_HANDOVER_STARTED" />
    <protected-broadcast android:name="android.btopp.intent.action.TRANSFER_COMPLETE" />
    <protected-broadcast android:name="android.btopp.intent.action.USER_CONFIRMATION_TIMEOUT" />
    <protected-broadcast android:name="android.btopp.intent.action.BT_OPP_TRANSFER_PROGRESS" />
    <protected-broadcast android:name="android.btopp.intent.action.LIST" />
    <protected-broadcast android:name="android.btopp.intent.action.OPEN_OUTBOUND" />
    <protected-broadcast android:name="android.btopp.intent.action.HIDE_COMPLETE" />
    <protected-broadcast android:name="android.btopp.intent.action.CONFIRM" />
    <protected-broadcast android:name="android.btopp.intent.action.HIDE" />
    <protected-broadcast android:name="android.btopp.intent.action.BT_OPP_TRANSFER_DONE" />
    <protected-broadcast android:name="android.btopp.intent.action.RETRY" />
    <protected-broadcast android:name="android.btopp.intent.action.OPEN" />
    <protected-broadcast android:name="android.btopp.intent.action.OPEN_INBOUND" />
    <protected-broadcast android:name="com.android.bluetooth.pbap.authchall" />
    <protected-broadcast android:name="com.android.bluetooth.pbap.userconfirmtimeout" />
    <protected-broadcast android:name="com.android.bluetooth.pbap.authresponse" />
    <protected-broadcast android:name="com.android.bluetooth.pbap.authcancelled" />

    <protected-broadcast android:name="android.hardware.display.action.WIFI_DISPLAY_STATUS_CHANGED" />

    <protected-broadcast android:name="android.hardware.usb.action.USB_STATE" />
    <protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
    <protected-broadcast android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
    <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />

    <protected-broadcast android:name="android.intent.action.HEADSET_PLUG" />
    <protected-broadcast android:name="android.intent.action.ANALOG_AUDIO_DOCK_PLUG" />
    <protected-broadcast android:name="android.intent.action.DIGITAL_AUDIO_DOCK_PLUG" />
    <protected-broadcast android:name="android.intent.action.HDMI_AUDIO_PLUG" />
    <protected-broadcast android:name="android.intent.action.USB_AUDIO_ACCESSORY_PLUG" />
    <protected-broadcast android:name="android.intent.action.USB_AUDIO_DEVICE_PLUG" />

    <protected-broadcast android:name="android.media.AUDIO_BECOMING_NOISY" />
    <protected-broadcast android:name="android.media.RINGER_MODE_CHANGED" />
    <protected-broadcast android:name="android.media.VIBRATE_SETTING_CHANGED" />
    <protected-broadcast android:name="android.media.VOLUME_CHANGED_ACTION" />
    <protected-broadcast android:name="android.media.MASTER_VOLUME_CHANGED_ACTION" />
    <protected-broadcast android:name="android.media.MASTER_MUTE_CHANGED_ACTION" />
    <protected-broadcast android:name="android.media.SCO_AUDIO_STATE_CHANGED" />
    <protected-broadcast android:name="android.media.ACTION_SCO_AUDIO_STATE_UPDATED" />

    <protected-broadcast android:name="android.intent.action.MEDIA_REMOVED" />
    <protected-broadcast android:name="android.intent.action.MEDIA_UNMOUNTED" />
    <protected-broadcast android:name="android.intent.action.MEDIA_CHECKING" />
    <protected-broadcast android:name="android.intent.action.MEDIA_NOFS" />
    <protected-broadcast android:name="android.intent.action.MEDIA_MOUNTED" />
    <protected-broadcast android:name="android.intent.action.MEDIA_SHARED" />
    <protected-broadcast android:name="android.intent.action.MEDIA_UNSHARED" />
    <protected-broadcast android:name="android.intent.action.MEDIA_BAD_REMOVAL" />
    <protected-broadcast android:name="android.intent.action.MEDIA_UNMOUNTABLE" />
    <protected-broadcast android:name="android.intent.action.MEDIA_EJECT" />

    <protected-broadcast android:name="android.net.conn.CONNECTIVITY_CHANGE" />
    <protected-broadcast android:name="android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE" />
    <protected-broadcast android:name="android.net.conn.DATA_ACTIVITY_CHANGE" />
    <protected-broadcast android:name="android.net.conn.BACKGROUND_DATA_SETTING_CHANGED" />
    <protected-broadcast android:name="android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED" />

    <protected-broadcast android:name="android.net.nsd.STATE_CHANGED" />

    <protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" />
    <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_ON_DETECTED" />
    <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED" />
    <protected-broadcast android:name="com.android.nfc_extras.action.AID_SELECTED" />

    <protected-broadcast android:name="android.nfc.action.TRANSACTION_DETECTED" />
    <protected-broadcast android:name="android.intent.action.CLEAR_DNS_CACHE" />
    <protected-broadcast android:name="android.intent.action.PROXY_CHANGE" />

    <protected-broadcast android:name="android.os.UpdateLock.UPDATE_LOCK_CHANGED" />

    <protected-broadcast android:name="android.intent.action.DREAMING_STARTED" />
    <protected-broadcast android:name="android.intent.action.DREAMING_STOPPED" />
    <protected-broadcast android:name="android.intent.action.ANY_DATA_STATE" />
    <protected-broadcast android:name="android.intent.action.DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN" />

    <protected-broadcast android:name="com.android.server.WifiManager.action.START_SCAN" />
    <protected-broadcast android:name="com.android.server.WifiManager.action.DELAYED_DRIVER_STOP" />
    <protected-broadcast android:name="android.net.wifi.WIFI_STATE_CHANGED" />
    <protected-broadcast android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />
    <protected-broadcast android:name="android.net.wifi.WIFI_SCAN_AVAILABLE" />
    <protected-broadcast android:name="android.net.wifi.SCAN_RESULTS" />
    <protected-broadcast android:name="android.net.wifi.RSSI_CHANGED" />
    <protected-broadcast android:name="android.net.wifi.STATE_CHANGE" />
    <protected-broadcast android:name="android.net.wifi.LINK_CONFIGURATION_CHANGED" />
    <protected-broadcast android:name="android.net.wifi.CONFIGURED_NETWORKS_CHANGE" />
    <protected-broadcast android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
    <protected-broadcast android:name="android.net.wifi.supplicant.STATE_CHANGE" />
    <protected-broadcast android:name="android.net.wifi.p2p.STATE_CHANGED" />
    <protected-broadcast android:name="android.net.wifi.p2p.DISCOVERY_STATE_CHANGE" />
    <protected-broadcast android:name="android.net.wifi.p2p.THIS_DEVICE_CHANGED" />
    <protected-broadcast android:name="android.net.wifi.p2p.PEERS_CHANGED" />
    <protected-broadcast android:name="android.net.wifi.p2p.CONNECTION_STATE_CHANGE" />
    <protected-broadcast android:name="android.net.wifi.p2p.PERSISTENT_GROUPS_CHANGED" />
    <protected-broadcast android:name="android.net.conn.TETHER_STATE_CHANGED" />
    <protected-broadcast android:name="android.net.conn.INET_CONDITION_ACTION" />
    <protected-broadcast android:name="android.net.conn.NETWORK_CONDITIONS_MEASURED" />
    <protected-broadcast
            android:name="android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED" />
    <protected-broadcast android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE" />
    <protected-broadcast android:name="android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE" />
    <protected-broadcast android:name="android.intent.action.AIRPLANE_MODE" />
    <protected-broadcast android:name="android.intent.action.ADVANCED_SETTINGS" />
    <protected-broadcast android:name="android.intent.action.BUGREPORT_FINISHED" />

    <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_START" />
    <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_END" />

    <protected-broadcast android:name="android.intent.action.HDMI_PLUGGED" />

    <protected-broadcast android:name="android.intent.action.PHONE_STATE" />

    <protected-broadcast android:name="android.location.GPS_ENABLED_CHANGE" />
    <protected-broadcast android:name="android.location.PROVIDERS_CHANGED" />
    <protected-broadcast android:name="android.location.MODE_CHANGED" />
    <protected-broadcast android:name="android.location.GPS_FIX_CHANGE" />
    <protected-broadcast android:name="android.net.proxy.PAC_REFRESH" />

    <protected-broadcast
        android:name="com.android.server.connectivityservice.CONNECTED_TO_PROVISIONING_NETWORK_ACTION" />

Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.HEADSET_PLUG

时间: 2024-10-23 09:25:43

Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.HEADSET_PLUG的相关文章

关于 Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED from 错误原因

当在Android4.4上进行图片的扫描功能开发时一般会使用:sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory()+ picPath)));的广播 但因为Android4.4中限制了系统应用才有权限使用广播通知系统扫描SD卡,所以会报上面的错误. 解决方法:使用MediaScannerConnection执行

Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED

当在Android4.4上进行图片的扫描功能开发时一般会使用:sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory()+ picPath)));的广播 因为Android4.4中限制了系统应用才有权限使用广播通知系统扫描SD卡,所以会抛题目异常. 解决方法:使用MediaScannerConnection执行具体

ContentProvider异常:Caused by: java.lang.SecurityException: Permission Denial

在使用ContentProvider时抛出异常:Caused by: java.lang.SecurityException: Permission Denial 原因:在Provider的 Manifest文件中 对provider的属性描述时 没有 加入 属性 android:exported="true" android:exported属性非常重要.这个属性用于指示该服务是否能够被其他应用程序组件调用或跟它交互.如果设置为true,则能够被调用或交互,否则不能.

Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://...

在as中创建cordova中添加从相册选取照片的插件 $cordovaImagePicker 就是以上这货,调用后直接程序就崩溃了,并报错 Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://... 添加权限 <uses-permission android:name="android.permis

访问不了自己创建的Contentprovider,报错:java.lang.SecurityException: Permission Denial

情景:1.A,B两个程序,A程序提供ContentProvider:B程序访问A程序的ContendProvider 2.在A程序中已经添加权限: <provider android:name=".provider.UserProvider" android:authorities="com.example.listview.userprovider"></provider> 问题:A程序部署后,再运行B程序,报错: 03-11 21:48:

java.lang.SecurityException: Permission Denial: opening provider

在测试调用外部提供的ContentProvider时候报一下错误: java.lang.SecurityException: Permission Denial: opening provider com.example.onehw.BookProvider from ProcessRecord{b2f1b230 8449:com.example.adtest/u0a53} (pid=8449, uid=10053) that is not exported from uid 10052 at

【Android】java.lang.SecurityException: Permission Denial: starting Intent 应用启动失败异常

异常提示 在Eclipse和Android Studio同时使用的时候,我遇到过这样一个异常,具体错误提示如下: ava.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.xxx.xxx/.activity.SplashActivity }

Permission Denial: not allowed to send broadcast in android

因为最近项目里Intent用到了广播"android.intent.action.MEDIA_MOUNTED", 结果被提示权限不足, 查了下原因, 是因为从4.4开始, 官方开始限制这个广播的使用, 加上了 protected权限, 只能系统内部使用. 如下: <protected-broadcast android:name="android.intent.action.MEDIA_MOUNTED" /> 想想也在情理之中, 否则就是因为需要加载一张

spring Caused by: java.lang.SecurityException: Prohibited package name: java.time

六月 09, 2014 1:05:02 下午 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.4.8. 六月 09, 2014 1:05:03 下午 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities