Commit Graph

247 Commits

Author SHA1 Message Date
Antony Sargent
725dad7d71 Prevent deadlocks during VirtualDisplay creation
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
2022-05-29 11:18:36 -07:00
yuanjiahsu
36a660756e Add OWNER to Virtual Device Manager
Test: presubmit
Change-Id: I4a8a2b45835b7838ab41ae6867dc230471eb5952
2022-05-06 02:41:50 +00:00
TreeHugger Robot
3ece298e8b Merge "Add launch complete status to launchPendingIntent" into tm-dev 2022-03-30 22:47:56 +00:00
yuanjiahsu
ad1bf17965 Don't register playback/recording change if caller doesn't care it
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
2022-03-30 04:10:17 +00:00
Maurice Lam
5cecf5331a Add launch complete status to launchPendingIntent
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
2022-03-28 23:29:52 -07:00
yuanjiahsu
ab63d0671c Don't send callback with null topActivity
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
2022-03-24 16:39:58 +00:00
Shaun Corkran
a4889a2180 Merge "Add CrossTaskNavigations API to restrict navigation from current task" into tm-dev 2022-03-23 17:57:37 +00:00
Evan Chen
8fedd4796e Add a new association request failure code
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
2022-03-21 17:20:06 +00:00
Shaun Corkran
e9beecfa7e Add CrossTaskNavigations API to restrict navigation from current task
This changes the API to allow virtual device owners to configure allow
and deny lists of components to navigate to new tasks while being
streamed.

The change is only in VirtualDeviceParams, a recent API addition with
low touch. Base case has the new lists set to an empty set preventing
any change to current behavior.

Bug: 223915401
Test: Tests added in ag/17235857
Change-Id: Icb44163acb23736e562ffb4b08f4eb93c8b01990
2022-03-21 04:35:46 +00:00
Taylor Bessette
ddb1e2a09a Merge "Enforce @NonNull within VirtualDeviceParams." into tm-dev 2022-03-09 18:25:22 +00:00
Taylor Bessette
5741ba8051 Enforce @NonNull within VirtualDeviceParams.
Test: unit tests
Change-Id: I8768fd5264297e4a1938563ffc6b3bad67e13269
2022-03-08 16:23:23 -08:00
Yuanjia Hsu
8967e85cf4 Merge "Add more methods for capture and injection" into tm-dev 2022-03-03 00:43:31 +00:00
TreeHugger Robot
6c6f6bd6d5 Merge "Update VirtualDeviceManager.ActivityCallback API" into tm-dev 2022-03-03 00:08:27 +00:00
yuanjiahsu
5adb027679 Add more methods for capture and injection
Add #close() but keep it and the constructor as package-private because we want caller to call VirtualAudioDevice#close().

Add #getFormat() and the audio format will be owned by
AudioCapture/AudioInjection, not VirtualAudioSession.

Add all #read() and #write() overloads method, so that the caller can
replace the call to AudioRecord/AudioTrack easily.

Bug: 218542209
CTS-Coverage-Bug: 218528439
Test: atest FrameworksCoreTests:android.companion.virtual
Change-Id: Iccfd497e6aaeacc60a57d28ae730fdc0cce46a25
2022-03-02 19:09:33 +00:00
Maurice Lam
79b6c1cb92 Update VirtualDeviceManager.ActivityCallback API
- Removed overload of addActivityListener that doesn't have executor
- Moved executor to be before the listener

Bug: 219985243
Test: atest CtsVirtualDevicesTestCases
Change-Id: I0681aeabeeefde5ce2c3ff4da3f50acc7f22ca07
2022-03-01 22:13:43 +00:00
Christine Franks
70dda6fe48 Update remote input device doc and add IntDef
This IntDef specifies the supported key codes.

Bug: 216554655
Test: builds
Change-Id: Idde1ab17148294bd7348fdf72eb3b1fa65f777c1
2022-03-01 18:07:09 +00:00
TreeHugger Robot
47d52ee0bf Merge "Specify default activity policy" into tm-dev 2022-02-25 22:05:13 +00:00
Maurice Lam
804b69925e Specify default activity policy
Instead of using null values to indicate whether to use the allow list
or deny list for activity launching, add an intdef value to specify that
explicitly.

Bug: 219985243
Test: atest CtsVirtualDevicesTestCases
Change-Id: Ie6039262c95270f8886da7146999f30844f69a3c
2022-02-22 20:37:20 +00:00
Maurice Lam
4de7d3f9d2 Make executor @Nullable in createVirtualDisplay
Fixes: 218717272
Test: Existing tests pass
Change-Id: I0e4b73d8e9c3bf80e7d7d33213fd1c43d8ed207d
2022-02-22 20:32:31 +00:00
yuanjiahsu
5536865e01 Clean up audio resources when VirtualDevice is closed
Limits only one VirtualAudioDevice can be created per VirtualDevice.
When VirtualDevice is closed, the associated VirtualAudioDevice and VirtualAudioController will be closed as well.

Bug: 218751752
Test: atest FrameworksServicesTests:com.android.server.companion.virtual

Change-Id: I6aa8b8af8b526fb52bbb4b23305f28182012803d
2022-02-17 02:34:54 +00:00
Maurice Lam
b73e26f971 Address API review comments
Expand javadocs and change return value to NonNull for
VirtualDeviceManager.createVirtualDevice.
Also removed the redundant @TestApi on the virtual display flag.

Bug: 217742182
Test: Existing tests pass
Change-Id: I381039e6ebe4f5f5046a35e9a3e266ff7f46c369
2022-02-11 23:47:07 +00:00
Maurice Lam
1feb56be88 Add parameter annotations to createVirtualDisplay
Also changed the Handler parameter to Executor

Bug: 217742182
Test: atest CtsVirtualDevicesTestCases
Change-Id: I3321927b36361168655f4886825955a642fb6c79
2022-02-10 21:25:22 +00:00
TreeHugger Robot
db33f67f8d Merge "Use property instead of meta-data for primary CDM service" 2022-02-10 19:15:44 +00:00
Christine Franks
cb41738a86 Merge "Address API feedback and CTS on cloud devices" 2022-02-10 10:40:47 +00:00
TreeHugger Robot
f63c1051d7 Merge "[8/8] Use PresenceController and AppController in CdmService" 2022-02-10 09:58:21 +00:00
yuanjiahsu
f45b47964d Audio Injection respect Enterprise Policy
Listens to User Restrictions change of DISALLOW_UNMUTE_MICROPHONE to suspend or resume audio injection.

Bug: 195654431
Test: manual testing by go/testdpc pass
Change-Id: Ifedb89172edb0dc6474e078dea0c96f1c7038c4c
2022-02-10 03:32:03 +00:00
yuanjiahsu
69cf28591c Implement VirtualAudioDevice API
Add createVirtualAudioDevice() API in VirtualDevice to return a VirtualAudioDevice object for the caller to capture audio and inject microphone to applications running on the specified virtual display.

The VirtualAudioController in service side will responsible for listening virtual display running applications change, playback and recording config change, then notify the VirtualAudioSession to update AudioRecord/AudioTrack inside the AudioCapture/AudioInjection class internally.

Bug: 201558304
CTS-Coverage-Bug: 218528439
Test: atest FrameworksCoreTests:android.companion.virtual, atest FrameworksServicesTests:com.android.server.companion.virtual, manual testing with Exo by ag/16575248
Change-Id: I74f3da67b76aaa909943fbfc8418bf22d637ca39
2022-02-10 03:31:50 +00:00
Christine Franks
3b79889dfd Address API feedback and CTS on cloud devices
- Add additional javadoc for vendor and product ids
- Enumerate full allowed key code set for VirtualKeyEvent
- On cloud devices, CTS fails with 'bad address' for VirtualTouchscreen.
  Pass by address rather than by value to solve.

Bug: 216554655
Test: atest CtsHardwareTestCases:android.hardware.input.cts.tests
Change-Id: Ifb233d2b6c4eee1ffdcba218ed17312e67bac6f6
2022-02-09 17:14:52 -08:00
Evan Chen
bb287ae2d7 Use property instead of meta-data for primary CDM service
Meta-data will increase the system server ram consumption.
So we decide to use property instead of meta-data to
indicate the primary cdm service.

Test: atest CtsCompanionDeviceManagerCoreTestCases:SelfPresenceReportingTest
Fix: 217953124
Change-Id: I91ebe374bba392d14d693d3c6a36433b5af7cf2a
2022-02-09 19:35:22 +00:00
Antony Sargent
615b6c4e5d Merge "Rename LOCK_STATE_ALWAYS_LOCKED to LOCK_STATE_DEFAULT" 2022-02-09 17:08:28 +00:00
Sergey Nikolaienkov
880e3858ea Merge "Update javadoc for set/isForceConfirmation() in CDM" 2022-02-09 16:51:34 +00:00
Sergey Nikolaienkov
1aaf191972 Update javadoc for set/isForceConfirmation() in CDM
Replace "would prefer" with stronger language - "requires" - in the
javadoc to AssociationRequest.Builder.setForceConfirmation(boolean) and
AssociationRequest.isForceConfirmation().

Bug: 217366132
Test: m
Change-Id: I7d94598d71a39fc022927634975706ccffeac406
2022-02-09 14:17:24 +01:00
Sergey Nikolaienkov
aa15e1cc90 [8/8] Use PresenceController and AppController in CdmService
Use CompanionDevicePresenceMonitor and CompanionApplicationController in
CompanionDeviceManagerService.

Remove CompanionDevicePresenceController.

Bug: 211398735
Test: atest CtsCompanionDeviceManagerCoreTestCases
Test: atest CtsCompanionDeviceManagerUiAutomationTestCases
Test: atest CtsOsTestCases:CompanionDeviceManagerTest
Change-Id: I542c6d8157b51fc9c0a2e55055792b6951f292d9
2022-02-09 10:21:07 +01:00
Antony Sargent
e1db351bfb Rename LOCK_STATE_ALWAYS_LOCKED to LOCK_STATE_DEFAULT
Also update the documentation to more accurately represent what the
flag actually does.

Bug: 217273933
Test: existing tests should pass
Change-Id: I28c9798d7974e58cfcd6ab59e7ee50f9a6c43985
2022-02-08 22:36:51 -08:00
Christine Franks
2a017cdc08 Guard VirtualDevice#close by permission
If the permission is not already held by the caller through other means,
this causes unregistration failures, since the unique id disassociation
requires a signature permission. Clear the binding identity if the
permission is found, allowing use of the permisson. This is especially
important for CTS tests, and for access by non-signature apps.

Bug: 217275682
Test: atest CtsHardwareTestCases:android.hardware.input.cts.tests
Change-Id: Ide5232e5b5b5b1b3ca96e5cbfb997e4a1001a583
2022-02-08 00:25:33 -08:00
Christine Franks
27a354bf40 Add API to hide cursor for virtual mice
Bug: 216244627
Test: atest FrameworksServicesTests:com.android.server.companion.virtual
CTS-Coverage-Bug: 208247880
Change-Id: Ie1a2bc526a705f2f9788898afbff87f5a9448f85
2022-02-04 12:15:18 -08:00
Sergey Nikolaienkov
214667438f Merge "Add CDM CTS test modules to Test-Mapping Presubmit" 2022-02-03 09:52:38 +00:00
Maurice Lam
a072e9fd46 Unhide VDM API to allow / block specific activities
Bug: 194949534
Test: ag/15781910
CTS-Coverage-Bug: 204606917
Change-Id: I77b68bc04a7e5fd3b6d2ca3f84e5d772d6e680b2
2022-01-27 18:22:02 +00:00
Evan Chen
52b04dcfd3 Merge "Introduce COMPANION_COMPUTER profile for Phone Hub" 2022-01-27 06:57:35 +00:00
Guojing Yuan
08af136e37 Merge "[CDM perm sync] Hide data transfer APIs" 2022-01-27 05:09:17 +00:00
Evan Chen
79122d967e Introduce COMPANION_COMPUTER profile for Phone Hub
Bug: 216213933
Test: atest CtsCompanionDeviceManagerCoreTestCases:DeviceProfilesTest
Change-Id: I2cd6cfc5e2b9df3708fae3e4db8164e36fc9717a
2022-01-26 23:43:05 +00:00
Guojing Yuan
cad8812676 [CDM perm sync] Hide data transfer APIs
Due to permission sync feature has been punted to U, the data transfer
APIs need to be hidden.

Bug: 199427116
Fix: 203822629

Test: m and flash
Change-Id: Ibb642827cd9f1708a557af7a8a996826ceec3eb9
2022-01-26 22:50:17 +00:00
Maurice Lam
d7d54f31a9 Merge "Allow VDM virtual displays to get FLAG_OWN_DISPLAY_GROUP" 2022-01-26 05:06:24 +00:00
TreeHugger Robot
9e17f25d21 Merge "Unhide VDM activity APIs" 2022-01-26 03:45:15 +00:00
Maurice Lam
0f830d9944 Allow VDM virtual displays to get FLAG_OWN_DISPLAY_GROUP
For virtual displays that are created through VDM, allow
FLAG_OWN_DISPLAY_GROUP to be added. This applies to every display
created through VDM, because VDM adds this flag on behalf of the caller
by default.

Bug: 194949534
Test: atest DisplayManagerServiceTest.java
Change-Id: I1826dbd0cb7f4c4a76abbf25741b9862c5ff7355
2022-01-25 23:51:44 +00:00
Maurice Lam
f9e52140f2 Unhide VDM activity APIs
Unhiding VDM activity listener and launchPendingIntent APIs.

Bug: 194949534
Test: ag/15781910
CTS-Coverage-Bug: 204606917
Change-Id: I7c8b80cf8ed99d1c2931084840b5cd4428c5b285
2022-01-25 22:17:32 +00:00
Maurice Lam
4cf3f9b827 Add oneway to IVirtualDeviceActivityListener
Bug: 216200887
Test: Error logs no longer show on logcat
Change-Id: I4c945ef78be9277b2c2570538138f9b8b955d7c1
2022-01-25 18:25:50 +00:00
Maurice Lam
7f512ebc8a Add ActivityListener to VirtualDeviceManager
The API allows virtual device owners to listen to when the top activity
of a virtual device's display changes, and when a display becomes empty.
The former is used to display a notification to the user that can say
"Syncing <app name> to your Chromebook". The latter is used so that the
streamed window on ChromeOS side can be closed when the display becomes
empty.

Bug: 194949534
Test: To be added in ag/15781910
Change-Id: I5172e55a3a79b5fadc1719e99160b7675612e97b
2022-01-21 15:16:06 -08:00
Christine Franks
1bc94f4f47 Merge "Add mouse handling APIs" 2022-01-21 20:34:27 +00:00
Christine Franks
488d915feb Add mouse handling APIs
Bug: 202273865
Test: atest FrameworksCoreTests:android.hardware.input
CTS-Coverage-Bug: 208247880
Change-Id: Ic70f5f9e914492cb512095abb5687727b3bb3f09
2022-01-20 21:43:50 -08:00