跟上前面的log:
11-13 05:06:35.081: V/BluetoothEventManager(8739): Received android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:35.081: V/BluetoothDiscoveryReceiver(8739): Received: android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:35.086: I/BluetoothConnect(20856): yong: public ConnectThread(): tmp=android.bluetooth.BluetoothSocket@42a6e908
11-13 05:06:35.086: D/BluetoothConnect(20856): yong: state->2
11-13 05:06:35.091: I/BluetoothConnect(20856): yong: BEGIN mConnectThread 
11-13 05:06:35.096: D/BluetoothUtils(20856): isSocketAllowedBySecurityPolicy start : device null
11-13 05:06:35.096: W/BluetoothAdapter(20856): getBluetoothService() called with no BluetoothManagerCallback
11-13 05:06:35.096: V/BluetoothEventManager(8739): Received android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:35.101: V/BluetoothDiscoveryReceiver(8739): Received: android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:35.101: D/BTIF_SOCK(25644): service_uuid: 00001101-0000-1000-8000-00805f9b34fb
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_create: id EnforceMasterRole :: key KEY_BDADDR, value 94:63:d1:f7:db:7e
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_add_key: key KEY_LMP_MFCT, value 10
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_add_key: key KEY_LMP_VER, value 6:7558
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_add_key: key KEY_DIR_ALL, value 1
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_execute: result 1
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_create: id DisablePwlCtrReq :: key KEY_BDADDR, value 94:63:d1:f7:db:7e
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_add_key: key KEY_LMP_MFCT, value 10
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_add_key: key KEY_LMP_VER, value 6:7558
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_add_key: key KEY_DIR_ALL, value *
11-13 05:06:35.101: D/IOP_DB_BT(25644): db_query_execute: result 1
11-13 05:06:35.101: D/BluetoothSocket(20856): connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[62]}
11-13 05:06:35.251: D/SSRMv2:Monitor(2997): SIOP:: AP = 320, Prev AP = 280, Duration = 10003, PST = 284
11-13 05:06:35.251: D/SSRMv2:AmoledAdjustTimer(2997): prevTemp = 268, currTemp = 269, prevStep = 4, currStep = 4
11-13 05:06:37.181: D/PackageManager(2997): [MSG] MCS_UNBIND
11-13 05:06:37.181: I/PackageManager(2997): calling disconnectService()
11-13 05:06:37.181: D/PackageManager(2997): Trying to unbind to DefaultContainerService
11-13 05:06:37.641: D/InputReader(2997): Input event: value=1 when=92650651394000
11-13 05:06:37.641: I/InputReader(2997): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.6003 ] when=92650651646000
11-13 05:06:37.641: I/InputDispatcher(2997): Delivering touch to: action: 0x4
11-13 05:06:37.641: I/InputDispatcher(2997): Delivering touch to: action: 0x0
11-13 05:06:37.756: D/InputReader(2997): Input event: value=0 when=92650749905000
11-13 05:06:37.756: I/InputReader(2997): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=92650749908000
11-13 05:06:37.756: I/InputDispatcher(2997): Delivering touch to: action: 0x1
11-13 05:06:37.821: W/ActivityManager(2997): Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
11-13 05:06:37.826: E/DatabaseUtils(2997): Writing exception to parcel
11-13 05:06:37.826: E/DatabaseUtils(2997): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
11-13 05:06:37.826: E/DatabaseUtils(2997):  at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:14615)
11-13 05:06:37.826: E/DatabaseUtils(2997):  at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2258)
11-13 05:06:37.826: E/DatabaseUtils(2997):  at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:663)
11-13 05:06:37.826: E/DatabaseUtils(2997):  at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
11-13 05:06:37.826: E/DatabaseUtils(2997):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
11-13 05:06:37.826: E/DatabaseUtils(2997):  at android.os.Binder.execTransact(Binder.java:404)
11-13 05:06:37.826: E/DatabaseUtils(2997):  at dalvik.system.NativeStart.run(Native Method)
11-13 05:06:37.826: D/MainActivity(20856): my_address=94:63:D1:F7:DB:7E
11-13 05:06:37.826: D/MainActivity(20856): my_Bluetoothdevice device=94:63:D1:F7:DB:7E
11-13 05:06:37.826: D/BluetoothConnect(20856): yong: connect to 94:63:D1:F7:DB:7E
11-13 05:06:37.826: I/BluetoothConnect(20856): yong: public ConnectThread(): device=94:63:D1:F7:DB:7E
11-13 05:06:37.826: V/BluetoothEventManager(8739): Received android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:37.831: V/BluetoothDiscoveryReceiver(8739): Received: android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:37.836: I/BluetoothConnect(20856): yong: public ConnectThread(): tmp=android.bluetooth.BluetoothSocket@42a72928
11-13 05:06:37.836: D/BluetoothConnect(20856): yong: state->2
11-13 05:06:37.836: I/BluetoothConnect(20856): yong: BEGIN mConnectThread 
11-13 05:06:37.836: D/BluetoothUtils(20856): isSocketAllowedBySecurityPolicy start : device null
11-13 05:06:37.836: W/BluetoothAdapter(20856): getBluetoothService() called with no BluetoothManagerCallback
11-13 05:06:37.836: V/BluetoothEventManager(8739): Received android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:37.836: D/BTIF_SOCK(25644): service_uuid: 00001101-0000-1000-8000-00805f9b34fb
11-13 05:06:37.841: D/BluetoothSocket(20856): connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[63]}
11-13 05:06:37.846: V/BluetoothDiscoveryReceiver(8739): Received: android.bluetooth.adapter.action.DISCOVERY_FINISHED
11-13 05:06:38.591: D/IOP_DB_BT(25644): db_query_create: id EnforceMasterRole :: key KEY_BDADDR, value 94:63:d1:f7:db:7e
11-13 05:06:38.591: D/IOP_DB_BT(25644): db_query_add_key: key KEY_LMP_MFCT, value 10
11-13 05:06:38.591: D/IOP_DB_BT(25644): db_query_add_key: key KEY_LMP_VER, value 6:7558
11-13 05:06:38.591: D/IOP_DB_BT(25644): db_query_add_key: key KEY_DIR_ALL, value *
11-13 05:06:38.596: D/IOP_DB_BT(25644): db_query_execute: result 1
11-13 05:06:38.596: D/(25644): remote version info [94:63:d1:f7:db:7e]: 6, a, 1d86
11-13 05:06:38.606: D/KeyguardViewMediator(3226): Received android.bluetooth.device.action.ACL_CONNECTED
11-13 05:06:38.606: D/ContainerEventsRelayManager(3505): <<< Intent action is >>> : android.bluetooth.device.action.ACL_CONNECTED
11-13 05:06:38.606: D/ContainerEventsRelayManager(3505): <<< Intent data is   >>> : null
11-13 05:06:38.611: D/ECS_EnterpriseContainerService(2997): getContainers   --  Called + uid1000
11-13 05:06:38.611: D/ECS_EnterpriseContainerService(2997): getContainers   --  Called passing security
11-13 05:06:38.611: D/ECS_EnterpriseContainerCacheData(2997): Container cache getContainers 
11-13 05:06:38.611: D/ECS_EnterpriseContainerCacheData(2997): Container cache getContainers not null
11-13 05:06:38.621: D/KeyguardViewMediator(3226): isGear1: device is not B1!
11-13 05:06:38.621: V/BluetoothEventManager(8739): Received android.bluetooth.device.action.NAME_CHANGED
11-13 05:06:38.631: D/BluetoothDevicePreference(8739): Is my device connected::false
11-13 05:06:38.631: I/BluetoothDevicePreference(8739): summaryResId else part
11-13 05:06:38.711: D/BluetoothNotiBroadcastReceiver(8739): onReceive
11-13 05:06:38.711: E/bt-btif(25644): DISCOVERY_COMP_EVT slot id:117, failed to find channle,                                       status:1, scn:0
11-13 05:06:38.711: I/BluetoothConnect(20856): yong: BEGIN mConnectThread :IOException e  //koo

解决方案 »

  1.   

    第一:
    Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0
    引用自 http://www.tuicool.com/articles/Q7RjAr
    log中直接给出提示,需要加一个权限INTERACT_ACROSS_USERS_FULL,这个权限时API17新引入的,目的在于允许不同用户的应用之间可以产生交互。可是加上去之后发现,还不是无法调起浏览器,而且log依然提示需要权限INTERACT_ACROSS_USERS_FULL,很是奇怪,于是继续分析。首先说明一下Linux中的pid和uid,以及android扩展的userSerialNumber。pid是Process的标识,用于系统对进程的控制,从API层面看就是用于Process.killProcess()和Process.sendSignal();uid在Linux系统中是用来标识用户的,而在android将uid视为app的标识id,用于"sandbox"安全模型,即用于app权限控制;而对于API17引入的多用户支持(目前只支持平板),uid已经被占用,只好新引入userSerialNumber来标识用户。回到刚才的问题,log中告知startActivity时运行用户标识为-2,而调用却是由用户标识0发起,导致拒绝执行。用这句话搜索,发现在Google开发者网站中有相关的issue,链接如下: https://code.google.com/p/android/issues/detail?id=39801 (打不开可以把https改为http)。结合官方的回答,问题原因如下:由于被卸载,C端进程监听到目录被删除,立即执行am命令,此时将会默认以USER_CURRENT的身份执行,由于API17中ActivityManagerService.handleIncomingUser()会校验userSerialNumber,发现用户标识不匹配,导致权限校验失败——这也说明了权限的影响范围仅限于Java端的进程,对于fork()出来的C端进程来说,并不继承父进程在Android中声明的权限。解决方案:增加处理分支,若API>=17,将userSerialNumber传递给C端进程,然后在am命令中带上参数--user userSerialNumber即可。问题2:
    八成是控件用法的有问题。最好多贴一下 newListView  相关的代码。
      

  2.   


    to gqjjqg 对于 问题一 ,提到的“ userSerialNumber传递给C端进程,然后在am命令中带上参数--user userSerialNumber即可。
     ”
    具体在哪个位置改呢?  麻烦详细说下对于问题 2:文件  MainActivity.java protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
            setTitle(R.string.Bluetooth_Controller);
            setContentView(R.layout.test_dimen);
            String noDevice=null;
            ScanButton = (Button)findViewById(R.id.Button01);
            ControlButton = (Button)findViewById(R.id.Button02);
            
            
            Resources r = getResources();
            float btn_h = r.getDimension(R.dimen.btn_height);
            float btn_w = r.getDimension(R.dimen.btn_weight);
            ScanButton.setHeight((int)btn_h);
            ScanButton.setWidth((int)btn_w);
            ControlButton.setHeight((int)btn_h);
            ControlButton.setWidth((int)btn_w);
            
            mPairedDevices = new ArrayAdapter<String>(this,R.layout.device_name);
            mNewDevices = new ArrayAdapter<String>(this,R.layout.device_name);
            
            ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
            pairedListView.setAdapter(mPairedDevices);
          //  pairedListView.setOnItemClickListener(mDeviceClickListener);
            
            ListView newListView = (ListView) findViewById(R.id.new_devices);
            newListView.setAdapter(mNewDevices);
            newListView.setOnItemClickListener(mDeviceClickListener);
            
            IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
            this.registerReceiver(mReceiver, filter);
            
            mBluetoothConnection = new BluetoothConnection(this,mHandler);
            
            mBluetoothDevice = new MBluetoothDevice();
            filter = new IntentFilter(mBluetoothDevice.Action_Bluetooth_Discovery_Finish);
            this.registerReceiver(mReceiver,filter);
         
            ScanButton.setOnClickListener(new OnClickListener() {
             public void onClick(View v){
              doDiscovery();
               }
            });        Set<BluetoothDevice> pairedDevices = mBluetoothDevice.getPairdDevices();
            
            Log.d(TAG,"yong:size="+pairedDevices.size());
            if( pairedDevices.size() >0) {
             for(BluetoothDevice device : pairedDevices) {
             mPairedDevices.add(device.getName() + "\n" + device.getAddress());
             }
            } else {
             noDevice = getResources().getText(R.string.none_paired).toString();
             mPairedDevices.add(noDevice);
            }
           pairedListView.setAdapter(mPairedDevices);
          // newDevicesListView.setAdapter(mNewDevices);
            
        }
     private OnItemClickListener  mDeviceClickListener = new OnItemClickListener() {
         public void onItemClick(AdapterView<?>av,View v,int arg2,long arg3) {
         mBluetoothDevice.discoveryBluetooth_Cancel();
        
         String info = ((TextView)v).getText().toString();
         String address =info.substring(info.length()-17);
        
         Log.d(TAG,"my_address="+address);
        
         BluetoothDevice device = mBluetoothDevice
         .getRemoteBluetoothDevice(address);
         Log.d(TAG,"my_Bluetoothdevice device="+device);
        
         mBluetoothConnection.connect(device);
        
        
         }
        
        };
      

  3.   

    请问 newListView  相关的代码 有问题吗?
      

  4.   

    tmp = device.createInsecureRfcommSocketToServiceRecord(uuid);目测这个uuid 有问题吧。
    我没搞过蓝牙相关的东西,不了具体怎么改, 楼主参考之前的链接看看人家怎么处理,再改呗。问题二,我去查了一下android 4.4 和5.L源码,貌似都没有 unregisterIRListener 这个LOG相关的代码。
    要是源码改过的话,具体代表啥意思就不知道了。
    看样子这个仅仅只是输出debug的信息而已,对APP没影响吧。
    另外你的代码,我没看出有啥问题。