summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-06-19 01:01:36 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-19 01:01:38 +0000
commit0348ba2e2303d9dce57a6b5d19cc47ecc5089afe (patch)
tree1fa68bfb40b35b9c25653836164adf3004d224e6 /services
parent00fac63575349df5ed8c399b83f1f9c7199ff070 (diff)
parentb6683c428698105f715985a96066192aa62e9f53 (diff)
downloadframeworks_base-0348ba2e2303d9dce57a6b5d19cc47ecc5089afe.zip
frameworks_base-0348ba2e2303d9dce57a6b5d19cc47ecc5089afe.tar.gz
frameworks_base-0348ba2e2303d9dce57a6b5d19cc47ecc5089afe.tar.bz2
Merge "Fix issue #20494208: Go out of device idle when headset button is pressed" into mnc-dev
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/DeviceIdleController.java46
-rw-r--r--services/core/java/com/android/server/am/BatteryStatsService.java4
-rw-r--r--services/core/java/com/android/server/audio/MediaFocusControl.java10
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java17
4 files changed, 59 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index 8dd087a..82b334a 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -45,6 +45,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManagerInternal;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -487,7 +488,7 @@ public class DeviceIdleController extends SystemService
mLocalPowerManager.setDeviceIdleMode(true);
try {
mNetworkPolicyManager.setDeviceIdleMode(true);
- mBatteryStats.noteDeviceIdleMode(true, false, false);
+ mBatteryStats.noteDeviceIdleMode(true, null, Process.myUid());
} catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent, UserHandle.ALL);
@@ -496,18 +497,19 @@ public class DeviceIdleController extends SystemService
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
- mBatteryStats.noteDeviceIdleMode(false, false, false);
+ mBatteryStats.noteDeviceIdleMode(false, null, Process.myUid());
} catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent, UserHandle.ALL);
} break;
case MSG_REPORT_ACTIVE: {
- boolean fromMotion = msg.arg1 != 0;
+ String activeReason = (String)msg.obj;
+ int activeUid = msg.arg1;
boolean needBroadcast = msg.arg2 != 0;
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
- mBatteryStats.noteDeviceIdleMode(false, !fromMotion, fromMotion);
+ mBatteryStats.noteDeviceIdleMode(false, activeReason, activeUid);
} catch (RemoteException e) {
}
if (needBroadcast) {
@@ -578,6 +580,12 @@ public class DeviceIdleController extends SystemService
}
}
+ @Override public void exitIdle(String reason) {
+ getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER,
+ null);
+ exitIdleInternal(reason);
+ }
+
@Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
DeviceIdleController.this.dump(fd, pw, args);
}
@@ -818,6 +826,12 @@ public class DeviceIdleController extends SystemService
}
}
+ public void exitIdleInternal(String reason) {
+ synchronized (this) {
+ becomeActiveLocked(reason, Binder.getCallingUid());
+ }
+ }
+
void updateDisplayLocked() {
mCurDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
// We consider any situation where the display is showing something to be it on,
@@ -830,7 +844,7 @@ public class DeviceIdleController extends SystemService
becomeInactiveIfAppropriateLocked();
} else if (screenOn) {
mScreenOn = true;
- becomeActiveLocked("screen");
+ becomeActiveLocked("screen", Process.myUid());
}
}
@@ -841,21 +855,21 @@ public class DeviceIdleController extends SystemService
becomeInactiveIfAppropriateLocked();
} else if (charging) {
mCharging = charging;
- becomeActiveLocked("charging");
+ becomeActiveLocked("charging", Process.myUid());
}
}
- void scheduleReportActiveLocked(boolean fromMotion) {
- Message msg = mHandler.obtainMessage(MSG_REPORT_ACTIVE, fromMotion ? 1 : 0,
- mState == STATE_IDLE ? 1 : 0);
+ void scheduleReportActiveLocked(String activeReason, int activeUid) {
+ Message msg = mHandler.obtainMessage(MSG_REPORT_ACTIVE, activeUid,
+ mState == STATE_IDLE ? 1 : 0, activeReason);
mHandler.sendMessage(msg);
}
- void becomeActiveLocked(String reason) {
- if (DEBUG) Slog.i(TAG, "becomeActiveLocked, reason = " + reason);
+ void becomeActiveLocked(String activeReason, int activeUid) {
+ if (DEBUG) Slog.i(TAG, "becomeActiveLocked, reason = " + activeReason);
if (mState != STATE_ACTIVE) {
- EventLogTags.writeDeviceIdle(STATE_ACTIVE, reason);
- scheduleReportActiveLocked(false);
+ EventLogTags.writeDeviceIdle(STATE_ACTIVE, activeReason);
+ scheduleReportActiveLocked(activeReason, activeUid);
mState = STATE_ACTIVE;
mInactiveTimeout = mConstants.INACTIVE_TIMEOUT;
mNextIdlePendingDelay = 0;
@@ -896,7 +910,7 @@ public class DeviceIdleController extends SystemService
if ((now+mConstants.MIN_TIME_TO_ALARM) > mAlarmManager.getNextWakeFromIdleTime()) {
// Whoops, there is an upcoming alarm. We don't actually want to go idle.
if (mState != STATE_ACTIVE) {
- becomeActiveLocked("alarm");
+ becomeActiveLocked("alarm", Process.myUid());
}
return;
}
@@ -954,7 +968,7 @@ public class DeviceIdleController extends SystemService
// state to wait again for no motion. Note that we only monitor for significant
// motion after moving out of the inactive state, so no need to worry about that.
if (mState != STATE_ACTIVE) {
- scheduleReportActiveLocked(true);
+ scheduleReportActiveLocked("motion", Process.myUid());
mState = STATE_ACTIVE;
mInactiveTimeout = mConstants.MOTION_INACTIVE_TIMEOUT;
EventLogTags.writeDeviceIdle(mState, "motion");
@@ -1240,7 +1254,7 @@ public class DeviceIdleController extends SystemService
synchronized (this) {
if (!mIdleDisabled) {
mIdleDisabled = true;
- becomeActiveLocked("disabled");
+ becomeActiveLocked("disabled", Process.myUid());
pw.println("Idle mode disabled");
}
}
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index b3189cd..d30a101 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -766,10 +766,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
}
@Override
- public void noteDeviceIdleMode(boolean enabled, boolean fromActive, boolean fromMotion) {
+ public void noteDeviceIdleMode(boolean enabled, String activeReason, int activeUid) {
enforceCallingPermission();
synchronized (mStats) {
- mStats.noteDeviceIdleModeLocked(enabled, fromActive, fromMotion);
+ mStats.noteDeviceIdleModeLocked(enabled, activeReason, activeUid);
}
}
diff --git a/services/core/java/com/android/server/audio/MediaFocusControl.java b/services/core/java/com/android/server/audio/MediaFocusControl.java
index 4ccb5ad..f72b598 100644
--- a/services/core/java/com/android/server/audio/MediaFocusControl.java
+++ b/services/core/java/com/android/server/audio/MediaFocusControl.java
@@ -46,10 +46,12 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
+import android.os.IDeviceIdleController;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.speech.RecognizerIntent;
@@ -1086,6 +1088,14 @@ public class MediaFocusControl implements OnFinished {
voiceIntent = new Intent(android.speech.RecognizerIntent.ACTION_WEB_SEARCH);
Log.i(TAG, "voice-based interactions: about to use ACTION_WEB_SEARCH");
} else {
+ IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface(
+ ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
+ if (dic != null) {
+ try {
+ dic.exitIdle("voice-search");
+ } catch (RemoteException e) {
+ }
+ }
voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE,
isLocked && mKeyguardManager.isKeyguardSecure());
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 6fb9a5c..bd545df 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -56,6 +56,7 @@ import android.os.Debug;
import android.os.FactoryTest;
import android.os.Handler;
import android.os.IBinder;
+import android.os.IDeviceIdleController;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
@@ -2734,6 +2735,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (!keyguardOn) {
voiceIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
} else {
+ IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface(
+ ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
+ if (dic != null) {
+ try {
+ dic.exitIdle("voice-search");
+ } catch (RemoteException e) {
+ }
+ }
voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, true);
}
@@ -5192,6 +5201,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
void launchVoiceAssistWithWakeLock(boolean keyguardActive) {
+ IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface(
+ ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
+ if (dic != null) {
+ try {
+ dic.exitIdle("voice-search");
+ } catch (RemoteException e) {
+ }
+ }
Intent voiceIntent =
new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, keyguardActive);