Commit Graph

1991 Commits

Author SHA1 Message Date
TreeHugger Robot
2c442e962e Merge "Stop using return within finally" 2016-11-04 02:42:11 +00:00
Ray Essick
7601049275 Stop using return within finally
Refactor code to avoid a return statement inside a finally block. Such
constructs interfere with exception propagation in non-obvious ways
and are therefore considered bad practice.

Bug: 32586420
Test: manual code walk
2016-11-03 14:45:56 -07:00
Philip P. Moltmann
08b678c029 Correctly use ByteBuffer in UsbRequest
Meaning: Read/Write to correct area in buffer, set position correectly.

- Create a new method UsbRequest#enqueue that has correct behavior, deprecate
  UsbRequest#queue.
- Move all description of the weird (legacy) UsbRequest#queue behavior to
  this method.

Change-Id: Ibeed400b4ad2aa9d005ace345c7895a3dc4ba1ad
Fixes: 31050148
Test: Submitted alongside
2016-10-27 10:25:40 -07:00
Philip P. Moltmann
927fefe813 Add UsbDeviceConnection.requestWait with a timeout
Test: Test is submitted alongside this change
Change-Id: I1c46143030a2822ee76676ddc80d3b5c8c62ee80
Fixes: 31288102
2016-10-26 10:21:21 -07:00
Yin-Chia Yeh
3e254b6953 Merge "Camera2 Legacy: catch more surface abandoned error" am: 03f14bef41 am: 50f9b6e71f
am: 0eb99d23b4

Change-Id: Ie8dbed22423aa52b418cebfd19e29c6ae2c6e2b5
2016-10-21 21:28:21 +00:00
Yin-Chia Yeh
50f9b6e71f Merge "Camera2 Legacy: catch more surface abandoned error"
am: 03f14bef41

Change-Id: If2e05eeb8c7fe24f97fc0c5e20bfe03a6c8c9e23
2016-10-21 21:07:44 +00:00
Yin-Chia Yeh
091661334b Camera2 Legacy: catch more surface abandoned error
Bug: 30140107
Change-Id: Ia293bdbb85c8078e17def55db9c599cfe70458db
2016-10-21 11:40:46 -07:00
Shuzhen Wang
88f1af2410 Camera2: Add onCaptureQueueEmpty callback
onCaptureQueueEmpty indicates that the non-repeating
capture request queue of camera device is empty, and
is ready to process a new request.

Test: testMultipleCapture in PerformanceTest.java

Bug: 29006447
Change-Id: If245ff6abf352548ca13a10fcfbd1550b92c1224
2016-10-18 17:50:17 -07:00
Philip P. Moltmann
f2d83edc26 Clarify which props of USB devices are optional
Test: Compiles, manually inspected object creation code, ran USB CTS
verifier tests
Fixes: 32209658
Change-Id: I738c0cea5a0f37484e986f0a01c8ed9c46b639ed
2016-10-17 12:14:45 -07:00
Jerry Zhang
7a396be6d5 Refactored setCurrentFunction and setUsbDataUnlocked into single method.
This gets rid of an extraneous configuration change when going from
adb to adb + file transfer as previously the config would have been
reset once for functions and once for data unlocked.

It also simplifies some of the code.

Test: manually changing usb configurations
Change-Id: Ica10a195338b2189db13113f44657393db110bee
2016-10-13 17:32:21 -07:00
Philip P. Moltmann
5201f1e61c Do not access MTP devices when disabled.
The USB data transfer is disabled we should not allow access MTP devices
(e.g.
usb sticks). We have two ways of accessing them: Either by mounting them
or by creating a MTPDevice in an app.

Of course an app could implement implement their own MTPDevice
implementation. In this case we cannot enforce the policy without
completely suppressing all MTP USB devices which would be too
restrictive.

Note: When the policy is set we do _not_ disconnect already connected
MTP devices

Fixes: 31472955
Change-Id: I6080c48c49657102774b2b3b4d89ff030245a266
2016-09-30 22:24:23 +00:00
Eino-Ville Talvala
dce815430d DngCreator: Do not cache timezone in static initializer am: ec727411d2 am: fa141e303e
am: f6ea31d8f1

Change-Id: Ib702bb0fed2a4980ce543a1ab37d7c43179a67e8
2016-09-29 02:05:30 +00:00
Eino-Ville Talvala
fa141e303e DngCreator: Do not cache timezone in static initializer
am: ec727411d2

Change-Id: I86d207b7bfd156f5296aa3f5ba5acecd2d762d4e
2016-09-28 21:27:21 +00:00
Eino-Ville Talvala
4e3bb26f64 Merge "DngCreator: Do not cache timezone in static initializer" into nyc-mr1-dev 2016-09-28 21:20:21 +00:00
Philip P. Moltmann
5dd4e6cf74 Clarify the behavior of UsbRequest
This is obviously just about describing a bad behavior. In the next step
these methods should be deprecated and replaced with versions that deal
with ByteBuffers appropriately.

Bug: 31050148
Test: Test that enshrines the documented behavior is submitted alongside
      this change
Change-Id: If250a8bbd636784355e839a1638d52f3bbe9b83d
2016-09-28 11:29:02 -07:00
Eino-Ville Talvala
ec727411d2 DngCreator: Do not cache timezone in static initializer
The static initializer for a pre-loaded framework class is run
no later than at zygote startup, which happens at device boot.

Which means that if the timezone later changes, DngCreator will use
an incorrect cached timezone until the next reboot.  This is especially
evident in freshly wiped devices, where initial setup will typically
change the timezone.

Instead, read the timezone each time DngCreator is created, which is
also when we query the current time for constructing the timestamps.

Test: android.hardware.camera2.cts.DngCreatorTest#testSingleImageThumbnail
Bug: 31743060
Change-Id: I83a4eac762650e5f904f3b8fa779c094cef30562
2016-09-28 11:10:00 -07:00
Greg Kaiser
5abcc9a888 ContextHubService: Hack around 32-bit app ID am: 1983f9b05b am: 40c0435026
am: eaed84e40a

Change-Id: I2eb38c4cf7e27bfb75db2f41b529840ac9fd1f44
2016-09-28 00:11:46 +00:00
Greg Kaiser
1983f9b05b ContextHubService: Hack around 32-bit app ID
The NanoApp.java class has a bug (b/30808791) where the API treats
app IDs as 32-bits, instead of 64-bits.  We are too late in the
Android N release cycle to change this API.

We previously put in a hack to fix this only for Google nanoapps.
However, our GTS nanoapps need this to work, and there are other
partners who need this to work in the N timeframe.  So we make
a more robust hack which parses the full 64-bit app ID out of
the header binary.

Test: Compiles and runs GTS
Bug: 31767599
Change-Id: Ic43f1f62c685fb99aac08d08767d1a67c329503f
2016-09-27 15:01:48 -07:00
Chien-Yu Chen
62d6962835 Camera2: Support early finished tasks am: dd6629ef86 am: 8425ebc28f
am: e98ffa404e

Change-Id: If7c38066a4244a0ba02158442d0a067b6fc802cd
2016-09-27 00:55:42 +00:00
Chien-Yu Chen
dd6629ef86 Camera2: Support early finished tasks
Add support to track finished tasks before it starts.

Bug: 30117138
Change-Id: I42eb0377f719d57d820d9c1b2484600116c8807a
2016-09-23 17:23:45 -07:00
Philip P. Moltmann
1599ab8d12 Merge "Clarify UsbConnection#bulkTransfer api behavior" 2016-09-23 16:49:34 +00:00
Philip P. Moltmann
71985f5e23 Merge "Do not access MTP devices when disabled." 2016-09-21 18:14:25 +00:00
Philip P. Moltmann
5e040ae477 Clarify UsbConnection#bulkTransfer api behavior
- Do not allow negative length as inside of JNI this is interpreted as
  unsigned value which lead to memory corruptions.
- Document behavior for uncommon but usable values of parameters

Test: Ran CTS verifier UBS device test
Change-Id: I0899a2831c6dd2617528a5e79ea21932f6a66c13
2016-09-20 15:31:32 -07:00
Eino-Ville Talvala
2ce4b7a8a0 DngCreator: Fix calculation of date/time stamps am: 3fc21ef78b am: 215c76b1f4
am: ba57a47375

Change-Id: I818087e4a3495162eedceaebcd4da93c9eecfe87
2016-09-20 03:04:26 +00:00
Eino-Ville Talvala
3fc21ef78b DngCreator: Fix calculation of date/time stamps
Converting the sensor timestamp to date/time requires checking
what the timebase of those timestamps is; getting it wrong will
create drift that increases with device uptime.

Test: android.hardware.camera2.cts.
      DngCreatorTest#testSingleImageThumbnail
Bug: 30125412
Change-Id: Ia5db86012bc9e1c06463b8dc4434d3e063f62cf5
2016-09-18 17:11:41 -07:00
Philip P. Moltmann
2c6fe63b4c Merge "Set buffer before UsbRequest is queued" 2016-09-15 16:17:50 +00:00
Philip P. Moltmann
4346f3c5ec Set buffer before UsbRequest is queued
Otherwise a second thread might dequeue() it in between
native_queue_direct and mBuffer = buffer. If that happens the dequeue
operation does mBuffer.isDirect which triggers a NPE.

Fixes: 30914003
Change-Id: I3ca3b72db8f53a14be1c5f0e37f8924eba44b9bc
2016-09-14 22:44:50 +00:00
Philip P. Moltmann
3390281f71 Leak UsbDeviceConnection fd if not closed
This is the previous behavior and there are users that just copy the fd
and then forget about the connection. In this case it is unsafe to close
the fd when finalizing.

Change-Id: I5cd76564e1e8ddbd61c829b34b0f43b9c699f094
2016-09-14 14:13:46 -07:00
Philip P. Moltmann
ec3cbb2a66 Do not access MTP devices when disabled.
The USB data transfer is disabled we should not allow access MTP devices (e.g.
usb sticks). We have two ways of accessing them: Either by mounting them
or by creating a MTPDevice in an app.

Of course an app could implement implement their own MTPDevice
implementation. In this case we cannot enforce the policy without
completely suppressing all MTP USB devices which would be too
restrictive.

Note: When the policy is set we do _not_ disconnect already connected
MTP devices

Fixes: 31472955
Change-Id: I6080c48c49657102774b2b3b4d89ff030245a266
2016-09-14 13:29:45 -07:00
Eino-Ville Talvala
1a64580308 Camera2: Unhide deferred surface configuration APIs
To speed up camera startup, allow setting up a camera capture session
before all the output Surfaces are available (but their eventual sizes
and types are known). Also allow images to be captured to the
non-deferred outputs even before the deferred outputs are available.

This allows parallelizing of camera startup and UI layout.

Test: android.hardware.camera2.cts.SurfaceViewPreviewTest#testDeferrredSurfaces 
passes
Bug: 31319716
Change-Id: I657efc39bb8cc2d4bf201e5d70807a227ef82dde
2016-09-08 21:59:16 +00:00
Eino-Ville Talvala
3c8c16f9f1 Camera2: Clean up some obsolete trampolines left from original API launch
Test: Checkbuild passes on angler-userdebug
Change-Id: Iddcb72616be2eb07a4499647b3383ff9d37f73d2
2016-09-07 22:46:33 +00:00
TreeHugger Robot
1ae9143d7a Merge "Do not leak usb device connection FD" 2016-08-31 18:03:12 +00:00
Greg Kaiser
f4d609b9c0 ContextHubService: Hack in Google vendor value am: 5817ce0c13 am: 3d2f2a4305
am: ee483f7d78

Change-Id: I8ca30026b44d6ccea7cefa4b6671b4f286c352b5
2016-08-31 03:04:41 +00:00
Philip P. Moltmann
674e8c3825 Do not leak usb device connection FD
The native code uses mNativeContext=0 to indicate that is was already
closed and checks this properly. Hence let's leave the checking in the
native code.

We need to keep a reference in UsbRequest as otherwise the
UsbDeviceConnection might get finalized while a UsbRequest is in
progress. The UsbRequest itself makes sure that it is not garbage
collected while the I/O is in progress.

Also I added CloseGuards to make sure the classes are used properly and
fixed an error string in the native code.

Fixes: 31124312
Bug: 31021315
Change-Id: I96deb73957eba0e14e6b656988a2ae9b409bf55f
2016-08-30 10:52:39 -07:00
Greg Kaiser
ed2a5f8592 ContextHubManager: Document InstanceInfo bug am: 3be73d3950 am: 6f155aa4bf
am: 7fd9e40381

Change-Id: I0f95997e013d5cb8fb23b18ad82763cc091e38f1
2016-08-30 17:20:09 +00:00
Greg Kaiser
786676eb39 NanoAppFilter: Workaround HubId issues am: 3907049080 am: 41ef2a038d
am: d20ed26dff

Change-Id: Iba85f8939fca3bf097f8778fdd980bd9290a7530
2016-08-30 01:38:27 +00:00
Greg Kaiser
45cad7f70c ContextHubManager: Fix API documentation. am: fac5be2ace am: 921e7ef350
am: fce14d1808

Change-Id: Ib5e0ba71519b2be92064b691c4e7d5b1b51deb81
2016-08-30 01:32:36 +00:00
Greg Kaiser
974c0b6a2c ContextHubService: Don't double report app loads am: fe6d4f518a am: ca627a8cc3
am: 8c94f54e0f

Change-Id: I34887862a05e0cbe3c21e038c31072cd41f363a3
2016-08-30 01:26:40 +00:00
Greg Kaiser
3d2f2a4305 ContextHubService: Hack in Google vendor value
am: 5817ce0c13

Change-Id: I168a2a2a50168f7590842b5c51fbc8a80842b00e
2016-08-29 17:59:23 +00:00
Greg Kaiser
143aaa6d05 Merge "ContextHubService: Hack in Google vendor value" into nyc-mr1-dev 2016-08-29 17:43:31 +00:00
Greg Kaiser
6f155aa4bf ContextHubManager: Document InstanceInfo bug
am: 3be73d3950

Change-Id: I8a1418086d7e9c4f60205234394dd1cc8d1215df
2016-08-26 18:27:50 +00:00
Brian Duddie
73f511e471 Merge "ContextHubManager: Document InstanceInfo bug" into nyc-mr1-dev 2016-08-26 18:20:19 +00:00
Greg Kaiser
5817ce0c13 ContextHubService: Hack in Google vendor value
To workaround b/30808791 without changing the NanoApp API,
we make the assumption that if the most significant byte
of our four-byte app ID is a lower-case 'L', then this
is a Google Nanoapp and thus we should use "Googl" for
our vendor ID, and set the most significant four bytes
of our eight byte app ID accordingly.

Bug: 30922112
Change-Id: I155dff58cdda1ef36a68e6d25df1e9059b1252f1
2016-08-25 23:18:16 -07:00
Greg Kaiser
41ef2a038d NanoAppFilter: Workaround HubId issues
am: 3907049080

Change-Id: I0b9b272e05bc2ff4ecbc74b5570eda066dedede1
2016-08-26 03:44:47 +00:00
Greg Kaiser
921e7ef350 ContextHubManager: Fix API documentation.
am: fac5be2ace

Change-Id: I220af0f42791d1210acf9e88da670994f3c6ae45
2016-08-26 03:37:12 +00:00
Greg Kaiser
f8d61675ac Merge "NanoAppFilter: Workaround HubId issues" into nyc-mr1-dev 2016-08-26 03:34:39 +00:00
Greg Kaiser
1e07e392c3 Merge "ContextHubManager: Fix API documentation." into nyc-mr1-dev 2016-08-26 03:30:19 +00:00
Keun-young Park
badbbae6fa allow external USB host management
- Setting config_UsbDeviceConnectionHandling_component leads into
  launching specified Activity whenever USB device is connected.
- This allows external Activity to manage USB device based on
  its own setup and settings.
- Device access can be passed to other app with permission update
  by UsbManager.grantPermission.
- added UsbDeviceConnection.resetDevice() to reset USB device connected.
  This is necessary to get device out from AOAP.
- Test requires installing UsbHostExternalManagmentTestApp and
  AoapTestHost to USB host, and AoapTestDevice to USB Device.

bug: 26404209
Change-Id: I8e77ddc646c15454d9b2ecf1356924cf6351fc28
2016-08-24 15:00:08 -07:00
Greg Kaiser
3be73d3950 ContextHubManager: Document InstanceInfo bug
Our getNanoAppInstanceInfo() method returns incorrect information
for several fields in many cases.  We're too late in the release
cycle to fix the core of this issue, but we can at least document
it so users aren't surprised.

Bug: 30944457
Change-Id: I9330c3b77d08c36befbe20258c6cc45dc640f103
2016-08-19 11:09:01 -07:00
Greg Kaiser
3907049080 NanoAppFilter: Workaround HubId issues
There's no API to set mContextHubId, but testMatch() uses this.

We can't add API at this point of the release cycle, so instead
we default mContextHubId to HUB_ANY, which makes it always match.

Bug:30018518
Change-Id: I4e08afc65889dc109a4da1bd99a027345da865ca
2016-08-19 11:04:32 -07:00