summaryrefslogtreecommitdiffstats
path: root/services/voiceinteraction
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-06-15 13:35:16 -0700
committerDianne Hackborn <hackbod@google.com>2015-06-15 17:05:04 -0700
commitb8004ff3d4be75f2d57ac757cd0b983eed4ae9c0 (patch)
treeffde2923733fa16f9f7cc808a6eb239778963861 /services/voiceinteraction
parent285cb414eaab8543f6c857357849bfcf24b5974f (diff)
downloadframeworks_base-b8004ff3d4be75f2d57ac757cd0b983eed4ae9c0.zip
frameworks_base-b8004ff3d4be75f2d57ac757cd0b983eed4ae9c0.tar.gz
frameworks_base-b8004ff3d4be75f2d57ac757cd0b983eed4ae9c0.tar.bz2
Fix issue #21816660 (app standby), work on issue #20882522 (voice interact)
Issue #21816660: More app standby abuse prevention We now apply the same rules for deciding when an app has counted as active when the screen is on as when the screen is off; the only change this really means is that we don't immediately count foreground services as making an app active both screen on as well as the existing behavior for screen off. Also small fix to how we switch into voice interaction mode that guarantees we immediately switch to the screen on state. Issue #20882522 VI: voice interactor service not restarted This fixes some problems in the framework, allowing it to be correctly restarted (and rolled by to the default voice interactor if appropriate). There are still some problems in system UI that leave things broken in some cases. Also small fix to how we switch into voice interaction mode that guarantees we immediately switch to the screen on state. Change-Id: Ie4fd098a2f5174a2c94f36d30427fb2a9db3d835
Diffstat (limited to 'services/voiceinteraction')
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java109
1 files changed, 71 insertions, 38 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index b0fca95..fafe44a 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -853,7 +853,38 @@ public class VoiceInteractionManagerService extends SystemService {
PackageMonitor mPackageMonitor = new PackageMonitor() {
@Override
public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) {
- return super.onHandleForceStop(intent, packages, uid, doit);
+ if (DEBUG) Slog.d(TAG, "onHandleForceStop uid=" + uid + " doit=" + doit);
+
+ int userHandle = UserHandle.getUserId(uid);
+ ComponentName curInteractor = getCurInteractor(userHandle);
+ ComponentName curRecognizer = getCurRecognizer(userHandle);
+ boolean hit = false;
+ for (String pkg : packages) {
+ if (curInteractor != null && pkg.equals(curInteractor.getPackageName())) {
+ hit = true;
+ break;
+ } else if (curRecognizer != null
+ && pkg.equals(curRecognizer.getPackageName())) {
+ hit = true;
+ break;
+ }
+ }
+ if (hit && doit) {
+ // The user is force stopping our current interactor/recognizer.
+ // Clear the current settings and restore default state.
+ synchronized (VoiceInteractionManagerService.this) {
+ mSoundTriggerHelper.stopAllRecognitions();
+ if (mImpl != null) {
+ mImpl.shutdownLocked();
+ mImpl = null;
+ }
+ setCurInteractor(null, userHandle);
+ setCurRecognizer(null, userHandle);
+ initForUser(userHandle);
+ switchImplementationIfNeededLocked(true);
+ }
+ }
+ return hit;
}
@Override
@@ -865,51 +896,53 @@ public class VoiceInteractionManagerService extends SystemService {
int userHandle = getChangingUserId();
if (DEBUG) Slog.d(TAG, "onSomePackagesChanged user=" + userHandle);
- ComponentName curInteractor = getCurInteractor(userHandle);
- ComponentName curRecognizer = getCurRecognizer(userHandle);
- if (curRecognizer == null) {
- // Could a new recognizer appear when we don't have one pre-installed?
- if (anyPackagesAppearing()) {
- curRecognizer = findAvailRecognizer(null, userHandle);
- if (curRecognizer != null) {
- setCurRecognizer(curRecognizer, userHandle);
+ synchronized (VoiceInteractionManagerService.this) {
+ ComponentName curInteractor = getCurInteractor(userHandle);
+ ComponentName curRecognizer = getCurRecognizer(userHandle);
+ if (curRecognizer == null) {
+ // Could a new recognizer appear when we don't have one pre-installed?
+ if (anyPackagesAppearing()) {
+ curRecognizer = findAvailRecognizer(null, userHandle);
+ if (curRecognizer != null) {
+ setCurRecognizer(curRecognizer, userHandle);
+ }
}
- }
- return;
- }
-
- if (curInteractor != null) {
- int change = isPackageDisappearing(curInteractor.getPackageName());
- if (change == PACKAGE_PERMANENT_CHANGE) {
- // The currently set interactor is permanently gone; fall back to
- // the default config.
- setCurInteractor(null, userHandle);
- setCurRecognizer(null, userHandle);
- initForUser(userHandle);
return;
}
- change = isPackageAppearing(curInteractor.getPackageName());
- if (change != PACKAGE_UNCHANGED) {
- // If current interactor is now appearing, for any reason, then
- // restart our connection with it.
- if (mImpl != null && curInteractor.getPackageName().equals(
- mImpl.mComponent.getPackageName())) {
- switchImplementationIfNeededLocked(true);
+ if (curInteractor != null) {
+ int change = isPackageDisappearing(curInteractor.getPackageName());
+ if (change == PACKAGE_PERMANENT_CHANGE) {
+ // The currently set interactor is permanently gone; fall back to
+ // the default config.
+ setCurInteractor(null, userHandle);
+ setCurRecognizer(null, userHandle);
+ initForUser(userHandle);
+ return;
+ }
+
+ change = isPackageAppearing(curInteractor.getPackageName());
+ if (change != PACKAGE_UNCHANGED) {
+ // If current interactor is now appearing, for any reason, then
+ // restart our connection with it.
+ if (mImpl != null && curInteractor.getPackageName().equals(
+ mImpl.mComponent.getPackageName())) {
+ switchImplementationIfNeededLocked(true);
+ }
}
+ return;
}
- return;
- }
- // There is no interactor, so just deal with a simple recognizer.
- int change = isPackageDisappearing(curRecognizer.getPackageName());
- if (change == PACKAGE_PERMANENT_CHANGE
- || change == PACKAGE_TEMPORARY_CHANGE) {
- setCurRecognizer(findAvailRecognizer(null, userHandle), userHandle);
+ // There is no interactor, so just deal with a simple recognizer.
+ int change = isPackageDisappearing(curRecognizer.getPackageName());
+ if (change == PACKAGE_PERMANENT_CHANGE
+ || change == PACKAGE_TEMPORARY_CHANGE) {
+ setCurRecognizer(findAvailRecognizer(null, userHandle), userHandle);
- } else if (isPackageModified(curRecognizer.getPackageName())) {
- setCurRecognizer(findAvailRecognizer(curRecognizer.getPackageName(),
- userHandle), userHandle);
+ } else if (isPackageModified(curRecognizer.getPackageName())) {
+ setCurRecognizer(findAvailRecognizer(curRecognizer.getPackageName(),
+ userHandle), userHandle);
+ }
}
}
};