summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/Intent.java27
-rw-r--r--core/java/android/hardware/display/DisplayManagerInternal.java14
-rw-r--r--core/java/android/hardware/input/InputManagerInternal.java12
-rw-r--r--core/java/android/os/IPowerManager.aidl2
-rw-r--r--core/java/android/os/PowerManager.java59
-rw-r--r--core/java/android/service/dreams/DreamService.java18
-rw-r--r--core/java/android/view/Display.java62
-rw-r--r--core/java/android/view/DisplayInfo.java13
-rw-r--r--core/java/android/view/KeyEvent.java6
-rw-r--r--core/java/android/view/WindowManager.java3
-rw-r--r--core/java/android/view/WindowManagerPolicy.java8
11 files changed, 185 insertions, 39 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 65e2268..95e27e2 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1414,15 +1414,38 @@ public class Intent implements Parcelable, Cloneable {
// Standard intent broadcast actions (see action variable).
/**
- * Broadcast Action: Sent after the screen turns off.
+ * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
+ * <p>
+ * For historical reasons, the name of this broadcast action refers to the power
+ * state of the screen but it is actually sent in response to changes in the
+ * overall interactive state of the device.
+ * </p><p>
+ * This broadcast is sent when the device becomes non-interactive which may have
+ * nothing to do with the screen turning off. To determine the
+ * actual state of the screen, use {@link android.view.Display#getState}.
+ * </p><p>
+ * See {@link android.os.PowerManager#isInteractive} for details.
+ * </p>
*
* <p class="note">This is a protected intent that can only be sent
* by the system.
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
+
/**
- * Broadcast Action: Sent after the screen turns on.
+ * Broadcast Action: Sent when the device wakes up and becomes interactive.
+ * <p>
+ * For historical reasons, the name of this broadcast action refers to the power
+ * state of the screen but it is actually sent in response to changes in the
+ * overall interactive state of the device.
+ * </p><p>
+ * This broadcast is sent when the device becomes interactive which may have
+ * nothing to do with the screen turning on. To determine the
+ * actual state of the screen, use {@link android.view.Display#getState}.
+ * </p><p>
+ * See {@link android.os.PowerManager#isInteractive} for details.
+ * </p>
*
* <p class="note">This is a protected intent that can only be sent
* by the system.
diff --git a/core/java/android/hardware/display/DisplayManagerInternal.java b/core/java/android/hardware/display/DisplayManagerInternal.java
index 03fa1d5..cec90cd 100644
--- a/core/java/android/hardware/display/DisplayManagerInternal.java
+++ b/core/java/android/hardware/display/DisplayManagerInternal.java
@@ -58,16 +58,6 @@ public abstract class DisplayManagerInternal {
public abstract boolean isProximitySensorAvailable();
/**
- * Called by the power manager to blank all displays.
- */
- public abstract void blankAllDisplaysFromPowerManager();
-
- /**
- * Called by the power manager to unblank all displays.
- */
- public abstract void unblankAllDisplaysFromPowerManager();
-
- /**
* Returns information about the specified logical display.
*
* @param displayId The logical display id.
@@ -254,12 +244,10 @@ public abstract class DisplayManagerInternal {
void onStateChanged();
void onProximityPositive();
void onProximityNegative();
+ void onDisplayStateChange(int state); // one of the Display state constants
void acquireSuspendBlocker();
void releaseSuspendBlocker();
-
- void blankAllDisplays();
- void unblankAllDisplays();
}
/**
diff --git a/core/java/android/hardware/input/InputManagerInternal.java b/core/java/android/hardware/input/InputManagerInternal.java
index 8be94d0..6a392dd 100644
--- a/core/java/android/hardware/input/InputManagerInternal.java
+++ b/core/java/android/hardware/input/InputManagerInternal.java
@@ -25,12 +25,18 @@ import android.view.InputEvent;
* @hide Only for use within the system server.
*/
public abstract class InputManagerInternal {
+ public abstract boolean injectInputEvent(InputEvent event, int displayId, int mode);
+
/**
- * Sets information about the displays as needed by the input system.
- * The input system should copy this information if required.
+ * Called by the display manager to set information about the displays as needed
+ * by the input system. The input system must copy this information to retain it.
*/
public abstract void setDisplayViewports(DisplayViewport defaultViewport,
DisplayViewport externalTouchViewport);
- public abstract boolean injectInputEvent(InputEvent event, int displayId, int mode);
+ /**
+ * Called by the power manager to tell the input manager whether it should start
+ * watching for wake events.
+ */
+ public abstract void setInteractive(boolean interactive);
}
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 56176a4..92af1a5 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -37,8 +37,8 @@ interface IPowerManager
void wakeUp(long time);
void goToSleep(long time, int reason);
void nap(long time);
+ boolean isInteractive();
- boolean isScreenOn();
void reboot(boolean confirm, String reason, boolean wait);
void shutdown(boolean confirm, boolean wait);
void crash(String message);
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 86ef479..646bfef 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -582,21 +582,64 @@ public final class PowerManager {
}
/**
- * Returns whether the screen is currently on.
+ * Returns true if the device is in an interactive state.
* <p>
- * Only indicates whether the screen is on. The screen could be either bright or dim.
+ * For historical reasons, the name of this method refers to the power state of
+ * the screen but it actually describes the overall interactive state of
+ * the device. This method has been replaced by {@link #isInteractive}.
* </p><p>
- * {@samplecode
- * PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
- * boolean isScreenOn = pm.isScreenOn();
- * }
+ * The value returned by this method only indicates whether the device is
+ * in an interactive state which may have nothing to do with the screen being
+ * on or off. To determine the actual state of the screen,
+ * use {@link android.view.Display#getState}.
* </p>
*
- * @return whether the screen is on (bright or dim).
+ * @return True if the device is in an interactive state.
+ *
+ * @deprecated Use {@link #isInteractive} instead.
*/
+ @Deprecated
public boolean isScreenOn() {
+ return isInteractive();
+ }
+
+ /**
+ * Returns true if the device is in an interactive state.
+ * <p>
+ * When this method returns true, the device is awake and ready to interact
+ * with the user (although this is not a guarantee that the user is actively
+ * interacting with the device just this moment). The main screen is usually
+ * turned on while in this state. Certain features, such as the proximity
+ * sensor, may temporarily turn off the screen while still leaving the device in an
+ * interactive state. Note in particular that the device is still considered
+ * to be interactive while dreaming (since dreams can be interactive) but not
+ * when it is dozing or asleep.
+ * </p><p>
+ * When this method returns false, the device is dozing or asleep and must
+ * be awoken before it will become ready to interact with the user again. The
+ * main screen is usually turned off while in this state. Certain features,
+ * such as "ambient mode" may cause the main screen to remain on (albeit in a
+ * low power state) to display system-provided content while the device dozes.
+ * </p><p>
+ * The system will send a {@link android.content.Intent#ACTION_SCREEN_ON screen on}
+ * or {@link android.content.Intent#ACTION_SCREEN_OFF screen off} broadcast
+ * whenever the interactive state of the device changes. For historical reasons,
+ * the names of these broadcasts refer to the power state of the screen
+ * but they are actually sent in response to changes in the overall interactive
+ * state of the device, as described by this method.
+ * </p><p>
+ * Services may use the non-interactive state as a hint to conserve power
+ * since the user is not present.
+ * </p>
+ *
+ * @return True if the device is in an interactive state.
+ *
+ * @see android.content.Intent#ACTION_SCREEN_ON
+ * @see android.content.Intent#ACTION_SCREEN_OFF
+ */
+ public boolean isInteractive() {
try {
- return mService.isScreenOn();
+ return mService.isInteractive();
} catch (RemoteException e) {
return false;
}
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java
index de9eeff..2303d65 100644
--- a/core/java/android/service/dreams/DreamService.java
+++ b/core/java/android/service/dreams/DreamService.java
@@ -789,10 +789,20 @@ public class DreamService extends Service implements Window.Callback {
return;
}
- // start it up
- if (mDebug) Slog.v(TAG, "Calling onDreamingStarted()");
- mStarted = true;
- onDreamingStarted();
+ // We need to defer calling onDreamingStarted until after onWindowAttached,
+ // which is posted to the handler by addView, so we post onDreamingStarted
+ // to the handler also. Need to watch out here in case detach occurs before
+ // this callback is invoked.
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mWindow != null) {
+ if (mDebug) Slog.v(TAG, "Calling onDreamingStarted()");
+ mStarted = true;
+ onDreamingStarted();
+ }
+ }
+ });
}
private void safelyFinish() {
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 7d310a2..c4494f4 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -204,6 +204,36 @@ public final class Display {
public static final int TYPE_VIRTUAL = 5;
/**
+ * Display state: The display state is unknown.
+ *
+ * @see #getState
+ */
+ public static final int STATE_UNKNOWN = 0;
+
+ /**
+ * Display state: The display is off.
+ *
+ * @see #getState
+ */
+ public static final int STATE_OFF = 1;
+
+ /**
+ * Display state: The display is on.
+ *
+ * @see #getState
+ */
+ public static final int STATE_ON = 2;
+
+ /**
+ * Display state: The display is dozing in a low-power state; it may be showing
+ * system-provided content while the device is in a non-interactive state.
+ *
+ * @see #getState
+ * @see android.os.PowerManager#isInteractive
+ */
+ public static final int STATE_DOZING = 3;
+
+ /**
* Internal method to create a display.
* Applications should use {@link android.view.WindowManager#getDefaultDisplay()}
* or {@link android.hardware.display.DisplayManager#getDisplay}
@@ -628,6 +658,19 @@ public final class Display {
}
/**
+ * Gets the state of the display, such as whether it is on or off.
+ *
+ * @return The state of the display: one of {@link #STATE_OFF}, {@link #STATE_ON},
+ * {@link #STATE_DOZING}, or {@link #STATE_UNKNOWN}.
+ */
+ public int getState() {
+ synchronized (this) {
+ updateDisplayInfoLocked();
+ return mIsValid ? mDisplayInfo.state : STATE_UNKNOWN;
+ }
+ }
+
+ /**
* Returns true if the specified UID has access to this display.
* @hide
*/
@@ -718,5 +761,22 @@ public final class Display {
return Integer.toString(type);
}
}
-}
+ /**
+ * @hide
+ */
+ public static String stateToString(int state) {
+ switch (state) {
+ case STATE_UNKNOWN:
+ return "UNKNOWN";
+ case STATE_OFF:
+ return "OFF";
+ case STATE_ON:
+ return "ON";
+ case STATE_DOZING:
+ return "DOZING";
+ default:
+ return Integer.toString(state);
+ }
+ }
+}
diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java
index 8944207..5f840d3 100644
--- a/core/java/android/view/DisplayInfo.java
+++ b/core/java/android/view/DisplayInfo.java
@@ -180,6 +180,11 @@ public final class DisplayInfo implements Parcelable {
public float physicalYDpi;
/**
+ * The state of the display, such as {@link android.view.Display#STATE_ON}.
+ */
+ public int state;
+
+ /**
* The UID of the application that owns this display, or zero if it is owned by the system.
* <p>
* If the display is private, then only the owner can use it.
@@ -248,6 +253,7 @@ public final class DisplayInfo implements Parcelable {
&& logicalDensityDpi == other.logicalDensityDpi
&& physicalXDpi == other.physicalXDpi
&& physicalYDpi == other.physicalYDpi
+ && state == other.state
&& ownerUid == other.ownerUid
&& Objects.equal(ownerPackageName, other.ownerPackageName);
}
@@ -280,6 +286,7 @@ public final class DisplayInfo implements Parcelable {
logicalDensityDpi = other.logicalDensityDpi;
physicalXDpi = other.physicalXDpi;
physicalYDpi = other.physicalYDpi;
+ state = other.state;
ownerUid = other.ownerUid;
ownerPackageName = other.ownerPackageName;
}
@@ -307,6 +314,7 @@ public final class DisplayInfo implements Parcelable {
logicalDensityDpi = source.readInt();
physicalXDpi = source.readFloat();
physicalYDpi = source.readFloat();
+ state = source.readInt();
ownerUid = source.readInt();
ownerPackageName = source.readString();
}
@@ -335,6 +343,7 @@ public final class DisplayInfo implements Parcelable {
dest.writeInt(logicalDensityDpi);
dest.writeFloat(physicalXDpi);
dest.writeFloat(physicalYDpi);
+ dest.writeInt(state);
dest.writeInt(ownerUid);
dest.writeString(ownerPackageName);
}
@@ -431,7 +440,7 @@ public final class DisplayInfo implements Parcelable {
sb.append(smallestNominalAppHeight);
sb.append(", ");
sb.append(refreshRate);
- sb.append(" fps, rotation");
+ sb.append(" fps, rotation ");
sb.append(rotation);
sb.append(", density ");
sb.append(logicalDensityDpi);
@@ -446,6 +455,8 @@ public final class DisplayInfo implements Parcelable {
if (address != null) {
sb.append(", address ").append(address);
}
+ sb.append(", state ");
+ sb.append(Display.stateToString(state));
if (ownerUid != 0 || ownerPackageName != null) {
sb.append(", owner ").append(ownerPackageName);
sb.append(" (uid ").append(ownerUid).append(")");
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 437ccfb..7b389c0 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -1167,9 +1167,13 @@ public class KeyEvent extends InputEvent implements Parcelable {
/**
* This mask is set if the device woke because of this key event.
+ *
+ * @deprecated This flag will never be set by the system since the system
+ * consumes all wake keys itself.
*/
+ @Deprecated
public static final int FLAG_WOKE_HERE = 0x1;
-
+
/**
* This mask is set if the key event was generated by a software keyboard.
*/
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 53a4c0d0..d5a7d33 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -610,7 +610,10 @@ public interface WindowManager extends ViewManager {
* screen is pressed, you will receive this first touch event. Usually
* the first touch event is consumed by the system since the user can
* not see what they are pressing on.
+ *
+ * @deprecated This flag has no effect.
*/
+ @Deprecated
public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
/** Window flag: as long as this window is visible to the user, keep
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 74dda77..893db89 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -86,8 +86,7 @@ public interface WindowManagerPolicy {
public final static int FLAG_FILTERED = 0x04000000;
public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
- public final static int FLAG_WOKE_HERE = 0x10000000;
- public final static int FLAG_BRIGHT_HERE = 0x20000000;
+ public final static int FLAG_INTERACTIVE = 0x20000000;
public final static int FLAG_PASS_TO_USER = 0x40000000;
// Flags used for indicating whether the internal and/or external input devices
@@ -735,11 +734,10 @@ public interface WindowManagerPolicy {
* because it's the most fragile.
* @param event The key event.
* @param policyFlags The policy flags associated with the key.
- * @param isScreenOn True if the screen is already on
*
* @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
*/
- public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
+ public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
/**
* Called from the input reader thread before a motion is enqueued when the screen is off.
@@ -752,7 +750,7 @@ public interface WindowManagerPolicy {
*
* @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
*/
- public int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags);
+ public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags);
/**
* Called from the input dispatcher thread before a key is dispatched to a window.