Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
99fa73c0
Commit
99fa73c0
authored
1 year ago
by
Treehugger Robot
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Revert "[hotword] fix race condition in destroy()"" into main
parents
ccb49a09
9aa1db74
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/java/android/service/voice/AlwaysOnHotwordDetector.java
+24
-28
24 additions, 28 deletions
core/java/android/service/voice/AlwaysOnHotwordDetector.java
with
24 additions
and
28 deletions
core/java/android/service/voice/AlwaysOnHotwordDetector.java
+
24
−
28
View file @
99fa73c0
...
...
@@ -960,8 +960,8 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
mKeyphraseMetadata
=
new
KeyphraseMetadata
(
1
,
mText
,
fakeSupportedLocales
,
AlwaysOnHotwordDetector
.
RECOGNITION_MODE_VOICE_TRIGGER
);
}
notifyStateChangedLocked
();
}
notifyStateChanged
(
availability
);
}
/**
...
...
@@ -1371,8 +1371,8 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
mAvailability
=
STATE_INVALID
;
mIsAvailabilityOverriddenByTestApi
=
false
;
notifyStateChangedLocked
();
}
notifyStateChanged
(
STATE_INVALID
);
super
.
destroy
();
}
...
...
@@ -1402,8 +1402,6 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
*/
// TODO(b/281608561): remove the enrollment flow from AlwaysOnHotwordDetector
void
onSoundModelsChanged
()
{
boolean
notifyError
=
false
;
synchronized
(
mLock
)
{
if
(
mAvailability
==
STATE_INVALID
||
mAvailability
==
STATE_HARDWARE_UNAVAILABLE
...
...
@@ -1444,9 +1442,6 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
// calling stopRecognition where there is no started session.
Log
.
w
(
TAG
,
"Failed to stop recognition after enrollment update: code="
+
result
);
// Execute a refresh availability task - which should then notify of a change.
new
RefreshAvailabilityTask
().
execute
();
}
catch
(
Exception
e
)
{
Slog
.
w
(
TAG
,
"Failed to stop recognition after enrollment update"
,
e
);
if
(
CompatChanges
.
isChangeEnabled
(
SEND_ON_FAILURE_FOR_ASYNC_EXCEPTIONS
))
{
...
...
@@ -1455,14 +1450,14 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
+
Log
.
getStackTraceString
(
e
),
FailureSuggestedAction
.
RECREATE_DETECTOR
));
}
else
{
notifyError
=
true
;
updateAndNotifyStateChangedLocked
(
STATE_ERROR
)
;
}
return
;
}
}
}
if
(
notifyError
)
{
updateAndNotifyStateChanged
(
STATE_ERROR
);
// Execute a refresh availability task - which should then notify of a change.
new
RefreshAvailabilityTask
().
execute
(
);
}
}
...
...
@@ -1578,11 +1573,10 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
}
}
private
void
updateAndNotifyStateChanged
(
int
availability
)
{
synchronized
(
mLock
)
{
updateAvailabilityLocked
(
availability
);
}
notifyStateChanged
(
availability
);
@GuardedBy
(
"mLock"
)
private
void
updateAndNotifyStateChangedLocked
(
int
availability
)
{
updateAvailabilityLocked
(
availability
);
notifyStateChangedLocked
();
}
@GuardedBy
(
"mLock"
)
...
...
@@ -1596,17 +1590,17 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
}
}
private
void
notifyStateChanged
(
int
newAvailability
)
{
@GuardedBy
(
"mLock"
)
private
void
notifyStateChangedLocked
()
{
Message
message
=
Message
.
obtain
(
mHandler
,
MSG_AVAILABILITY_CHANGED
);
message
.
arg1
=
new
Availability
;
message
.
arg1
=
m
Availability
;
message
.
sendToTarget
();
}
@GuardedBy
(
"mLock"
)
private
void
sendUnknownFailure
(
String
failureMessage
)
{
synchronized
(
mLock
)
{
// update but do not call onAvailabilityChanged callback for STATE_ERROR
updateAvailabilityLocked
(
STATE_ERROR
);
}
// update but do not call onAvailabilityChanged callback for STATE_ERROR
updateAvailabilityLocked
(
STATE_ERROR
);
Message
.
obtain
(
mHandler
,
MSG_DETECTION_UNKNOWN_FAILURE
,
failureMessage
).
sendToTarget
();
}
...
...
@@ -1822,17 +1816,19 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
availability
=
STATE_KEYPHRASE_UNENROLLED
;
}
}
updateAndNotifyStateChangedLocked
(
availability
);
}
updateAndNotifyStateChanged
(
availability
);
}
catch
(
Exception
e
)
{
// Any exception here not caught will crash the process because AsyncTask does not
// bubble up the exceptions to the client app, so we must propagate it to the app.
Slog
.
w
(
TAG
,
"Failed to refresh availability"
,
e
);
if
(
CompatChanges
.
isChangeEnabled
(
SEND_ON_FAILURE_FOR_ASYNC_EXCEPTIONS
))
{
sendUnknownFailure
(
"Failed to refresh availability: "
+
Log
.
getStackTraceString
(
e
));
}
else
{
updateAndNotifyStateChanged
(
STATE_ERROR
);
synchronized
(
mLock
)
{
if
(
CompatChanges
.
isChangeEnabled
(
SEND_ON_FAILURE_FOR_ASYNC_EXCEPTIONS
))
{
sendUnknownFailure
(
"Failed to refresh availability: "
+
Log
.
getStackTraceString
(
e
));
}
else
{
updateAndNotifyStateChangedLocked
(
STATE_ERROR
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment