Commit Graph

403 Commits

Author SHA1 Message Date
Hani Kazmi
c7cdc8ca72 Merge "Migrate Bundle/Intent APIs to new, type checked, variants" 2022-07-05 10:32:47 +00:00
Hani Kazmi
4f221e5c51 Migrate Bundle/Intent APIs to new, type checked, variants
Part of go/safer-parcel. Follow up to ag/16639043. Migrates the following unsafe APIs:

* Parcel.readArray()
* Parcel.readParcelableArray()
* Bundle.getSerializable()
* Bundle.getParcelable()
* Bundle.getParcelableArrayList()
* Bundle.getParcelableArray()
* Bundle.getSparseParcelableArray()
* Intent.getSerializableExtra()
* Intent.getParcelableExtra()
* Intent.getParcelableArrayExtra()
* Intent.getParcelableArrayListExtra

Bug: 227458983
Test: m and presubmit pass
Change-Id: I72f206cb18eb5c669a7fff07a6845bed1c433fdb
2022-07-01 10:53:53 +00:00
Aleksandar Kiridzic
c023ecf0b9 speech: Update alternative spans API
As per API council’s advice, builders have been removed from both
AlternativeSpan and AlternativeSpans classes. The objects are now built
via a public constructor which takes parameters for all fields.

Tests are updated so they reflect the aforementioned changes.

Bug: 236591093
Test: CTS
Change-Id: Ie6bdb6d5167407e8d77eb148c343c263119e4863
2022-06-30 17:33:22 +01:00
Aleksandar Kiridzic
0fd5934060 speech: Design public value type for alternative spans
One class, AlternativeSpan, represents a list of alternative hypotheses
for a specific span of the recognized string. It's using only builtin
types (two ints for the range and a List<String> for the hypotheses) and
is Parcelable.

The other class, AlternativeSpans, represents a list of objects of the
first class for a single speech recognition result. It is also
Parcelable. An ArrayList<AlternativeSpans> will be added to the
SpeechRecognizer result bundle under key RESULTS_ALTERNATIVES.

Classes' public API methods are tested in the corresponding CTS.

Bug: 231575601
Test: CTS
Change-Id: If6e0c4e803b8fee39ac12a2568ac738dcc9e0564
2022-06-14 18:13:18 +01:00
Nate Myren
ad966ee71e Merge "Skip preflight RECORD_AUDIO in RecognitionService if FD provided" into tm-dev am: 39e65acd0a am: b59c67530e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18298904

Change-Id: I60b7133fd6d339ea462edf55bcbe4bf4bfddd9b6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-14 03:02:00 +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
Andrea Ambu
ae825ce308 Merge "speech: Allow isolated process to start ODSR" 2022-05-04 09:28:05 +00: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
27230bee0d speech: Allow isolated process to start ODSR
Bug: 230581623
Test: manual

Change-Id: I80cafe81b43c21ea2d626a86b4b13233c0c7fa92
2022-04-28 15:03:00 +01: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