public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DBG) log("Receive intent action = " + action); if (action.equals(BluetoothDunService.ACCESS_RESPONSE_ACTION)) { int result = intent.getIntExtra( BluetoothDunService.EXTRA_ACCESS_RESULT, BluetoothDunService.RESULT_USER_REJECT); if (result == BluetoothDunService.RESULT_USER_ACCEPT) { dunConnectRspNative(mDunConnPath, true); } else { dunConnectRspNative(mDunConnPath, false); // dunSetState(BluetoothDun.STATE_DISCONNECTED); } } else if (action.equals(BluetoothDunService.RESEND_NOTIFICATION_ACTION)) { BluetoothDevice device = mAdapter.getRemoteDevice(mDunConnPath); createDunAuthNotification(context, device, true); } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { ConnectivityManager connmgr; connmgr = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo MobileInfo = connmgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); NetworkInfo WifiInfo = connmgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo.DetailedState MobileState = NetworkInfo.DetailedState.IDLE; NetworkInfo.DetailedState WifiState = NetworkInfo.DetailedState.IDLE; if (MobileInfo != null) MobileState = MobileInfo.getDetailedState(); if (WifiInfo != null) WifiState = WifiInfo.getDetailedState(); if (DBG) log("NetworkInfo broadcast, MobileState=" + MobileState + ",WifiState=" + WifiState); /* if get network service via wifi, get interface name by "wifi.interface" system property key * String interfaceName = SystemProperties.get("wifi.interface", "tiwlan0"); * log("wifi interface name=" + interfaceName); */ if (MobileState == NetworkInfo.DetailedState.IDLE && WifiState == NetworkInfo.DetailedState.IDLE) { if (mDunState == BluetoothDun.STATE_CONNECTED) { dunDisconnectNative(); } } } else if (action.equals(BluetoothTethering.BLUETOOTH_INTERFACE_ADDED)) { if (DBG) log("receiver BluetoothTethering.BLUETOOTH_INTERFACE_ADDED"); if (mDunState == BluetoothDun.STATE_CONNECTED) { String iface = intent.getStringExtra(BluetoothTethering.BLUETOOTH_INTERFACE_NAME); ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm.tether(iface) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { Log.e(TAG, "Error tethering " + iface); } } else { if (DBG) log("DUN does not connected"); } } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR) == BluetoothAdapter.STATE_TURNING_OFF) { clearService(); } } }