From: Philip P. Moltmann Date: Wed, 11 Apr 2018 16:23:19 +0000 (-0700) Subject: Properly disconnect after skipping an operation. X-Git-Tag: android-x86-9.0-r1~142^2~33^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=09dd8c47d81abc486161194f82fb1d3fafed349a;p=android-x86%2Fframeworks-base.git Properly disconnect after skipping an operation. If we skip an operation we used to just return. This lead to the service staying connected, holding the wakelock and consuming power. Hence after we skip an operation we need to check if we can disconnect the service, basically treating skipping an operation similar failing to execute the operation. Fixes: 77766977 Test: Detected music via sound trigger service and triggered dropping of operations Change-Id: Ia837d628193b3a5c2763f4aae666193d624b6d7f --- diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java index 11609435205f..cd524a517376 100644 --- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java @@ -926,25 +926,24 @@ public class SoundTriggerService extends SystemService { Slog.w(TAG, mPuuid + ": Dropped operation as too many operations were " + "run in last 24 hours"); } - return; - } - - mNumOps.addOp(currentTime); + } else { + mNumOps.addOp(currentTime); - // Find a free opID - int opId = mNumTotalOpsPerformed; - do { - mNumTotalOpsPerformed++; - } while (mRunningOpIds.contains(opId)); + // Find a free opID + int opId = mNumTotalOpsPerformed; + do { + mNumTotalOpsPerformed++; + } while (mRunningOpIds.contains(opId)); - // Run OP - try { - if (DEBUG) Slog.v(TAG, mPuuid + ": runOp " + opId); + // Run OP + try { + if (DEBUG) Slog.v(TAG, mPuuid + ": runOp " + opId); - op.run(opId, mService); - mRunningOpIds.add(opId); - } catch (Exception e) { - Slog.e(TAG, mPuuid + ": Could not run operation " + opId, e); + op.run(opId, mService); + mRunningOpIds.add(opId); + } catch (Exception e) { + Slog.e(TAG, mPuuid + ": Could not run operation " + opId, e); + } } // Unbind from service if no operations are left (i.e. if the operation failed)