Commit Graph

301 Commits

Author SHA1 Message Date
Dianne Hackborn
d752c3b3e6 Merge "Implement issue #3426299: Introduce application "stopped" state" 2011-02-25 16:15:27 -08:00
Dianne Hackborn
e7f972122d Implement issue #3426299: Introduce application "stopped" state
The package manager now keeps track of whether an application is
stopped.  There are new intent flags to control whether intent
filters in a stopped application will match the intent.  This is
currently used in one place, sending broadcasts, so that stopped
apps can not be launched due to background processes.

The package manager during first init makes sure no applications
are in the stopped state.  When new applications are installed,
that begin in the stopped state.  When the activity manager is
launching a component of an application, it ensures the application
is taken out of the stopped state.

The "force stop" button in manage applications will now put an
application back in to the stopped state; it can't go back out
of the stopped state until one of its components is launched by
the activity manager.

There will probably be a few more places where we need to filter
stopped applications out of intent matches, but doing this for
broadcast is a very big first step.

This also introduces a new broadcast that is sent to an application
after it is replaced with a new .apk.  But only if the app is not
in the stopped state.  This makes it a lot easier for developers to
implement code to get their application back in proper running shape
after an upgrade.

Finally another new broadcast is added that is sent to a package's
installer at the first time it is launched.  This allows the installer
to tell the package about it being installed only when it is first
actually used.

Change-Id: I589c53ff0e0ece868fe734ace4439c0d202dca2d
2011-02-25 14:46:27 -08:00
Jaikumar Ganesh
cc2c06656c Unset device trust state before unpairing.
a) Device is trusted.
b) Device is unpaired.
c) We need to set the trusted value before unpairing.

Else on the next pairing, the device will be trusted automatically
and we will not show the PBAP authentication dialog.

Change-Id: I8d7c962688885885d37be341e5494069294eb392
2011-02-25 14:16:27 -08:00
Jake Hamby
9a62c9cd65 Refactor android.server.BluetoothService classes.
Several cleanups to BluetoothService:
- Move BluetoothService.BondState inner class to top level.
- Extract adapter and remote device properties cache management
  logic into two new classes: BluetoothAdapterProperties and
  BluetoothDeviceProperties.
- Add getter methods for other classes in the package to access
  the new properties cache objects for multi-part operations.
- Inline log() method in BluetoothService and selected the
  appropriate Log method (Log.d, Log.w, Log.e) for each message.
- Refactor dump() method into smaller sized pieces.
- Clean up logic of updateCountersAndCheckForConnectionStateChange()
  method for better readability.
- Change sendConnectionStateChange() to return instead of sending
  an intent if the current or previous state values are invalid.
  Previously the code sent an intent with -1 for the invalid state.
- Added Javadoc comments to document the methods that are called from
  native Bluez code.
- Fixed some typos and code style issues.

Original Change by: Jake Hamby
Modified by: Jaikumar Ganesh

Change-Id: I76ebac00ecd29566dcb2d1ad3e7a486b7530ce24
2011-02-24 16:26:20 -08:00
Jaikumar Ganesh
74ef119945 Make BluetoothPan inherit from BluetoothProfile.
Change-Id: Ibd3e24e391be93ebe2cf975bd075efb68e10c1ff
2011-02-23 15:49:15 -08:00
Jaikumar Ganesh
4ab0e7746f Make BluetoothInputDevice inherit from BluetoothProfile.
This makes it in sync with BluetoothHeadset and BluetoothA2dp profiles.

Change-Id: I3ddb1d18b04aacb173b7bc376bca21c277a6afe4
2011-02-22 10:42:26 -08:00
Jaikumar Ganesh
47898dd398 Make profile handler classes package and final.
Also merge in the netmask removal fix.

Change-Id: I7a5c806d442a704f9cb21204a1d1307461f801c7
2011-02-14 15:40:54 -08:00
Jaikumar Ganesh
9efb1343a0 Fix ANR in Settings and Phone app.
When we have a lot of devices paired and try to enable bluetooth,
loadBondState will take a some time. During this all UUIDs would
have been registered and we would send out the Bluetooth On intent.
When Settings apps or phone app gets the Bluetooth On intent, they
try to initialize state. However, the enable Thread in Bluetooth Service
is still initializing internal state in loadBondState leading to
ANRs and deadlocks. So register SDP records as the last step of enable Thread.

Change-Id: Iaa0a773e31b9d269f4c56c4f975a0e2973e02d6e
2011-02-14 15:02:42 -08:00
Jaikumar Ganesh
30b8cbe059 Refactor Input profile operations from Bluetooth Service.
Change-Id: I818b0c7056fd43c7303c95150d8001dfc434e5e7
2011-02-14 15:02:42 -08:00
Jaikumar Ganesh
a8571f15c3 Remove Bluetooth Pan operations from Bluetooth Service.
Change-Id: I4dfe14ce04ec357a952b577d452da2257165fc6f
2011-02-14 15:02:42 -08:00
Jaikumar Ganesh
a44a1e77ef Distinguish between NAP and PAN role disconnections
Distinguish between NAP and PANU disconnect in BT tethering
and call appropriate functions. We were never disconnecting
NAP role devices.

ToDo: BluetoothService needs to be refactored, its become too big
1) BluetoothAdapter and BluetoothDevice properties need to be moved to separate
classes.
2) BluetoothPanProfile and BluetoothInputDeviceProfile which are handled
by BluetoothService need to be moved to a separate file.
3) Integrate PAN to the profile state machine.

Change-Id: I32a8d274f38c78931434bd9738c8f6570ba89fcf
2011-02-14 15:00:25 -08:00
Robert Greenwalt
b979f79158 Remove more use of netmask
bug:2542681
Change-Id: Ifd75672739ee8262d4df22afd8173e4f3f67260d
2011-02-14 14:32:33 -08:00
Jaikumar Ganesh
8f08ae9661 Reject incoming tethering connections if Tethering option is not enabled.
Change-Id: I40aa08ad5a3f3a2169551bbe35682910daced098
2011-02-07 16:45:23 -08:00
Jaikumar Ganesh
b3c4efc22d Merge "Wait till SDP records are registered before sending intent." 2011-02-03 17:27:10 -08:00
Jaikumar Ganesh
50b40cec9c Wait till SDP records are registered before sending intent.
Wait till all SDP records are registered, before sending STATE_ON intent.
This would fix crashes in Settings app when the profile manager
is not registered.
Problem:
  We were sending Bluetooth State on intent before we got the uuid state
  change intent from Bluez, which is asynchronous.
  Hence when the Settings app queries for the profiles
  to decide if headset profile was registered it would get false and
  the profile manager would be null causing crashes.
  This was not 100 % reproducible, well because it was a race condition.

Change-Id: I791eb63dfbc78aba4c06fd8db933069cb5fde00d
2011-02-03 17:02:06 -08:00
Robert Greenwalt
f8d40f0d55 Merge "Bind addr and prefixLength together in LinkAddress" 2011-02-03 13:17:48 -08:00
Jaikumar Ganesh
fbb238db71 Remove discoverable timeout handler.
This is leftover code from bluez3 days. We get a property change
in Bluez4 and an intent is sent.

Change-Id: Iba8821ef73edf08add590ef9d11074b59fec2d50
2011-02-01 14:15:12 -08:00
Robert Greenwalt
ed12640932 Bind addr and prefixLength together in LinkAddress
bug:2542681
Change-Id: I90200446216d78c676498144946832afe75efdb8
2011-01-28 15:34:55 -08:00
Jaikumar Ganesh
6312927254 am e97c0188: am 55271a79: Merge "Disable PBAP for no voice capability" into honeycomb
* commit 'e97c01888fcc94453041eb6adc575598d744b580':
  Disable PBAP for no voice capability
2011-01-26 19:11:20 -08:00
Jaikumar Ganesh
67a8b8eaa1 Disable PBAP for no voice capability
PBAP is contact transfer to cars and headsets.
This is closely tied to handsfree profile.
Without calling functionality it was of practically no use.
It will just confuse users when they see a "Dial" button
on their car systems.

Bug: 3395362
Change-Id: I4e4597f0e4b371f69ed7af95d73893554e3fb8ac
2011-01-26 14:33:20 -08:00
Jaikumar Ganesh
55b6b862c8 Do Not Merge. Don't connect to non keyboard HID devices.
Bug: 3385950
Change-Id: I2cfb17467c3d2fd383747111cd990d39f10f5136
2011-01-25 17:38:11 -08:00
Jaikumar Ganesh
fbe807d064 Make connection / disconnect failure more robust.
Add error codes so that the states can be tracked better.

Change-Id: Ic07a5d34589134b68dedeb4803ccb523aa01b567
2011-01-19 14:06:29 -08:00
Jaikumar Ganesh
d1287f5ef0 Fix bug in handling connect/disconnect multiple devices.
Multiple HID devices can be connected. There is no pointing
maintaining the global state. Check individual device state.

Bug: 3350904

Change-Id: I03d9a6015e39e4f9d7f68cc8bbdb19731129b4e6
2011-01-13 15:59:27 -08:00
Staffan Lindvall
81f8e3c85f Phone crash when old callback func is woken up when enabling BT.
When the remote Jerry device is powered down the BT link to the
phone is dropped, and the Jerry firmware in the phone quite
immediately tries to re-connect to the Jerry device. Then
SDP and Discover Services is started, fetchRemoteUuids() ->
discoverServicesNative(). This results in an asynchronous dbus
call dbus_func_args_async()  that is provided with a callback
function, onDiscoverServicesResult(), but before this callback
function is used Bluetooth is disabled according to the problem
scenario above. For some reason this discover services activity
is not cleared when Bluetooth is disabled, so when Bluetooth
is enabled again the (old) callback function
onDiscoverServicesResult() is executed, but the following
getAddressFromObjectPath() fails. The reason for this is that
the deviceObjectPath parameter contains an old value,
containg the process id of the old bluetoothd (the one running
before Bluetooth was disabled). Then the new updated
AdapterObjectPath /org/bluez/<new bluetooth hd pid>/hci0/dev_
is not a prefix of the old deviceObjectPath /org/bluez/<old
bluetooth hd pid>/hci0/dev_<BT_ADDR>, which results in that null
will be used as address in sendUuidIntent(), and later on,
ending up in the BluetoothDevice constructor where and
IllegalArgumentExceotion is thrown due to
Bluetooth address = null. Then the phone will crash.

Making sure sendUuidIntent() is not called when address is null
is a work-around for the problem.

Change-Id: I8ff60bad80de3b379cef0970402943dfa4de3cfd
2011-01-13 09:28:48 -08:00
Jaikumar Ganesh
f487d72215 Add ability to parse keyboard fixed pin auto pair blacklist.
Try auto pairing with such keyboards.
Also fix bug where dynamic auto pairing file was not being created.

Change-Id: I93afb96fee8bc4f245f96ec5961979c620de7948
2011-01-12 11:56:15 -08:00
Jaikumar Ganesh
ac6f13dc68 Revert "Add temporary hack for keyboards not following spec."
This reverts commit 8cc316e4f4.
2011-01-12 10:08:57 -08:00
Jaikumar Ganesh
8cc316e4f4 Add temporary hack for keyboards not following spec.
Change-Id: Ic206d45e54f0dc2ccf8124adb08df0c768d7e130
2011-01-06 14:18:58 -08:00
Jaikumar Ganesh
c88b0c62c5 Follow the spec recommendation for keyboard pairing.
Generate a variable pin and show it to the user.

Change-Id: Id4aae7a16f25c67d6c6ead6fd936cb14087f3c7a
2011-01-06 14:18:42 -08:00
Jaikumar Ganesh
057898a9b5 Enable Bluetooth reverse tethering.
Change-Id: I84a508b64f18a1445b8ac424f2a36d56ef432375
2010-12-22 15:24:18 -08:00
Jaikumar Ganesh
b9fbc9e92f Fix parameter to Pan Device Call.
Change-Id: I659e47feb56b052c61b7ee5521ffb5be71ce04c2
2010-12-21 17:27:07 -08:00
Jaikumar Ganesh
5200c8ab72 Add EXTRA_LOCAL_ROLE to Pan State change intent.
This will help apps distinguish between reverse and normal tethering.

Change-Id: I5327ad75dc2cbf478e4f7c2cd6ef1dbe8fba9e93
2010-12-21 16:53:43 -08:00
Jaikumar Ganesh
b7ec3e1019 Fix PANU - Bluetooth tethering - JNI calls.
Change-Id: Ia0b37a03e65be6632cc0bb8f1a98f268d42c9d87
2010-12-16 18:02:29 -08:00
Robert Greenwalt
81d5ad515a Fix Bluetooth-tethering config of interface.
bug:3288692
Change-Id: Id7f1b680392f938000953157716bf9a8f8a66af9
2010-12-16 11:35:40 -08:00
Jaikumar Ganesh
6a3c473910 Add FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT to name changed broadcast.
BT can come up before the system boots up and we send a broadcast,
this can cause issues.

Bug: 3259948
Change-Id: I53ce6b9851fbf611309db1f0a16768ef9f388e0c
2010-12-15 13:14:47 -08:00
Robert Greenwalt
04808c2940 Fix some IpV4-only code.
InterfaceConfiguration changed to use InetAddress and stop with the string->int->string
conversions.

bug:2542681
Change-Id: I11c4954547333c43bb840fa0469ddde57b0d043b
2010-12-14 14:41:26 -08:00
Jaikumar Ganesh
2d1fc4e3f5 Remove delay with auto connection.
SDP records are now registered with a dbus call so we don't have to wait
for initiating auto connections.

Also reduce time to connect other profiles case by 2 secs.

Change-Id: I8f0eab6a95d3bfaf11a8eb7495a024949639d7fc
2010-12-13 15:58:44 -08:00
Jaikumar Ganesh
84690c88f3 Add direct calls to Bluez to add SDP records.
This helps Settings app to enable just the Headset service.

Change-Id: Ia9c39467df1e83d665e377313e16e6c54991f6d6
2010-12-13 11:37:41 -08:00
Jaikumar Ganesh
58b93c3640 Update BT code for voice capability cases.
1. Disable PBAP and Headset / Handsfree records.
2. Add API to query for local adapter UUIDs.

Change-Id: Ic84ba6a49738adc89a8695d3a4890f08562e0621
2010-11-24 10:49:47 -08:00
Jake Hamby
39657b808f Revert "Don't call cancel discovery when its already canceelled."
This reverts commit 58d0dcb75b.
Fixes a bug where discovery would start every 20-30 seconds.
2010-11-19 16:45:58 -08:00
Jaikumar Ganesh
58d0dcb75b Don't call cancel discovery when its already canceelled.
Reported by: Leijun Tao

Change-Id: I5f04ecde16d147776a30810210cd3c973aee4d87
2010-11-12 09:41:12 -08:00
Jaikumar Ganesh
bb0773fac8 Fix crash in dump function.
Change-Id: I5a4cd7cf3fd325ced5d05f036c191f759dee16e0
2010-11-11 15:18:19 -08:00
Jaikumar Ganesh
7a0f816916 Disconnect PAN and Input devices on BT disable.
Also, add a missing break.

Change-Id: I228f80a4223de20e60d2f3828e3f63bdc14f5afc
2010-11-01 15:04:06 -07:00
Jaikumar Ganesh
c53cab20b2 Add an API call to get the ConnectionState of the Bluetooth Adapter.
Change-Id: Icd87d7720189034946aaa98e1a6c5d03ef4219e5
2010-10-26 16:03:01 -07:00
Jaikumar Ganesh
b2ec4fa8d7 Fix A2DP connection problem, if disconnected while playing music.
Change-Id: I594564c11dc1698f00f9db3e6f6e4f8da9e2fe69
2010-10-26 11:22:48 -07:00
Jaikumar Ganesh
8febf88618 Add logs to debug incoming A2DP connection issue.
Change-Id: Ifbdd625ec8dc50544990a1ddbd87284285f3f2d2
2010-10-26 00:28:39 -07:00
Jaikumar Ganesh
b1ef244732 Clean up some logging to make it more useful to debug.
Change-Id: Ic30210ea6886b1c4630d7671a4b01736512e9da8
2010-10-26 00:15:45 -07:00
Jaikumar Ganesh
a46f2fb152 Implement ACTION_CONNECTION_STATE_CHANGED intent.
Change-Id: I6b5783c189c9796ebd85d9d54bdcb07949bef27e
2010-10-25 18:44:57 -07:00
Jaikumar Ganesh
ff7db40be1 Make setting the adapter properties asynchronous.
1. These involve disk operations and multiple processes.
2. onPropertyChange already informs us asychronously.
3. Settings app is the only user, will have to revisit the function
   if we make them public.

Change-Id: If019a83c05a0c9e625f27faf99063d33f369f0d8
2010-10-25 16:36:45 -07:00
Jaikumar Ganesh
5a1e4cf83f Update BT APIs return type from Set to List.
Change-Id: Ia27220dd26cde13007f6938c830517ee7f6968ce
2010-10-22 11:36:28 -07:00
Jaikumar Ganesh
03cd78cf5e Convert return type of APIs from Set to List.
Most of the time it will either be empty or have 1 device.
Using list makes it much a better API and since its supported
by the AIDL format, the code becomes much nicer.

Change-Id: I5a2508b33ba754fc8cc738409d658e1235aaf2cf
2010-10-22 11:36:27 -07:00