summaryrefslogtreecommitdiffstats
path: root/services/java/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android')
-rw-r--r--services/java/com/android/server/EventLogTags.logtags6
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java28
-rw-r--r--services/java/com/android/server/power/PowerManagerService.java63
-rw-r--r--services/java/com/android/server/wm/WindowAnimator.java1
-rwxr-xr-xservices/java/com/android/server/wm/WindowManagerService.java17
5 files changed, 80 insertions, 35 deletions
diff --git a/services/java/com/android/server/EventLogTags.logtags b/services/java/com/android/server/EventLogTags.logtags
index 840e006..0fe66fc 100644
--- a/services/java/com/android/server/EventLogTags.logtags
+++ b/services/java/com/android/server/EventLogTags.logtags
@@ -52,12 +52,12 @@ option java_package com.android.server
# NotificationManagerService.java
# ---------------------------
# when a NotificationManager.notify is called
-2750 notification_enqueue (pkg|3),(id|1|5),(tag|3),(notification|3)
+2750 notification_enqueue (pkg|3),(id|1|5),(tag|3),(userid|1|5),(notification|3)
# when someone tries to cancel a notification, the notification manager sometimes
# calls this with flags too
-2751 notification_cancel (pkg|3),(id|1|5),(tag|3),(required_flags|1),(forbidden_flags|1)
+2751 notification_cancel (pkg|3),(id|1|5),(tag|3),(userid|1|5),(required_flags|1),(forbidden_flags|1)
# when someone tries to cancel all of the notifications for a particular package
-2752 notification_cancel_all (pkg|3),(required_flags|1),(forbidden_flags|1)
+2752 notification_cancel_all (pkg|3),(userid|1|5),(required_flags|1),(forbidden_flags|1)
# ---------------------------
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 09a606e..4a54efe 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -916,7 +916,7 @@ public class NotificationManagerService extends INotificationManager.Stub
// behalf of the download manager without affecting other apps.
if (!pkg.equals("com.android.providers.downloads")
|| Log.isLoggable("DownloadManager", Log.VERBOSE)) {
- EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag,
+ EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag, userId,
notification.toString());
}
@@ -1207,7 +1207,7 @@ public class NotificationManagerService extends INotificationManager.Stub
*/
private void cancelNotification(String pkg, String tag, int id, int mustHaveFlags,
int mustNotHaveFlags, boolean sendDelete, int userId) {
- EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL, pkg, id, tag,
+ EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL, pkg, id, tag, userId,
mustHaveFlags, mustNotHaveFlags);
synchronized (mNotificationList) {
@@ -1231,20 +1231,34 @@ public class NotificationManagerService extends INotificationManager.Stub
}
/**
+ * Determine whether the userId applies to the notification in question, either because
+ * they match exactly, or one of them is USER_ALL (which is treated as a wildcard).
+ */
+ private boolean notificationMatchesUserId(NotificationRecord r, int userId) {
+ return
+ // looking for USER_ALL notifications? match everything
+ userId == UserHandle.USER_ALL
+ // a notification sent to USER_ALL matches any query
+ || r.userId == UserHandle.USER_ALL
+ // an exact user match
+ || r.userId == userId;
+ }
+
+ /**
* Cancels all notifications from a given package that have all of the
* {@code mustHaveFlags}.
*/
boolean cancelAllNotificationsInt(String pkg, int mustHaveFlags,
int mustNotHaveFlags, boolean doit, int userId) {
- EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL_ALL, pkg, mustHaveFlags,
- mustNotHaveFlags);
+ EventLog.writeEvent(EventLogTags.NOTIFICATION_CANCEL_ALL, pkg, userId,
+ mustHaveFlags, mustNotHaveFlags);
synchronized (mNotificationList) {
final int N = mNotificationList.size();
boolean canceledSomething = false;
for (int i = N-1; i >= 0; --i) {
NotificationRecord r = mNotificationList.get(i);
- if (userId != UserHandle.USER_ALL && r.userId != userId) {
+ if (!notificationMatchesUserId(r, userId)) {
continue;
}
if ((r.notification.flags & mustHaveFlags) != mustHaveFlags) {
@@ -1322,7 +1336,7 @@ public class NotificationManagerService extends INotificationManager.Stub
for (int i=N-1; i>=0; i--) {
NotificationRecord r = mNotificationList.get(i);
- if (r.userId != userId) {
+ if (!notificationMatchesUserId(r, userId)) {
continue;
}
@@ -1376,7 +1390,7 @@ public class NotificationManagerService extends INotificationManager.Stub
final int len = list.size();
for (int i=0; i<len; i++) {
NotificationRecord r = list.get(i);
- if (r.userId != userId || r.id != id) {
+ if (!notificationMatchesUserId(r, userId) || r.id != id) {
continue;
}
if (tag == null) {
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java
index b76ad45..4e692a2 100644
--- a/services/java/com/android/server/power/PowerManagerService.java
+++ b/services/java/com/android/server/power/PowerManagerService.java
@@ -162,6 +162,11 @@ public final class PowerManagerService extends IPowerManager.Stub
// Poll interval in milliseconds for watching boot animation finished.
private static final int BOOT_ANIMATION_POLL_INTERVAL = 200;
+ // If the battery level drops by this percentage and the user activity timeout
+ // has expired, then assume the device is receiving insufficient current to charge
+ // effectively and terminate the dream.
+ private static final int DREAM_BATTERY_LEVEL_DRAIN_CUTOFF = 5;
+
private Context mContext;
private LightsService mLightsService;
private BatteryService mBatteryService;
@@ -256,6 +261,14 @@ public final class PowerManagerService extends IPowerManager.Stub
// The current plug type, such as BatteryManager.BATTERY_PLUGGED_WIRELESS.
private int mPlugType;
+ // The current battery level percentage.
+ private int mBatteryLevel;
+
+ // The battery level percentage at the time the dream started.
+ // This is used to terminate a dream and go to sleep if the battery is
+ // draining faster than it is charging and the user activity timeout has expired.
+ private int mBatteryLevelWhenDreamStarted;
+
// True if the device should wake up when plugged or unplugged.
private boolean mWakeUpWhenPluggedOrUnpluggedConfig;
@@ -1067,12 +1080,14 @@ public final class PowerManagerService extends IPowerManager.Stub
final int oldPlugType = mPlugType;
mIsPowered = mBatteryService.isPowered(BatteryManager.BATTERY_PLUGGED_ANY);
mPlugType = mBatteryService.getPlugType();
+ mBatteryLevel = mBatteryService.getBatteryLevel();
if (DEBUG) {
Slog.d(TAG, "updateIsPoweredLocked: wasPowered=" + wasPowered
+ ", mIsPowered=" + mIsPowered
+ ", oldPlugType=" + oldPlugType
- + ", mPlugType=" + mPlugType);
+ + ", mPlugType=" + mPlugType
+ + ", mBatteryLevel=" + mBatteryLevel);
}
if (wasPowered != mIsPowered || oldPlugType != mPlugType) {
@@ -1126,8 +1141,7 @@ public final class PowerManagerService extends IPowerManager.Stub
}
if (!wasPowered && mIsPowered
&& mPlugType == BatteryManager.BATTERY_PLUGGED_WIRELESS
- && mBatteryService.getBatteryLevel() >=
- WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT) {
+ && mBatteryLevel >= WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT) {
return false;
}
@@ -1403,7 +1417,7 @@ public final class PowerManagerService extends IPowerManager.Stub
mSandmanScheduled = false;
boolean canDream = canDreamLocked();
if (DEBUG_SPEW) {
- Log.d(TAG, "handleSandman: canDream=" + canDream
+ Slog.d(TAG, "handleSandman: canDream=" + canDream
+ ", mWakefulness=" + wakefulnessToString(mWakefulness));
}
@@ -1431,10 +1445,24 @@ public final class PowerManagerService extends IPowerManager.Stub
if (mWakefulness == WAKEFULNESS_NAPPING) {
mWakefulness = WAKEFULNESS_DREAMING;
mDirty |= DIRTY_WAKEFULNESS;
+ mBatteryLevelWhenDreamStarted = mBatteryLevel;
updatePowerStateLocked();
continueDreaming = true;
} else if (mWakefulness == WAKEFULNESS_DREAMING) {
- continueDreaming = true;
+ if (!isBeingKeptAwakeLocked()
+ && mBatteryLevel < mBatteryLevelWhenDreamStarted
+ - DREAM_BATTERY_LEVEL_DRAIN_CUTOFF) {
+ // If the user activity timeout expired and the battery appears
+ // to be draining faster than it is charging then stop dreaming
+ // and go to sleep.
+ Slog.i(TAG, "Stopping dream because the battery appears to "
+ + "be draining faster than it is charging. "
+ + "Battery level when dream started: "
+ + mBatteryLevelWhenDreamStarted + "%. "
+ + "Battery level now: " + mBatteryLevel + "%.");
+ } else {
+ continueDreaming = true;
+ }
}
}
if (!continueDreaming) {
@@ -1704,8 +1732,11 @@ public final class PowerManagerService extends IPowerManager.Stub
}
/**
- * Reboot the device, passing 'reason' (may be null)
- * to the underlying __reboot system call. Should not return.
+ * Reboots the device.
+ *
+ * @param confirm If true, shows a reboot confirmation dialog.
+ * @param reason The reason for the reboot, or null if none.
+ * @param wait If true, this call waits for the reboot to complete and does not return.
*/
@Override // Binder call
public void reboot(boolean confirm, String reason, boolean wait) {
@@ -1713,15 +1744,17 @@ public final class PowerManagerService extends IPowerManager.Stub
final long ident = Binder.clearCallingIdentity();
try {
- rebootInternal(false, confirm, reason, wait);
+ shutdownOrRebootInternal(false, confirm, reason, wait);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
/**
- * Shutdown the devic, passing 'reason' (may be null)
- * to the underlying __reboot system call. Should not return.
+ * Shuts down the device.
+ *
+ * @param confirm If true, shows a shutdown confirmation dialog.
+ * @param wait If true, this call waits for the shutdown to complete and does not return.
*/
@Override // Binder call
public void shutdown(boolean confirm, boolean wait) {
@@ -1729,19 +1762,20 @@ public final class PowerManagerService extends IPowerManager.Stub
final long ident = Binder.clearCallingIdentity();
try {
- rebootInternal(true, confirm, null, wait);
+ shutdownOrRebootInternal(true, confirm, null, wait);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
- private void rebootInternal(final boolean shutdown, final boolean confirm,
+ private void shutdownOrRebootInternal(final boolean shutdown, final boolean confirm,
final String reason, boolean wait) {
if (mHandler == null || !mSystemReady) {
- throw new IllegalStateException("Too early to call reboot()");
+ throw new IllegalStateException("Too early to call shutdown() or reboot()");
}
Runnable runnable = new Runnable() {
+ @Override
public void run() {
synchronized (this) {
if (shutdown) {
@@ -1789,6 +1823,7 @@ public final class PowerManagerService extends IPowerManager.Stub
private void crashInternal(final String message) {
Thread t = new Thread("PowerManagerService.crash()") {
+ @Override
public void run() {
throw new RuntimeException(message);
}
@@ -2087,6 +2122,8 @@ public final class PowerManagerService extends IPowerManager.Stub
pw.println(" mWakefulness=" + wakefulnessToString(mWakefulness));
pw.println(" mIsPowered=" + mIsPowered);
pw.println(" mPlugType=" + mPlugType);
+ pw.println(" mBatteryLevel=" + mBatteryLevel);
+ pw.println(" mBatteryLevelWhenDreamStarted=" + mBatteryLevelWhenDreamStarted);
pw.println(" mStayOn=" + mStayOn);
pw.println(" mProximityPositive=" + mProximityPositive);
pw.println(" mBootCompleted=" + mBootCompleted);
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index b67fb51..269eac0 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -618,6 +618,7 @@ public class WindowAnimator {
if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(
TAG, ">>> OPEN TRANSACTION animateLocked");
Surface.openTransaction();
+ Surface.setAnimationTransaction();
try {
updateAppWindowsLocked();
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 77d815b..c341872 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -2823,16 +2823,9 @@ public class WindowManagerService extends IWindowManager.Stub
"Relayout window turning screen on: " + win);
win.mTurnOnScreen = true;
}
- int diff = 0;
- if (win.mConfiguration != mCurConfiguration
- && (win.mConfiguration == null
- || (diff=mCurConfiguration.diff(win.mConfiguration)) != 0)) {
- win.mConfiguration = mCurConfiguration;
- if (DEBUG_CONFIGURATION) {
- Slog.i(TAG, "Window " + win + " visible with new config: "
- + win.mConfiguration + " / 0x"
- + Integer.toHexString(diff));
- }
+ if (win.isConfigChanged()) {
+ if (DEBUG_CONFIGURATION) Slog.i(TAG, "Window " + win
+ + " visible with new config: " + win.mConfiguration);
outConfig.setTo(mCurConfiguration);
}
}
@@ -8260,7 +8253,7 @@ public class WindowManagerService extends IWindowManager.Stub
Slog.v(TAG, "1ST PASS " + win
+ ": gone=" + gone + " mHaveFrame=" + win.mHaveFrame
+ " mLayoutAttached=" + win.mLayoutAttached
- + " screen changed=" + win.isConfigDiff(ActivityInfo.CONFIG_SCREEN_SIZE));
+ + " screen changed=" + win.isConfigChanged());
final AppWindowToken atoken = win.mAppToken;
if (gone) Slog.v(TAG, " GONE: mViewVisibility="
+ win.mViewVisibility + " mRelayoutCalled="
@@ -8282,7 +8275,7 @@ public class WindowManagerService extends IWindowManager.Stub
// windows, since that means "perform layout as normal,
// just don't display").
if (!gone || !win.mHaveFrame || win.mLayoutNeeded
- || win.isConfigDiff(ActivityInfo.CONFIG_SCREEN_SIZE)
+ || win.isConfigChanged()
|| win.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
if (!win.mLayoutAttached) {
if (initial) {