Virtual input devices did not store the deviceId as this was not needed.
This change stores the deviceId during the device initialization (deviceId
is given to InputDeviceListener callback, which is used to wait for a
virtual device to be initialized and configured)
The deviceId is needed to restrict an input device to a display group.
Bug: 244516415
Test: atest android.hardware.input.cts.tests.VirtualKeyboardTest
Change-Id: I982191d543556e2728e41d6da01ab1a631e50e1a
* changes:
Add deviceId to Context and allow for creating Contexts with different deviceId.
Open the visibility of VirtualDeviceManager and VirtualDeviceManager#getVirtualDevices.
Add an API to get the details of all virtual devices.
Expose minimal information about a virtual device in `VirtualDevice` and allow clients to access it via VDM.
Bug: 239152561
Test: atest VirtualDeviceTest, CTS sent separately
Change-Id: I7e21009444205925707821692888dad50b58316f
This will be used in a later CL to allow virtual displays to be
associated with their virtual device.
Bug: 205343547
Test: atest VirtualDeviceManagerServiceTest
Change-Id: Ibbf5a8c834d5d7a7bac4816a0ea151adad4e7ea7
Update the javadoc that application must caancel it's own
bt discovery before calling assoicate api.
Test: make
Fix: 245763762
Change-Id: I41746f0d52d58e69edf453047416b6fc235db72e
Adds close listener so that VirtualDevice can remove the cached reference when VirtualAudioDevice is closed.
Bug: 224917468
Test: atest FrameworksCoreTests:android.companion.virtual
Change-Id: I0fa27818568684f7bfb7edd62a6d6eebdb648f29
The ArrayEquals, ArrayHashCode, ArrayToString, and
ArraysAsListPrimitiveArray errorprone findings were
demoted from errors to warnings. Fix existing
occurrences of them so they can be made errors again.
Bug: 242630963
Test: RUN_ERROR_PRONE=true m javac-check
Change-Id: Ia6f216cc36ad0a5758f39fd9b34962cd4adf9d8e
The ISystemDataTransferCallback argument can be null, so quietly
handle that case. Also fix bug where we forgot "break" statements
when processing responses.
Finally, always detach transport before closing streams to avoid
misleading warning logs being emitted from system.
Bug: 237030169
Test: manual
Change-Id: Id6d2d93a1c6872152112f877a2b92f4656277803
An earlier change introduced a socketpair() based CDM transport,
which is robust "streaming" interface between two devices.
This change updates the existing permissions sync logic to use this
new transport for its payloads. It also begins returning success or
failure messages so the requesting side knows when the permissions
have been applied.
We also rename the package and class hosting the transport logic,
and migrate our socketpair() based transport logic there. Since
the initial version of this protocol won't be using protobufs,
and doesn't need to implement manual pagination, this change also
removes that logic to reduce the size of our backports.
Finally, since this transport isn't ready to be used by third-party
apps, we add security checks to only allow built-in apps.
Bug: 237030169
Test: atest CompanionTests
Change-Id: Ia0dab24d44f1973d5af6ad8a2abb198408a681df
callback
This new trigger API accpets a callback which would be executed when the
system data transfer finishes successfully or with error.
The callback hasn't been fully implemented because we need signals from
transport layer when the transfer finishes.
Bug: 237030169
Test: m builds
Change-Id: I7e57d3e53e5f019c8730df10f7ec6c840e446f67
Based on design conversations with the team, it's more robust to
rely on a CDM companion service to provide a "streaming" interface
between two devices, instead of building our own message
fragmentation and reassembly logic. (Most transports such as
Bluetooth RFCOMM will already be doing their own fragmentation, so
we don't need to duplicate that work.)
Additionally, this change uses socketpair() for the bidirectional
data transfer between the companion service and the system_server,
avoiding additional Binder transaction load while handling its own
chunking, at the expense of dedicating two threads to "shovel" data
in each direction.
This change attempts to implement the design in the most
straightforward way possible to reduce risk; there are several
opportunities to optimize the thread usage using tools like
MessageQueue.addOnFileDescriptorEventListener(), but those will
need to wait for a future iteration.
Also includes basic functionality tests that exercise a PING/PONG
command to verify many different edge cases; they're currently all
passing.
Bug: 237030169
Test: atest CompanionTests
Change-Id: I075128fa60379f47400345b211a07d9a32391155
This cl fixes the problem that CDM calls RoleManager.removeRoleHolderAsUser()
will kill the application's process that lead to the poor user
experience.
In order to fix the problem:
1. Introduce a new OnUidImportanceListener which watches the
importance of the packages. In this class, we only interested in
the importance of the running process is greater than
IMPORTANCE_VISIBLE.
2. Introduce a new field in AssociationInfo class: 'mRevoked' to
indicate the associaiton has been reovked and pending for
role holder removal. So that the revoked association can store
in the same place as the active associaiton -> easy maintenance.
3. Finally remove the role holder for the packages are not visible to
the users.
Bug: 189250370
Test: atest CtsCompanionDeviceManagerCoreTestCases
atest CtsCompanionDeviceManagerUiAutomationTestCases
atest CtsOsTestCases:CompanionDeviceManagerTest
Change-Id: Ib7fb08b0d800c62a9ee708ddd52cd174de1829d9
Merged-In: Ib7fb08b0d800c62a9ee708ddd52cd174de1829d9
This cl fixes the problem that CDM calls RoleManager.removeRoleHolderAsUser()
will kill the application's process that lead to the poor user
experience.
In order to fix the problem:
1. Introduce a new OnUidImportanceListener which watches the
importance of the packages. In this class, we only interested in
the importance of the running process is greater than
IMPORTANCE_VISIBLE.
2. Introduce a new field in AssociationInfo class: 'mRevoked' to
indicate the associaiton has been reovked and pending for
role holder removal. So that the revoked association can store
in the same place as the active associaiton -> easy maintenance.
3. Finally remove the role holder for the packages are not visible to
the users.
Bug: 189250370
Test: atest CtsCompanionDeviceManagerCoreTestCases
atest CtsCompanionDeviceManagerUiAutomationTestCases
atest CtsOsTestCases:CompanionDeviceManagerTest
Change-Id: Ib7fb08b0d800c62a9ee708ddd52cd174de1829d9
Merged-In: Ib7fb08b0d800c62a9ee708ddd52cd174de1829d9
When creating a VirtualDisplay for a VirtualDevice, we need to do some
extra work like setting up for input injection, creating a
DisplayWindowPolicyController, and grabbing a wakelock to keep the
display awake. Some parts of this extra work end up calling back into
the DisplayManagerService from another thread, but since we're already
holding the mSyncRoot lock we sometimes get into situations where
those threads get blocked trying to acquire mSyncRoot, while holding a
lock that another thread ends up needing like the global window
manager one, so we get deadlock.
The fix in this CL is to break up the extra work the
VirtualDeviceManagerService needs to do into two parts: one part that
happens before the VirtualDisplay is created, and one part
after. Neither of these needs mSyncRoot to be held.
Fixes: 230544802
Test: atest CreateVirtualDisplayTest
Change-Id: I6a6e03f816567579510b3f1ef0705375549a3c88
Main changes:
1. Backup/restore permissions into/from CompanionMessage. ~95% of the
B+R code is copied from PermissionController and minimal changes have
been made to accomodate the CDM perm sync case. The main logical changes are
near the commented blocks in the files.
2. Message pagination
Bug: 228228540
Test: Manually tested on CDM test app, checked the output proto bytes.
Restore hasn't been tested, will test when the test app is done.
Change-Id: I21cdb6106b4237b72ea798ba3f206db5ee136916
When calling VirtualDeviceManager#createVirtualAudioDevice(), if the
caller pass null AudioConfigurationChangeCallback parameter, it means
the caller doesn't care the audio playback/recording change in virtual
display, and we should not register it with AudioManager for
optimization.
Bug: 218528439
Test: atest CtsVirtualDevicesTestCases
Change-Id: I00120f2506f593100ef8c523a4f6addffe46597b
Design doc: go/cdm-perm-sync
There are 3 parts of the APIs:
1. Data transfer APIs (onMessageDispatchedFromSystem/dispatchMessageToSystem) - For communication between the companion app and CDM. Previously been reviewed: ag/15741895, ag/15899622
2. Building user consent dialog
intent (buildPermissionTransferConfirmationIntent) for system data transfer. Previously been reviewed: ag/16422340
3. Trigger API for the actual system data transfer (startSystemDataTranfser) - It allows apps to trigger
system data transfer when the comms channel between the apps on two
devices is established and ready to communicate.
Bug: 204593788
Test: manually tested user consent dialog via the CDM test app.
Change-Id: Id7bf2628f75b35dbb546781524f1a968b0ac27a2
Instead of separate onLaunchSuccess and onLaunchFailure methods, combine
them into onLaunchComplete(int status), which can either be SUCCESS or
indicate the reason for failure.
Bug: 219985243
Test: atest CtsVirtualDevicesTestCases
Change-Id: I822c189b4bfc49ce936f072ff6e06f504c8eb80d
The topActivity defined in ActivityListener#onTopActivityChanged is @NonNull, so GenericWindowPolicyController should not send the callback when topActivity is null.
Bug: 222771130
Test: manual testing
Change-Id: I227d1d83e0e191975ab45b110909938022bb1d0c
1. Add the new association request failure codes
RESULT_USER_REJECTED, RESULT_DISCOVERY_TIMEOUT
RESULT_INTERNAL_ERROR
2. Add the new association failure reason:
REASON_CANCELED, REASON_DISCOVERY_TIMEOUT,
REASON_USER_REJECTED
The change helps to identify user's action that
the association request explicitly declined by the user
Test: atest CtsCompanionDeviceManagerCoreTestCases
atest CtsCompanionDeviceManagerUiAutomationTestCases
atest CtsOsTestCases:CompanionDeviceManagerTest
Bug: 223706865
Fix: 224559263
Change-Id: I50fe40780a977c5bbe0aac5b67e1925ea75058bb