27 Commits

Author SHA1 Message Date
Lucas Dupin
2447e9c280 Use system dialog corner radius
Bug: 64122537
Test: am start -n com.android.companiondevicemanager/.DeviceChooserActivity
Change-Id: I4a2c9b0659ba8e2f51b9a53b23ca75868e849a10
2017-11-29 13:13:26 -05:00
Eugene Susla
12ea054e90 [Companion] Fix NPE due to looking up view btoo soon
Fixes: b/64101223
Test: Ensure attached bug no longer reproduces
Change-Id: I23bb05c5355972ce96d08f620ceb8463df3fe853
2017-07-27 14:07:51 -07:00
Eugene Susla
38dff3b78a [Companion] Close chooser dialog on device tap
Fixes: 63597808
Test: Ensure list selection is now 1-tap
Change-Id: If99fc5e5c9b24526ac48dfc1c87659b01e713989
2017-07-13 14:56:03 -07:00
Eugene Susla
7a090a11ed [Companion] Dont crash if started with bluetooth off
Bug: 63068644
Test: Turn BT off, and ensure the attached bud doesn't reproduce
Change-Id: I0de5ba6d28d7195dd3ebc7a3af36f057c762de60
2017-06-28 11:01:04 -07:00
Eugene Susla
0c4a926626 Support associating with an already-paired device
This is required for migration scenario, where device(s) are already
paired(and thus no longer discoverable) but didn't go through companion
flow.
This also fixes a bug with filtering by mac address, which is also relevant to
the use-case of associating a specific device

Test: Pair with a device first, and call associate with a filter with its MAC
address and single device requested. Ensure the device is found.
Ensure only that device is ever returned when filtering by MAC address.
Bug: 62487084
Change-Id: Ic7cc6affc0648ad85b15620e8c3aba4b9fc91aa1
2017-06-12 16:21:51 -07:00
Eugene Susla
cbead6cf97 Fix Companion UI crash on configuration change
Fixes: 38004370
Test: Ensure no more crash described in the bug.
Change-Id: I9c8266d545eff337760bf875cedfe90fc15e4b7c
2017-05-17 17:48:19 -07:00
Eugene Susla
722463ff95 Follow acronym convention for Companion BLE filter
Test: Ensure no compilation error
Fixes: 37514177
Change-Id: I4c255cf6b3c62d762755a9822928561371ecd88d
2017-04-25 14:42:35 -07:00
Eugene Susla
b7aec13d51 Remove 'via Bluetooth' from the choosed dialog
We no longer limit the items in a single chooser dialog to a devices from
single medium type.

Test: Ensure the dialog UI reflects the change.
Change-Id: Ia2342861f51f89e870f1c6a7fbebf9c1a37cac6a
2017-04-24 17:43:44 -07:00
TreeHugger Robot
e4964118c6 Merge "Change companion languare from 'pair' to 'link'/'ok'" into oc-dev 2017-04-24 20:31:06 +00:00
Eugene Susla
611797073f Merge "StopScan before each new Companion device scan" into oc-dev 2017-04-20 17:51:00 +00:00
Eugene Susla
a7717e3072 StopScan before each new Companion device scan
Fixes: 37356792
Test: Call associate many times rapidly with alternaring request value
Ensure no stale result is displayed
Change-Id: Icaa230d9ad468119e20b3de89f19c36531c2c60f
2017-04-19 11:20:06 -07:00
Eugene Susla
254b3730df Use wifi icon for wifi devices in companion chooser
Test: Ensure wifi devices have wifi icon
Change-Id: I08c9fba1acaefb097a010b1150cc052d5a397adc
2017-04-18 14:15:23 -07:00
Eugene Susla
3db65438ec Change companion languare from 'pair' to 'link'/'ok'
Test: Ensure the chooset dialog still works and reflects the changes.
Change-Id: If687affb47cbf3fee2c589e1a5f8ab98c72e27d2
2017-04-18 12:41:20 -07:00
Eugene Susla
200c37f413 [DO NOT MERGE] Stop scan on device chooser activity backgrounded
This effectively treats chooser activity pause event as cancel.

Bug: 30932767
Test: Install two toy apps and call associate API from both.
  Ensure foreground app always end up showing fresh data.

Change-Id: I7f5742e9878245550f678efd244bf84c427baef3
2017-04-14 23:17:04 +00:00
Eugene Susla
5423b4e0a8 [DO NOT MERGE] Improve the error msg when started not for result
This makes sure that if the association request callback IntentResult
s accidentally started not for result, the resulting exception is
metioning it explicitly.

Test: Ensure the error message when calling the IntentSender not for result
  explicitly mentions the requirement for the activity to be called for result.
Bug: 30932767

Change-Id: I950f262af43c555fb20dd5e49e935e476f24bba8
2017-04-14 23:15:12 +00:00
Svetoslav Ganov
728ce60465 Merge "[DO NOT MERGE] Fix a bug with filtering by raw bytes" into oc-dev 2017-04-14 23:11:30 +00:00
Eugene Susla
3c9aa1767c [DO NOT MERGE] Fix a bug with filtering by raw bytes
(when such filter is not provided)
See change in BluetoothDeviceFilterUtils

Bug: 30932767
Test: Call API with a BLE filter with no raw bytes filter, matching some device.
Ensure that the device eventually shows up.

Change-Id: I4397fa33dd0c48771c8a754791a171f2d0bd64eb
2017-04-14 23:10:20 +00:00
Alan Viverette
51efddbd3b Remove unnecessary casts on calls to findViewById
Just frameworks/ this time. More paths to come.

Bug: 24137209
Test: make -j32
Change-Id: Iff27abd26fa43296ac2fff8f534fc6742d2ae80c
2017-04-14 11:15:50 -04:00
Eugene Susla
a38fbf63fd Unbind from service on app killed and dedup association requests
1. Listen to calling package binder death stopping the scanning on that.
2. Don't restart scanning when a request with the same values was made.

Bug: 30932767
Test: 1.:
  - Using a test app start scanning and kill the app.
  - In debug mode ensure that DeviceDiscoveryService#stopScan gets triggered
2.:
  - Start scanning and rotate the device while device chooser is visible
  - Ensure no visible loss of state is happening
Change-Id: If126a2c963da90172a956fbd88e6b3dcd7ac8b01
2017-03-24 14:03:17 -07:00
Eugene Susla
6a7006a968 Register PackageMonitor for CompanionDeviceManagerService
1. On package removed -> remove all its associations
2. On package updated -> if had associations, update special access permission
in accordance with (potentially changed) permission entries in manifest

Bug: 30932767
Test: 1. Remove app, and ensure xml entries for it got removed.
2. adb install new version of app without special permissions in manifest, and
ensure whitelist removal method got called
Change-Id: I87261c05ddcf40a18332d160b44ee2f8284df5e4
2017-03-20 13:38:58 -07:00
Eugene Susla
36e866b8e0 Support multiple filters per association request
By supporting multiple filters per one request we should be able to cover
multiple kinds of use cases such as:
 - Letting the user select from a list of devices of more then one medium
 type (e.g. Bluetooth and BLE)
 - Allowing to provide multiple criteria for any field (e.g. filtering by
 more than one service UUID)

Bug: 30932767
Test: Provide multiple filters and ensure that devices matching either are
shown in the list to choose from.
Ensure wifi SSIDs are shown in the list if wifi filter is provided

Change-Id: I0a978787551a1ee5750ec5544b241d3bbfed5a7c
2017-03-09 17:52:49 -08:00
Hector Tellez
d66c95fa90 Revert "Support multiple filters per association request"
This reverts commit e70e6aa62c6f3a9a79624a4f9d97df95edda0364.

Change-Id: I12857cbbea0a0c74521191ab5e3713db230626ab
2017-03-09 17:55:43 +00:00
Eugene Susla
e70e6aa62c Support multiple filters per association request
By supporting multiple filters per one request we should be able to cover
multiple kinds of use cases such as:
 - Letting the user select from a list of devices of more then one medium
 type (e.g. Bluetooth and BLE)
 - Allowing to provide multiple criteria for any field (e.g. filtering by
 more than one service UUID)

Bug: 30932767
Test: Provide multiple filters and ensure that devices matching either are
shown in the list to choose from.
Ensure wifi SSIDs are shown in the list if wifi filter is provided
Change-Id: I6621da388e2bf4ed97c5af2692629a321d0b63c7
2017-03-08 16:52:14 -08:00
Eugene Susla
47aafbe033 Record app<->device association to xml file
Bug: 30932767
Test: Ensure file not exists -> query associations -> ensure result is empty list
  Associate device -> cat xml file -> ensure record appears as extected
  Disassociate device -> cat xml file -> ensure record is no longer present
Change-Id: Ibe456a6d9292e05e2391f5138e43fdaa37f87e1b
2017-03-06 16:53:32 -08:00
Svet Ganov
da0acdf938 Auto-grant background execution and data access
Companion apps can declare they want background access and
background execution exceptions via dedicated permissions
in their manifest. If such a permission is requested we
auto-grant the corresponding exception after the user has
chosen a device from the companion UI. These permissions
are appop ones allowing us to use the app ops for gauging
whether the user has made a change after we auto-granted
the permission since we would like to revoke these special
privileges when the app disassociates itself from the
companion device if the user did not make an excplicit
choice otherwise.

While at this auto-grant fixed location permission to the
companion device discovery service.

Test: manual

Change-Id: I46ee4291e5e5a8f7613f0dd75eb61d6b9341f306
2017-02-15 20:32:41 -08:00
Eugene Susla
d44f9334ed Companion device chooser UI enchancements
Test: Ensure the device chooser dialog looks nicer.
Bug: 30932767
Change-Id: I62e6437e26f229aedb051998a8745a6e1918dbdc
2017-02-07 18:27:15 -08:00
Eugene Susla
6ed45d8cd3 CompanionDeviceManager
This introduces an API for apps that support companion devices to provide a
more streamlined flow for pairing and setting up the device

Bug: 30932767
Test: Using a toy app, invoke the newly introduced API (CompanionDeviceManager),
 and go through the flow. Ensure filtering works, and device is returned to
 the calling app. Ensure the calling app can pair to the selected device.
Change-Id: I0aeb653afd65e4adead13ea9c7248ec20971b04a
2017-02-06 12:50:55 -08:00