简体   繁体   English

java.lang.SecurityException:BLUETOOTH权限崩溃。 (仅限三星设备)

[英]java.lang.SecurityException: BLUETOOTH permission crash. (Samsung devices only)

I'm getting the following crash, but this only occurs on some Samsung devices (not all, we develop/test on Samsung devices) 我遇到了以下崩溃,但这只发生在一些三星设备上(并非所有,我们在三星设备上开发/测试)

Crash log: 崩溃日志:

java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10025 nor current process has android.permission.BLUETOOTH.
   at android.os.Parcel.readException(Parcel.java:1540)
   at android.os.Parcel.readException(Parcel.java:1493)
   at android.bluetooth.IBluetooth$Stub$Proxy.isEnabled(IBluetooth.java:1156)
   at android.bluetooth.BluetoothAdapter.isEnabled(BluetoothAdapter.java:697)
   at org.altbeacon.beacon.service.scanner.CycledLeScanner.finishScanCycle(CycledLeScanner.java:245)
   at org.altbeacon.beacon.service.scanner.CycledLeScanner.scheduleScanCycleStop(CycledLeScanner.java:234)
   at org.altbeacon.beacon.service.scanner.CycledLeScanner$1.run(CycledLeScanner.java:230)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:145)
   at android.app.ActivityThread.main(ActivityThread.java:5972)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Here's my AndroidManifest: 这是我的AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.myapp" >


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<!--
     The following two permissions are not required to use Google Maps Android API v2,
     but are recommended. We also require them for location updates.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<permission
    android:name=".permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name=".permission.C2D_MESSAGE" />

<application
    android:name=".myapp"
    android:allowBackup="true"
    android:icon="@drawable/appicon"
    android:label="@string/app_name"
    android:logo="@drawable/action_bar_pinwheel_back"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".activities.VerifyPinActivity"
        android:label="@string/title_activity_verify_pin"
        android:screenOrientation="portrait"
        android:theme="@style/NoActionBarDark"
        android:windowSoftInputMode="stateVisible|adjustPan" >
    </activity>
    ...(more activities here removed)
</application>
</manifest>

I really have no idea why it only occurs on a few devices; 我真的不知道为什么它只发生在一些设备上; my initial guess is it has something to do with Samsung KNOX, and the (few) users that are crashing are KNOX users with a phone policy to disable bluetooth. 我最初的猜测是它与三星KNOX有关,而且(少数)崩溃的用户是具有电话政策的KNOX用户,以禁用蓝牙。

Has anyone else run into this? 有没有其他人遇到这个? Or does anyone have any idea what this might be? 或者有人知道这可能是什么?

If you are sure the users met this problems only on Samsung KNOX,the following answer maybe will help you. 如果您确定用户仅在Samsung KNOX上遇到此问题,以下答案可能会对您有所帮助。

Thinking step by step is the way to solve your problem. 一步一步思考是解决问题的方法。

1.This only occurs on some Samsung devices.

So, it has nothing to do with your code,also the permission.There is something wrong with the Samsung devices. 因此,它与您的代码无关,也与许可无关。三星设备有问题。

2.Check the crash log:  
java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10025 nor current process has android.permission.BLUETOOTH.

According to the experience,if you have met the log like "Neither user **** nor current process has *** permission.",this means that your app doesn't have the permission to do something in the system.This occurs often on that you do something need the system level permission. 根据经验,如果您遇到了“既不是用户****也不是当前进程有***权限”这样的日志,这意味着您的应用程序无权在系统中执行某些操作。这种情况会发生通常,你做某事需要系统级权限。

If you are installed as system level app together with customized Android ROM,or you signed your app with the platform.x509.pem and platform.pk8 file of the customized Android ROM,and then you can have the permission.

Now check what is Samsung KNOX: 现在查看Samsung KNOX是什么:

Samsung Knox (stylized Samsung KNOX) is an enterprise mobile security solution. 三星诺克斯(程式化的三星KNOX)是一款企业移动安全解决方案。

Bluetooth is one kind of data transmission way to the other's device.This will cause the security problem. 蓝牙是另一种设备的一种数据传输方式。这会引起安全问题。

Check the offical website: 查看官方网站:
https://www.samsungknox.com https://www.samsungknox.com

Search the key words 'Bluetooth',and we found this: https://www.samsungknox.com/en/faq/are-bluetooth-bluetooth-low-energy-and-nfc-available-inside-knox-container 搜索关键词'蓝牙',我们发现: https//www.samsungknox.com/en/faq/are-bluetooth-bluetooth-low-energy-and-nfc-available-inside-knox-container

KNOX 2.4+ — Bluetooth, Bluetooth Low Energy (GATT), and NFC are supported inside the KNOX container. KNOX 2.4+ - KNOX容器内部支持蓝牙,低功耗蓝牙(GATT)和NFC。

KNOX 2.3 or below — Bluetooth, Bluetooth GATT, and NFC aren't supported inside the KNOX container. KNOX 2.3或更低版本 - KNOX容器内不支持蓝牙,蓝牙GATT和NFC。 If the device is connected to a peripheral (eg headphones) in the personal space, Bluetooth will remain connected, even if the user enters the KNOX container. 如果设备连接到个人空间中的外围设备(例如耳机),即使用户进入KNOX容器,蓝牙也将保持连接状态。 Apps inside the KNOX container can't initiate a Bluetooth connection. KNOX容器内的应用程序无法启动蓝牙连接。

1.If your users are using KNOX 2.3 or below ,and they can update their OS of device to KNOX 2.4+ .tell your users who use Samsung KNOX update their OS of device. 1.如果您的用户使用KNOX 2.3或更低版本 ,他们可以将他们的设备操作系统更新为KNOX 2.4+。使用Samsung KNOX的用户更新他们的设备操作系统。

2.If your users are using KNOX 2.3 or below ,and they can't update their OS of device to KNOX 2.4+ .your app will not work under this situation,the problem is not the problem,what you can do is only tell uses that:the OS of your device doesn't support Bluetooth,so it's not working. 2.如果您的用户使用KNOX 2.3或更低版本 ,他们无法将他们的设备操作系统更新为KNOX 2.4+。您的应用程序在这种情况下无法正常工作,问题不是问题,您只能告诉他们使用:你的设备的操作系统不支持蓝牙,所以它不起作用。

3.If the above will not help you, you can contact with Samsung KNOX Official 3.如果上述情况对您没有帮助,您可以联系三星KNOX官方

Another tip: 另一个提示:
To improve your user experience of your app, you need to prevent your app to be crashed. 要改善应用的用户体验,您需要阻止应用崩溃。
Crashed is the worst user experience. 崩溃是最糟糕的用户体验。
If you can not solve the problem,you can do this: 如果无法解决问题,可以这样做:

 try{
     You code related with Bluetooth.
    }catch (Exception e)
    {
    }

Remember:The offical always helps you to solve the problems better! 记住:官方总能帮助您更好地解决问题!


You can look here . 你可以看看这里 I'd guess this is your problem. 我猜这是你的问题。

Are Bluetooth, Bluetooth Low Energy, and NFC available inside the KNOX container? KNOX容器内是否有蓝牙,低功耗蓝牙和NFC?

KNOX 2.4+ — Bluetooth, Bluetooth Low Energy (GATT), and NFC are supported inside the KNOX container. KNOX 2.4+ - KNOX容器内部支持蓝牙,低功耗蓝牙(GATT)和NFC。

KNOX 2.3 or below — Bluetooth, Bluetooth GATT, and NFC aren't supported inside the KNOX container. KNOX 2.3或更低版本 - KNOX容器内不支持蓝牙,蓝牙GATT和NFC。 If the device is connected to a peripheral (eg headphones) in the personal space, Bluetooth will remain connected, even if the user enters the KNOX container. 如果设备连接到个人空间中的外围设备(例如耳机),即使用户进入KNOX容器,蓝牙也将保持连接状态。 Apps inside the KNOX container can't initiate a Bluetooth connection. KNOX容器内的应用程序无法启动蓝牙连接。

I never had any hands-on experience with this, but I hope this helps. 我从未有过这方面的实践经验,但我希望这会有所帮助。

尝试将以下内容添加到您的清单中

<uses-feature android:name="android.hardware.bluetooth" android:required="true" />

From SDK 23 onward you need to check the permission for bluetooth in case required. 从SDK 23开始,您需要在需要时检查蓝牙权限。

   if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
         if (mContext.checkSelfPermission(Manifest.permission.BLUETOOTH) == PackageManager.PERMISSION_GRANTED) {
//TODO - Do the work
    }
  }

From KNOX Premium v1.1 onwards, Samsung no longer needs to sign third-party app (APK) files so that they can run inside KNOX containers. 从KNOX Premium v​​1.1开始,三星不再需要签署第三方应用(APK)文件,以便它们可以在KNOX容器内运行。 Instead, the appropriate permissions are granted at runtime, after an app activates its ELM and KLM licenses successfully. 相反,在应用程序成功激活其ELM和KLM许可证后,将在运行时授予相应的权限。 for more info see this 有关更多信息,请参阅

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.SecurityException:权限被拒绝 - java.lang.SecurityException: Permission denied Java.lang.SecurityException:Android中的安全权限? - Java.lang.SecurityException:SECURE PERMISSION in android? java.lang.SecurityException:权限拒绝错误 - java.lang.SecurityException: Permission Denial ERROR java.lang.SecurityException:UID 10457 / PID 24525 缺少权限 android.permission.BLUETOOTH - java.lang.SecurityException: UID 10457 / PID 24525 lacks permission android.permission.BLUETOOTH java.lang.SecurityException:需要 android.permission.BLUETOOTH_CONNECT 权限以获得 AttributionSource - java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource 在 android studio java.lang.SecurityException 中查找错误:需要 android.permission.BLUETOOTH_CONNECT - Finding Error in android studio java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT Android GoogleMaps在某些设备上不工作,显示java.lang.SecurityException:需要INSTALL_LOCATION_PROVIDER权限 - Android GoogleMaps not working on some devices shows java.lang.SecurityException: need INSTALL_LOCATION_PROVIDER permission java.lang.SecurityException:需要 BLUETOOTH 权限:用户 10065 和当前进程都没有 android.permission.BLUETOOTH - java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10065 nor current process has android.permission.BLUETOOTH java.lang.SecurityException: - java.lang.SecurityException: Java.lang.securityException - Java.lang.securityException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM