Commit Graph

397 Commits

Author SHA1 Message Date
Nate Myren
ee4e20c576 Merge "Skip preflight RECORD_AUDIO in RecognitionService if FD provided" into tm-dev am: 39e65acd0a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18298904

Change-Id: I114a3768be4473aa14801f72f9b32cf760c57b0e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-14 02:34:28 +00:00
Nate Myren
ddd89a86e2 Skip preflight RECORD_AUDIO in RecognitionService if FD provided
If a file descriptor is provided to a recognitionService using the
EXTRA_AUDIO_SOURCE option, then do not make a preflight RECORD_AUDIO
check

Test: manual
Bug: 226969470
Change-Id: Ibc9fa378f5375a38922f1791c13600a3a5ab55f1
2022-05-10 16:25:06 -07:00
Treehugger Robot
b4137f0748 Merge "speech: Add andreaambu@ to OWNERS" am: 72c2c6e07a am: 2af20d0f3e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2079618

Change-Id: I838d0dfd2a399a84940b19dbcbb915de8fedd164
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-29 19:45:52 +00:00
Andrea Ambu
b2694bfd02 speech: Add andreaambu@ to OWNERS
Test: n/a

Change-Id: Id3bb4ec310573d822ed87fb7d86532349df2c21f
2022-04-28 14:40:10 +01:00
Andrea Ambu
36522fa46d speech: Remove @Deprecated fields after rename
These APIs are new in T, they have new fields with new names now.

Bug: 225420491
Test: atest
Change-Id: Ia303a6e365c77df47578edd9ce6f7d14241d7cf0
2022-03-24 16:16:57 +00:00
Andrea Ambu
3d9a4ea5a7 speech: Add online languages to RecognitionSupport
This is based on the feedback from the speech recognition team: we need to distinguish information for online vs offline classifiers.

The deprecated APIs are due to be removed soon: b/225420491

Bug: 204189031
Test: atest
Change-Id: I48e413c13480df0c150cd7663e9d54196149b024
2022-03-21 19:15:07 +00:00
Qi Cao
4d897c6ad0 Update RecognitionListener JavaDoc to link to the right extra.
Fix: 220247022

Test: Only JavaDoc changes. No test needed.
Change-Id: I1ea9673da0b18efb6432f37e9aacb88ffecbca37
(cherry picked from commit 311e617aac)
2022-02-18 06:21:40 +00:00
Dharmesh Mokani
f623383ff1 Merge "Added public extras for audio injection, biasing, formatting, masking offensive words. Reworded existing extras for segmented session feature." 2022-02-17 20:54:40 +00:00
Andrea Ambu
c015c5be72 speech: Prefix trigger event with "on"
Bug: 216474485
Fix: 216474485
Test: atest
Change-Id: I675ab584c3bd063fb8550554e4c60e9e523fb7a8
2022-02-16 11:16:57 +00:00
Qi Cao
8c3cd43e0b Added public extras for audio injection, biasing, formatting, masking
offensive words. Reworded existing extras for segmented session feature.

Reference doc: go/recognizer-intent-public-doc
Bug: 218705986

Test: Only adding strings and doc. No test needed.
Change-Id: I929ddfd59ea17c9ed4cdc22a9ddb90dcc409c40b
2022-02-15 10:49:28 -08:00
Shubham Dubey
49f70ea34f Fix link for running support check in executor for speech
Following commit I9f1f2f6657b4c268546e68c1c2d23b6ad06b9c46, updating the link to fix broken sdk builds

Fix: 219636671

Change-Id: Ia9ffc93f1ad0f5dfd9275bea21cf7f7db182024d
2022-02-15 07:39:01 +00:00
Andrea Ambu
604cfdf873 speech: Run support check in Executor
Bug: 216475054
Test: atest
Change-Id: I9f1f2f6657b4c268546e68c1c2d23b6ad06b9c46
2022-02-14 17:52:26 +00:00
Andrea Ambu
3d349876fb speech: Fix builder plurality
Bug: 216474107
Test: atest
Change-Id: Ib804f70db5d9e617b36f4f2eb4bd2ed61a4f185b
2022-02-11 15:36:26 +00:00
Andrea Ambu
515bbcf6aa speech: Connect on model check/download trigger
Bug: 204189031
Test: atest
Change-Id: I9a3a0aa1b9a955dcb5f7fc365c2f0511a7bba7a0
2022-02-09 14:30:24 +00:00
Andrea Ambu
5230f95d5f Revert^2 "speech: Allow long speech sessions"
cd49383e17

Test: atest
Change-Id: I8b743e39172e307480d4f4ba6ec21769135c9da8
2022-02-08 16:11:04 +00:00
Shubham Dubey
cd49383e17 Revert "speech: Allow long speech sessions"
Revert "speech: Allow long speech sessions"

Revert submission 16691164-os-long-form

Reason for revert: Breaking OnDeviceRecognitionServiceTest
BUG:218303318

Reverted Changes:
I348fbcd70:speech: Allow long speech sessions
I62adfa7ac:speech: Allow long speech sessions

Change-Id: Ice4435288adb4472538c7426a4b68e9f75a2a2bc
2022-02-07 18:30:27 +00:00
Andrea Ambu
950a0f3e78 speech: Allow long speech sessions
See go/one-speech-long-form

Bug: 204189031
Cts-Coverage-Bug: 204189031
Test: atest
Change-Id: I62adfa7aca5e8df32253c141bd4dd7bc7e4fad3c
2022-02-04 11:15:50 +00:00
TreeHugger Robot
ce65b04d56 Merge "Revert "Revert "Migrate unsafe parcel APIs in framework-minus-apex""" 2022-01-20 11:33:39 +00:00
Bernardo Rufino
1a5cb387d6 Revert "Revert "Migrate unsafe parcel APIs in framework-minus-apex""
This reverts commit 331be9a643.

Reintroducing ag/16366278 since it seems unrelated to b/214053959 (more details on b/214053959#comment55).

Original commit message:

Migrate unsafe parcel APIs in framework-minus-apex

Migrate the following unsafe parcel APIs in framework-minus-apex:
* Parcel.readSerializable()
* Parcel.readArrayList()
* Parcel.readList()
* Parcel.readParcelable()
* Parcel.readParcelableList()
* Parcel.readSparseArray()

This CL was generated by applying lint fixes that infer the expected
type from the caller code and provide that as the type parameter
(ag/16365240).

A few observations:
* In some classes we couldn't migrate because the class also belonged to
another build module whose min SDK wasn't current (as is the case for
framework-minus-apex), hence I suppressed the lint check
(since I'll eventually submit the lint check to the tree).
* In some cases, I needed to do the cast in
https://stackoverflow.com/a/1080525/5765705 to make the compiler happy
since there isn't another way of providing a class of type
Class<MyClassWithGenerics<T>>.
* In the readSerializable() case, the new API also requires the class
loader, that was inferred to by InferredClass.class.getClassLoader().
* Note that automatic formatting and import rely on running hooked up
to the IDE, which wasn't the case here.

Bug: 195622897
Change-Id: I272432e6e082a973f7a50492ec35d79c2b577c93
Test: TH passes
2022-01-19 11:13:18 +00:00
Andrea Ambu
60aab5f1fa Merge "speech: Add api to check request is supported" 2022-01-19 09:34:02 +00:00
Andrea Ambu
d15616a547 speech: Add api to check request is supported
Bug: 204189031
CTS-Coverage-Bug: 208776893
Test: atest, new tests TBD
Change-Id: Id3d7df47f52efc31227edb577db44b9e4ca04265
2022-01-18 14:30:17 +00:00
Bernardo Rufino
331be9a643 Revert "Migrate unsafe parcel APIs in framework-minus-apex"
This reverts commit 90bb3709dc.

Reason for revert: b/214053959

Change-Id: Ic271bab1d3eaf677a5989dda9deb944ee2ad6850
2022-01-12 17:44:44 +00:00
Bernardo Rufino
90bb3709dc Migrate unsafe parcel APIs in framework-minus-apex
Migrate the following unsafe parcel APIs in framework-minus-apex:
* Parcel.readSerializable()
* Parcel.readArrayList()
* Parcel.readList()
* Parcel.readParcelable()
* Parcel.readParcelableList()
* Parcel.readSparseArray()

This CL was generated by applying lint fixes that infer the expected
type from the caller code and provide that as the type parameter
(ag/16365240).

A few observations:
* In some classes we couldn't migrate because the class also belonged to
another build module whose min SDK wasn't current (as is the case for
framework-minus-apex), hence I suppressed the lint check
(since I'll eventually submit the lint check to the tree).
* In some cases, I needed to do the cast in
https://stackoverflow.com/a/1080525/5765705 to make the compiler happy
since there isn't another way of providing a class of type
Class<MyClassWithGenerics<T>>.
* In the readSerializable() case, the new API also requires the class
loader, that was inferred to by InferredClass.class.getClassLoader().
* Note that automatic formatting and import rely on running hooked up
to the IDE, which wasn't the case here.

Bug: 195622897
Test: TH passes
Change-Id: I11a27b9bdab7959ee86e90aa1e1cbebd7aaf883c
2021-12-15 18:21:38 +00:00
Nate Myren
922e104be4 Do not fail Recognition on MODE_IGNORED for preflight
Recognition will fail upon attempting to open the microphone, if it is
accessed.

Bug: 197465285
Test: manual
Change-Id: I83f1ae30295caf576eb7a6f0191313cb789f1d52
2021-09-15 16:28:44 +00:00
Nate Myren
b1be18a806 Do not fail Recognition on MODE_IGNORED for preflight
Recognition will fail upon attempting to open the microphone, if it is
accessed.

Bug: 197465285
Test: manual
Change-Id: I83f1ae30295caf576eb7a6f0191313cb789f1d52
2021-09-10 13:36:22 -07:00
TreeHugger Robot
3a2373352f Merge "Only check downstream permissions in preflight in RecognitionService" into sc-dev 2021-07-15 17:44:56 +00:00
Nate Myren
861ee7a8b7 Only check downstream permissions in preflight in RecognitionService
Ensure that, in the preflight permission check, RecognitionService does
not check the service's own permissions. These will be checked if the
RecognitionService tries to access the mic

Fixes: 193111794
Test: manual
Change-Id: I172849f2e0368f9601dc298e6cf96d7a52219e5a
2021-07-12 16:17:17 -07:00
Andrea Ambu
cc204c7e2e Merge "speech: Add lenient SpeechRecognizer instantiation" into sc-dev 2021-07-08 17:40:10 +00:00
Andrea Ambu
6a630f8e00 speech: Add lenient SpeechRecognizer instantiation
This change allows to test on-device listening via a temporary
recognizer even in devices that do no support on device recognition.

It moves the failure from the static
SpeechRecognizer#createOnDeviceSpeechRecognizer to the instance #startListening.

fail-on-listening

Bug: 192586674
Test: atest CtsVoiceRecognitionTestCases with both config and no config
Change-Id: Id722f4e5167132b76b4fbd5ea0c2ef7d19f15909
2021-07-08 17:29:12 +00:00
Nate Myren
6c7dac39d5 Avoid creating Recognition Callback if preflight fails
Only create the callback (and call onCancel) if the preflight permission
check succeeds.

Bug: 190848702
Test: manual
Change-Id: Ie7155348213e86dea0a9080a9c4ed53144f91c6f
2021-07-02 13:32:34 -07:00
Nate Myren
bae80e0db8 Merge "Cancel RecognitionService if permission check fails" into sc-dev 2021-07-02 16:06:15 +00:00
Nate Myren
6978614aeb Cancel RecognitionService if permission check fails
This ensures that, when platform checks fail, the RecognitionService is
notified that it should cancel recognition

Fixes: 190848702
Test: manual
Change-Id: I5073728e544a47f386824ca0a034e149661d864a
2021-07-01 17:24:21 -07:00
Nate Myren
0b234cf922 Try to finish data delivery in onDestroy for RecognitionService
Test: manual
Fixes: 192275399
Change-Id: I56b2e59f80da3e4c6f59236637ec32c1aff1a50a
2021-07-01 23:21:51 +00:00
Nate Myren
050f400b3f Properly check for SDK before nullifying attribution tag
Also adds @SuppressLint to RecognitionService#createContext

Fixes: 190759697
Test: manual
Change-Id: I8ad14f93f86285127d5d2674b0f9a4963b03c933
2021-06-15 17:04:34 +00:00
TreeHugger Robot
c3467536bb Merge "speech: Update createSpeechRecognizer javadoc" into sc-dev 2021-06-14 14:13:23 +00:00
Svet Ganov
97bf4e0083 Don don't blame if attr ctx created
Test: manual

bug: 190657833

Change-Id: Id7c65999baa294a53765f5d17f77a7903611e85a
2021-06-12 04:49:50 +00:00
Andrea Ambu
df709e0d1b speech: Update createSpeechRecognizer javadoc
SpeechRecognizer#createSpeechRecognizer(Context, ComponentName) should
be called only with ComponentNames that are actually mapped in the
running environment.

This update documents how to check the ComponentName is acutally mapped
to RecognitionService.

Bug: 187176179
Test: n/a javadoc change only
Change-Id: Icbf1595f613d6f341b84879122e5eefce6c0fb4a
2021-06-07 14:05:48 +01:00
Svet Ganov
2eebf92965 Switch media fw permissions checks to AttributionSource
Attribution source is the abstraction to capture the data
flows for private data across apps. Checking permissions
for an attribution source does this for all apps in the
chain that would receive the data as well as the relevant
app ops are checked/noted/started as needed.

Teach speech recognition service about attribution
chains. If an implementation does nothing the OS
would enforce permisisons and do blame as always.
This apporach leads to double blaming and doesn't
support attribition chains where app calls into
the default recognizer which calls into the on
device recognizer (this nests recursively). If the
implementer takes advantage of the attribution chain
mechanims the permissions for the entire chain are
checked at mic access time and all apps are blamed
only once.

Fixed a few bugs around finishing ops for attribution
chains. Also ensured that any app death in a started
attribution chain would lead to finishing the op for
this app

bug: 158792096

Test: (added tests for speech reco)
      atest CtsMediaTestCases
      atest CtsPermissionTestCases
      atest CtsPermission2TestCases
      atest CtsPermission3TestCases
      atest CtsPermission4TestCases
      atest CtsPermission5TestCases
      atest CtsAppOpsTestCases
      atest CtsAppOps2TestCases

Merged-In: Ic92c7adc14bd2d135ac13b96f17a1b393dd562e4

Change-Id: Ic92c7adc14bd2d135ac13b96f17a1b393dd562e4
2021-06-01 23:43:29 +00:00
Andrea Ambu
feb478eae5 speech: TEST_MAPPING CtsVoiceRecognitionTestCases
ag/14530956 broke presubmit (b/188784537) because
CtsVoiceRecognitionTestCases did not run.

This makes them run for any change to core/java/android/speech

Bug: 188784537
Test: presubmitting this CL
Change-Id: I9e65abad8d242e5bb87fabc3523909bb14eed3c1
2021-05-21 11:47:07 +01:00
Andrea Ambu
40ef504bc8 speech: Add #isOnDeviceRecognitionAvailable
Bug: 188055926
Test: CtsVoiceRecognitionTestCases
Change-Id: I6ba1d083005782beedb28313077af041af2ae975
2021-05-18 19:04:46 +00:00
Nate Myren
dc0bd5b516 Add information to EXTRA_AUDIO_INJECT_SOURCE
indicate the data for injection should be a URI to an audio resource.

Fixes: 186411622
Test: none
Change-Id: I70b650c8fb8fa6de648c03df3c5464a570222fee
2021-04-26 11:47:37 -07:00
Sergey Volnov
04fa253482 Change attribution integration points for SpeechRecognizer.
I've deleted the extra attribution for now just to fix the bug asap, but
we need a long-term sync to make sure attribution works properly. For
both cases when the RS app decides to integrate with the new attribution
framework OR decides to ignore it.

Bug: 184963112
Test: atest CtsVoiceRecognitionTestCases
Change-Id: I20bd8174c1a188da6c5af55cdd3bebee8a638d2d
2021-04-23 16:16:39 +01:00
Nate Myren
e5a10560c8 Merge "Add EXTRA_AUDIO_INJECT_SOURCE to RecognizerIntent" into sc-dev 2021-04-21 15:30:07 +00:00
Nate Myren
1fde398f7f Add EXTRA_AUDIO_INJECT_SOURCE to RecognizerIntent
Add a constant to signify that the caller of a RecognitionService has
opened an audio stream for the service

Bug: 185936177
Test: build
Change-Id: Id8da84714fef547d2143457c2ad1c0b631e40741
2021-04-20 22:12:58 +00:00
Sergey Volnov
818ace5fe7 Add a comment mentioning that errors might be unbundled, to improve
backwards compatibility story.

Bug: 183427999
Test: N/A, comment change.
Change-Id: I1f583fe31c9edccada510f9a0ab2e333cc62df08
2021-04-19 16:57:10 +01:00
Sergey Volnov
8aeb16cd18 Introduce additional error codes for better language handling.
Additionally, address minor feedback from API council regarding errors
and documentation.

Test: N/A, adding constants
Bug: 176578753
Bug: 183427999
Change-Id: I46358373e8d562cb829ff44232252d26bb5acda4
2021-04-09 11:31:23 +01:00
Alex Agranovich
a95fc29ec6 Fix TextToSpeech system connection error handling
This CL fixes client listener notification upon engine binding error.
In addition fixes logs verbosity for errors caused by calls on dead client.

Bug: 183085464
Test: atest CtsSpeechTestCases
Change-Id: Ic67e97befd87f841430a53993ae5c79d81a0f6ba
2021-04-07 12:13:48 +00:00
Sergey Volnov
d9c6b16308 Merge "Add a comment to speech recognition service requiring clients targeting Android 11 to specify a <queries> tag." am: 8c6820048d am: 507ca766ac am: 9a4b4693f6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1660358

Change-Id: I4fb577b783a1fcc7b4817fc6fba9d8c56e14e5b5
2021-04-01 11:35:08 +00:00
Sergey Volnov
8c6820048d Merge "Add a comment to speech recognition service requiring clients targeting Android 11 to specify a <queries> tag." 2021-04-01 09:26:27 +00:00
Sergey Volnov
f16e2b1d07 Add a comment to speech recognition service requiring clients targeting
Android 11 to specify a <queries> tag.

Bug: 173748514
Test: N/A
Change-Id: If70dde1bff5d79e258e3759a1f9027d51de6b441
2021-03-31 21:20:21 +01:00