resolved conflicts for merge of 337e764d to master
Change-Id: I8168dbf42b68c2f7b5ccb300e0080dddc627af26
This commit is contained in:
@@ -19735,7 +19735,8 @@ package android.os {
|
||||
|
||||
public final class PowerManager {
|
||||
method public void goToSleep(long);
|
||||
method public boolean isScreenOn();
|
||||
method public boolean isInteractive();
|
||||
method public deprecated boolean isScreenOn();
|
||||
method public android.os.PowerManager.WakeLock newWakeLock(int, java.lang.String);
|
||||
method public void reboot(java.lang.String);
|
||||
method public void userActivity(long, boolean);
|
||||
@@ -28412,6 +28413,7 @@ package android.view {
|
||||
method public float getRefreshRate();
|
||||
method public int getRotation();
|
||||
method public void getSize(android.graphics.Point);
|
||||
method public int getState();
|
||||
method public deprecated int getWidth();
|
||||
method public boolean isValid();
|
||||
field public static final int DEFAULT_DISPLAY = 0; // 0x0
|
||||
@@ -28419,6 +28421,10 @@ package android.view {
|
||||
field public static final int FLAG_PRIVATE = 4; // 0x4
|
||||
field public static final int FLAG_SECURE = 2; // 0x2
|
||||
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
|
||||
field public static final int STATE_DOZING = 3; // 0x3
|
||||
field public static final int STATE_OFF = 1; // 0x1
|
||||
field public static final int STATE_ON = 2; // 0x2
|
||||
field public static final int STATE_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public class DragEvent implements android.os.Parcelable {
|
||||
@@ -28764,7 +28770,7 @@ package android.view {
|
||||
field public static final int FLAG_SOFT_KEYBOARD = 2; // 0x2
|
||||
field public static final int FLAG_TRACKING = 512; // 0x200
|
||||
field public static final int FLAG_VIRTUAL_HARD_KEY = 64; // 0x40
|
||||
field public static final int FLAG_WOKE_HERE = 1; // 0x1
|
||||
field public static final deprecated int FLAG_WOKE_HERE = 1; // 0x1
|
||||
field public static final int KEYCODE_0 = 7; // 0x7
|
||||
field public static final int KEYCODE_1 = 8; // 0x8
|
||||
field public static final int KEYCODE_2 = 9; // 0x9
|
||||
@@ -30898,7 +30904,7 @@ package android.view {
|
||||
field public static final int FLAG_SHOW_WALLPAPER = 1048576; // 0x100000
|
||||
field public static final int FLAG_SHOW_WHEN_LOCKED = 524288; // 0x80000
|
||||
field public static final int FLAG_SPLIT_TOUCH = 8388608; // 0x800000
|
||||
field public static final int FLAG_TOUCHABLE_WHEN_WAKING = 64; // 0x40
|
||||
field public static final deprecated int FLAG_TOUCHABLE_WHEN_WAKING = 64; // 0x40
|
||||
field public static final int FLAG_TRANSLUCENT_NAVIGATION = 134217728; // 0x8000000
|
||||
field public static final int FLAG_TRANSLUCENT_STATUS = 67108864; // 0x4000000
|
||||
field public static final int FLAG_TURN_SCREEN_ON = 2097152; // 0x200000
|
||||
|
||||
@@ -1417,15 +1417,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.
|
||||
|
||||
@@ -57,16 +57,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.
|
||||
*
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,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);
|
||||
|
||||
@@ -601,21 +601,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;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -203,6 +203,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()}
|
||||
@@ -629,6 +659,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
|
||||
@@ -720,5 +763,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +179,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>
|
||||
@@ -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(")");
|
||||
|
||||
@@ -1166,7 +1166,11 @@ 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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -90,8 +90,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
|
||||
@@ -744,11 +743,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.
|
||||
@@ -761,7 +759,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.
|
||||
|
||||
@@ -2357,7 +2357,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
|
||||
private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) {
|
||||
int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags, true);
|
||||
int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags);
|
||||
if ((actions & ACTION_PASS_TO_USER) != 0) {
|
||||
long delayMillis = interceptKeyBeforeDispatching(
|
||||
win, fallbackEvent, policyFlags);
|
||||
@@ -3801,12 +3801,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) {
|
||||
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
|
||||
if (!mSystemBooted) {
|
||||
// If we have not yet booted, don't let key events do anything.
|
||||
return 0;
|
||||
}
|
||||
|
||||
final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0;
|
||||
final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
|
||||
final boolean canceled = event.isCanceled();
|
||||
final int keyCode = event.getKeyCode();
|
||||
@@ -3818,7 +3819,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
// This will prevent any keys other than the power button from waking the screen
|
||||
// when the keyguard is hidden by another activity.
|
||||
final boolean keyguardActive = (mKeyguardDelegate == null ? false :
|
||||
(isScreenOn ?
|
||||
(interactive ?
|
||||
mKeyguardDelegate.isShowingAndNotHidden() :
|
||||
mKeyguardDelegate.isShowing()));
|
||||
|
||||
@@ -3830,7 +3831,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
if (DEBUG_INPUT) {
|
||||
Log.d(TAG, "interceptKeyTq keycode=" + keyCode
|
||||
+ " screenIsOn=" + isScreenOn + " keyguardActive=" + keyguardActive
|
||||
+ " interactive=" + interactive + " keyguardActive=" + keyguardActive
|
||||
+ " policyFlags=" + Integer.toHexString(policyFlags));
|
||||
}
|
||||
|
||||
@@ -3839,18 +3840,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
|
||||
}
|
||||
|
||||
// Basic policy based on screen state and keyguard.
|
||||
// FIXME: This policy isn't quite correct. We shouldn't care whether the screen
|
||||
// is on or off, really. We should care about whether the device is in an
|
||||
// interactive state or is in suspend pretending to be "off".
|
||||
// The primary screen might be turned off due to proximity sensor or
|
||||
// because we are presenting media on an auxiliary screen or remotely controlling
|
||||
// the device some other way (which is why we have an exemption here for injected
|
||||
// events).
|
||||
// Basic policy based on interactive state.
|
||||
int result;
|
||||
boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE
|
||||
| WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;
|
||||
if (isScreenOn || (isInjected && !isWakeKey)) {
|
||||
if (interactive || (isInjected && !isWakeKey)) {
|
||||
// When the screen is on or if the key is injected pass the key to the application.
|
||||
result = ACTION_PASS_TO_USER;
|
||||
} else {
|
||||
@@ -3875,7 +3869,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
case KeyEvent.KEYCODE_VOLUME_MUTE: {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
if (down) {
|
||||
if (isScreenOn && !mVolumeDownKeyTriggered
|
||||
if (interactive && !mVolumeDownKeyTriggered
|
||||
&& (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
|
||||
mVolumeDownKeyTriggered = true;
|
||||
mVolumeDownKeyTime = event.getDownTime();
|
||||
@@ -3889,7 +3883,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
if (down) {
|
||||
if (isScreenOn && !mVolumeUpKeyTriggered
|
||||
if (interactive && !mVolumeUpKeyTriggered
|
||||
&& (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
|
||||
mVolumeUpKeyTriggered = true;
|
||||
cancelPendingPowerKeyAction();
|
||||
@@ -3957,7 +3951,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
Log.w(TAG, "ITelephony threw RemoteException", ex);
|
||||
}
|
||||
}
|
||||
interceptPowerKeyDown(!isScreenOn || hungUp);
|
||||
interceptPowerKeyDown(!interactive || hungUp);
|
||||
} else {
|
||||
if (interceptPowerKeyUp(canceled)) {
|
||||
if ((mEndcallBehavior
|
||||
@@ -3984,7 +3978,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
if (panic) {
|
||||
mHandler.post(mRequestTransientNav);
|
||||
}
|
||||
if (isScreenOn && !mPowerKeyTriggered
|
||||
if (interactive && !mPowerKeyTriggered
|
||||
&& (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
|
||||
mPowerKeyTriggered = true;
|
||||
mPowerKeyTime = event.getDownTime();
|
||||
@@ -4010,7 +4004,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
Log.w(TAG, "ITelephony threw RemoteException", ex);
|
||||
}
|
||||
}
|
||||
interceptPowerKeyDown(!isScreenOn || hungUp
|
||||
interceptPowerKeyDown(!interactive || hungUp
|
||||
|| mVolumeDownKeyTriggered || mVolumeUpKeyTriggered);
|
||||
} else {
|
||||
mPowerKeyTriggered = false;
|
||||
@@ -4143,15 +4137,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags) {
|
||||
int result = 0;
|
||||
|
||||
final boolean isWakeMotion = (policyFlags
|
||||
& (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;
|
||||
if (isWakeMotion) {
|
||||
mPowerManager.wakeUp(whenNanos / 1000000);
|
||||
}
|
||||
return result;
|
||||
public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) {
|
||||
// We already know this is a wake motion so just wake up.
|
||||
// Note that we would observe policyFlags containing
|
||||
// FLAG_WAKE and FLAG_INTERACTIVE here.
|
||||
mPowerManager.wakeUp(whenNanos / 1000000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dispatchMediaKeyWithWakeLock(KeyEvent event) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.display;
|
||||
|
||||
/**
|
||||
* Interface used to update the actual display state.
|
||||
*/
|
||||
public interface DisplayBlanker {
|
||||
void requestDisplayState(int state);
|
||||
}
|
||||
@@ -107,15 +107,9 @@ abstract class DisplayDevice {
|
||||
}
|
||||
|
||||
/**
|
||||
* Blanks the display, if supported.
|
||||
* Sets the display state, if supported.
|
||||
*/
|
||||
public void blankLocked() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblanks the display, if supported.
|
||||
*/
|
||||
public void unblankLocked() {
|
||||
public void requestDisplayStateLocked(int state) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,6 +175,11 @@ final class DisplayDeviceInfo {
|
||||
*/
|
||||
public String address;
|
||||
|
||||
/**
|
||||
* Display state.
|
||||
*/
|
||||
public int state = Display.STATE_ON;
|
||||
|
||||
/**
|
||||
* The UID of the application that owns this display, or zero if it is owned by the system.
|
||||
* <p>
|
||||
@@ -219,6 +224,7 @@ final class DisplayDeviceInfo {
|
||||
&& rotation == other.rotation
|
||||
&& type == other.type
|
||||
&& Objects.equal(address, other.address)
|
||||
&& state == other.state
|
||||
&& ownerUid == other.ownerUid
|
||||
&& Objects.equal(ownerPackageName, other.ownerPackageName);
|
||||
}
|
||||
@@ -241,6 +247,7 @@ final class DisplayDeviceInfo {
|
||||
rotation = other.rotation;
|
||||
type = other.type;
|
||||
address = other.address;
|
||||
state = other.state;
|
||||
ownerUid = other.ownerUid;
|
||||
ownerPackageName = other.ownerPackageName;
|
||||
}
|
||||
@@ -260,6 +267,7 @@ final class DisplayDeviceInfo {
|
||||
if (address != null) {
|
||||
sb.append(", address ").append(address);
|
||||
}
|
||||
sb.append(", state ").append(Display.stateToString(state));
|
||||
if (ownerUid != 0 || ownerPackageName != null) {
|
||||
sb.append(", owner ").append(ownerPackageName);
|
||||
sb.append(" (uid ").append(ownerUid).append(")");
|
||||
|
||||
@@ -121,10 +121,6 @@ public final class DisplayManagerService extends SystemService {
|
||||
private static final int MSG_REQUEST_TRAVERSAL = 4;
|
||||
private static final int MSG_UPDATE_VIEWPORT = 5;
|
||||
|
||||
private static final int DISPLAY_BLANK_STATE_UNKNOWN = 0;
|
||||
private static final int DISPLAY_BLANK_STATE_BLANKED = 1;
|
||||
private static final int DISPLAY_BLANK_STATE_UNBLANKED = 2;
|
||||
|
||||
private final Context mContext;
|
||||
private final DisplayManagerHandler mHandler;
|
||||
private final Handler mUiHandler;
|
||||
@@ -176,8 +172,9 @@ public final class DisplayManagerService extends SystemService {
|
||||
// Display power controller.
|
||||
private DisplayPowerController mDisplayPowerController;
|
||||
|
||||
// Set to true if all displays have been blanked by the power manager.
|
||||
private int mAllDisplayBlankStateFromPowerManager = DISPLAY_BLANK_STATE_UNKNOWN;
|
||||
// The overall display state, independent of changes that might influence one
|
||||
// display or another in particular.
|
||||
private int mGlobalDisplayState = Display.STATE_UNKNOWN;
|
||||
|
||||
// Set to true when there are pending display changes that have yet to be applied
|
||||
// to the surface flinger state.
|
||||
@@ -315,21 +312,11 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
private void blankAllDisplaysFromPowerManagerInternal() {
|
||||
private void requestGlobalDisplayStateInternal(int state) {
|
||||
synchronized (mSyncRoot) {
|
||||
if (mAllDisplayBlankStateFromPowerManager != DISPLAY_BLANK_STATE_BLANKED) {
|
||||
mAllDisplayBlankStateFromPowerManager = DISPLAY_BLANK_STATE_BLANKED;
|
||||
updateAllDisplayBlankingLocked();
|
||||
scheduleTraversalLocked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void unblankAllDisplaysFromPowerManagerInternal() {
|
||||
synchronized (mSyncRoot) {
|
||||
if (mAllDisplayBlankStateFromPowerManager != DISPLAY_BLANK_STATE_UNBLANKED) {
|
||||
mAllDisplayBlankStateFromPowerManager = DISPLAY_BLANK_STATE_UNBLANKED;
|
||||
updateAllDisplayBlankingLocked();
|
||||
if (mGlobalDisplayState != state) {
|
||||
mGlobalDisplayState = state;
|
||||
updateGlobalDisplayStateLocked();
|
||||
scheduleTraversalLocked(false);
|
||||
}
|
||||
}
|
||||
@@ -616,7 +603,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
|
||||
mDisplayDevices.add(device);
|
||||
addLogicalDisplayLocked(device);
|
||||
updateDisplayBlankingLocked(device);
|
||||
updateDisplayStateLocked(device);
|
||||
scheduleTraversalLocked(false);
|
||||
}
|
||||
|
||||
@@ -655,27 +642,20 @@ public final class DisplayManagerService extends SystemService {
|
||||
scheduleTraversalLocked(false);
|
||||
}
|
||||
|
||||
private void updateAllDisplayBlankingLocked() {
|
||||
private void updateGlobalDisplayStateLocked() {
|
||||
final int count = mDisplayDevices.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
DisplayDevice device = mDisplayDevices.get(i);
|
||||
updateDisplayBlankingLocked(device);
|
||||
updateDisplayStateLocked(device);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplayBlankingLocked(DisplayDevice device) {
|
||||
private void updateDisplayStateLocked(DisplayDevice device) {
|
||||
// Blank or unblank the display immediately to match the state requested
|
||||
// by the power manager (if known).
|
||||
// by the display power controller (if known).
|
||||
DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
|
||||
if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
|
||||
switch (mAllDisplayBlankStateFromPowerManager) {
|
||||
case DISPLAY_BLANK_STATE_BLANKED:
|
||||
device.blankLocked();
|
||||
break;
|
||||
case DISPLAY_BLANK_STATE_UNBLANKED:
|
||||
device.unblankLocked();
|
||||
break;
|
||||
}
|
||||
device.requestDisplayStateLocked(mGlobalDisplayState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,9 +796,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
+ device.getDisplayDeviceInfoLocked());
|
||||
return;
|
||||
}
|
||||
boolean isBlanked = (mAllDisplayBlankStateFromPowerManager == DISPLAY_BLANK_STATE_BLANKED)
|
||||
&& (info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0;
|
||||
display.configureDisplayInTransactionLocked(device, isBlanked);
|
||||
display.configureDisplayInTransactionLocked(device, info.state == Display.STATE_OFF);
|
||||
|
||||
// Update the viewports if needed.
|
||||
if (!mDefaultViewport.valid
|
||||
@@ -897,8 +875,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
pw.println(" mOnlyCode=" + mOnlyCore);
|
||||
pw.println(" mSafeMode=" + mSafeMode);
|
||||
pw.println(" mPendingTraversal=" + mPendingTraversal);
|
||||
pw.println(" mAllDisplayBlankStateFromPowerManager="
|
||||
+ mAllDisplayBlankStateFromPowerManager);
|
||||
pw.println(" mGlobalDisplayState=" + Display.stateToString(mGlobalDisplayState));
|
||||
pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId);
|
||||
pw.println(" mDefaultViewport=" + mDefaultViewport);
|
||||
pw.println(" mExternalTouchViewport=" + mExternalTouchViewport);
|
||||
@@ -1322,11 +1299,26 @@ public final class DisplayManagerService extends SystemService {
|
||||
|
||||
private final class LocalService extends DisplayManagerInternal {
|
||||
@Override
|
||||
public void initPowerManagement(DisplayPowerCallbacks callbacks, Handler handler,
|
||||
public void initPowerManagement(final DisplayPowerCallbacks callbacks, Handler handler,
|
||||
SensorManager sensorManager) {
|
||||
synchronized (mSyncRoot) {
|
||||
DisplayBlanker blanker = new DisplayBlanker() {
|
||||
@Override
|
||||
public void requestDisplayState(int state) {
|
||||
// The order of operations is important for legacy reasons.
|
||||
if (state == Display.STATE_OFF) {
|
||||
requestGlobalDisplayStateInternal(state);
|
||||
}
|
||||
|
||||
callbacks.onDisplayStateChange(state);
|
||||
|
||||
if (state != Display.STATE_OFF) {
|
||||
requestGlobalDisplayStateInternal(state);
|
||||
}
|
||||
}
|
||||
};
|
||||
mDisplayPowerController = new DisplayPowerController(
|
||||
mContext, callbacks, handler, sensorManager);
|
||||
mContext, callbacks, handler, sensorManager, blanker);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,16 +1334,6 @@ public final class DisplayManagerService extends SystemService {
|
||||
return mDisplayPowerController.isProximitySensorAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blankAllDisplaysFromPowerManager() {
|
||||
blankAllDisplaysFromPowerManagerInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unblankAllDisplaysFromPowerManager() {
|
||||
unblankAllDisplaysFromPowerManagerInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayInfo getDisplayInfo(int displayId) {
|
||||
return getDisplayInfoInternal(displayId, Process.myUid());
|
||||
|
||||
@@ -42,6 +42,7 @@ import android.util.MathUtils;
|
||||
import android.util.Slog;
|
||||
import android.util.Spline;
|
||||
import android.util.TimeUtils;
|
||||
import android.view.Display;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@@ -122,6 +123,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// The sensor manager.
|
||||
private final SensorManager mSensorManager;
|
||||
|
||||
// The display blanker.
|
||||
private final DisplayBlanker mBlanker;
|
||||
|
||||
// The proximity sensor, or null if not available or needed.
|
||||
private Sensor mProximitySensor;
|
||||
|
||||
@@ -225,13 +229,15 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
* Creates the display power controller.
|
||||
*/
|
||||
public DisplayPowerController(Context context,
|
||||
DisplayPowerCallbacks callbacks, Handler handler, SensorManager sensorManager) {
|
||||
DisplayPowerCallbacks callbacks, Handler handler,
|
||||
SensorManager sensorManager, DisplayBlanker blanker) {
|
||||
mHandler = new DisplayControllerHandler(handler.getLooper());
|
||||
mCallbacks = callbacks;
|
||||
|
||||
mBatteryStats = BatteryStatsService.getService();
|
||||
mLights = LocalServices.getService(LightsManager.class);
|
||||
mSensorManager = sensorManager;
|
||||
mBlanker = blanker;
|
||||
|
||||
final Resources resources = context.getResources();
|
||||
|
||||
@@ -366,8 +372,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
mPowerState = new DisplayPowerState(new ElectronBeam(), mCallbacks,
|
||||
mLights.getLight(LightsManager.LIGHT_ID_BACKLIGHT));
|
||||
// Initialize the power state object for the default display.
|
||||
// In the future, we might manage multiple displays independently.
|
||||
mPowerState = new DisplayPowerState(mBlanker,
|
||||
mLights.getLight(LightsManager.LIGHT_ID_BACKLIGHT),
|
||||
new ElectronBeam(Display.DEFAULT_DISPLAY));
|
||||
|
||||
mElectronBeamOnAnimator = ObjectAnimator.ofFloat(
|
||||
mPowerState, DisplayPowerState.ELECTRON_BEAM_LEVEL, 0.0f, 1.0f);
|
||||
@@ -523,7 +532,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// Animate the screen on or off unless blocked.
|
||||
if (mScreenOffBecauseOfProximity) {
|
||||
// Screen off due to proximity.
|
||||
setScreenOn(false);
|
||||
setScreenState(Display.STATE_OFF);
|
||||
unblockScreenOn();
|
||||
} else if (mPowerRequest.wantScreenOnAny()) {
|
||||
// Want screen on.
|
||||
@@ -534,7 +543,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// Turn the screen on. The contents of the screen may not yet
|
||||
// be visible if the electron beam has not been dismissed because
|
||||
// its last frame of animation is solid black.
|
||||
setScreenOn(true);
|
||||
setScreenState(mPowerRequest.screenState == DisplayPowerRequest.SCREEN_STATE_DOZE
|
||||
? Display.STATE_DOZING : Display.STATE_ON);
|
||||
|
||||
if (mPowerRequest.blockScreenOn
|
||||
&& mPowerState.getElectronBeamLevel() == 0.0f) {
|
||||
@@ -567,12 +577,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
if (!mElectronBeamOnAnimator.isStarted()) {
|
||||
if (!mElectronBeamOffAnimator.isStarted()) {
|
||||
if (mPowerState.getElectronBeamLevel() == 0.0f) {
|
||||
setScreenOn(false);
|
||||
setScreenState(Display.STATE_OFF);
|
||||
} else if (mPowerState.prepareElectronBeam(
|
||||
mElectronBeamFadesConfig ?
|
||||
ElectronBeam.MODE_FADE :
|
||||
ElectronBeam.MODE_COOL_DOWN)
|
||||
&& mPowerState.isScreenOn()) {
|
||||
&& mPowerState.getScreenState() != Display.STATE_OFF) {
|
||||
mElectronBeamOffAnimator.start();
|
||||
} else {
|
||||
mElectronBeamOffAnimator.end();
|
||||
@@ -610,9 +620,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
private void blockScreenOn() {
|
||||
if (!mScreenOnWasBlocked) {
|
||||
mScreenOnWasBlocked = true;
|
||||
mScreenOnBlockStartRealTime = SystemClock.elapsedRealtime();
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Blocked screen on.");
|
||||
mScreenOnBlockStartRealTime = SystemClock.elapsedRealtime();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,11 +637,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
}
|
||||
}
|
||||
|
||||
private void setScreenOn(boolean on) {
|
||||
if (mPowerState.isScreenOn() != on) {
|
||||
mPowerState.setScreenOn(on);
|
||||
private void setScreenState(int state) {
|
||||
if (mPowerState.getScreenState() != state) {
|
||||
mPowerState.setScreenState(state);
|
||||
try {
|
||||
if (on) {
|
||||
if (state != Display.STATE_OFF) {
|
||||
mBatteryStats.noteScreenOn();
|
||||
} else {
|
||||
mBatteryStats.noteScreenOff();
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.server.display;
|
||||
|
||||
import com.android.server.lights.Light;
|
||||
|
||||
import android.hardware.display.DisplayManagerInternal.DisplayPowerCallbacks;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -27,6 +26,7 @@ import android.util.FloatProperty;
|
||||
import android.util.IntProperty;
|
||||
import android.util.Slog;
|
||||
import android.view.Choreographer;
|
||||
import android.view.Display;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@@ -54,12 +54,12 @@ final class DisplayPowerState {
|
||||
|
||||
private final Handler mHandler;
|
||||
private final Choreographer mChoreographer;
|
||||
private final ElectronBeam mElectronBeam;
|
||||
private final DisplayPowerCallbacks mCallbacks;
|
||||
private final DisplayBlanker mBlanker;
|
||||
private final Light mBacklight;
|
||||
private final ElectronBeam mElectronBeam;
|
||||
private final PhotonicModulator mPhotonicModulator;
|
||||
|
||||
private boolean mScreenOn;
|
||||
private int mScreenState;
|
||||
private int mScreenBrightness;
|
||||
private boolean mScreenReady;
|
||||
private boolean mScreenUpdatePending;
|
||||
@@ -71,13 +71,12 @@ final class DisplayPowerState {
|
||||
|
||||
private Runnable mCleanListener;
|
||||
|
||||
public DisplayPowerState(ElectronBeam electronBean,
|
||||
DisplayPowerCallbacks callbacks, Light backlight) {
|
||||
public DisplayPowerState(DisplayBlanker blanker, Light backlight, ElectronBeam electronBeam) {
|
||||
mHandler = new Handler(true /*async*/);
|
||||
mChoreographer = Choreographer.getInstance();
|
||||
mElectronBeam = electronBean;
|
||||
mCallbacks = callbacks;
|
||||
mBlanker = blanker;
|
||||
mBacklight = backlight;
|
||||
mElectronBeam = electronBeam;
|
||||
mPhotonicModulator = new PhotonicModulator();
|
||||
|
||||
// At boot time, we know that the screen is on and the electron beam
|
||||
@@ -86,7 +85,7 @@ final class DisplayPowerState {
|
||||
// Although we set the brightness to full on here, the display power controller
|
||||
// will reset the brightness to a new level immediately before the changes
|
||||
// actually have a chance to be applied.
|
||||
mScreenOn = true;
|
||||
mScreenState = Display.STATE_ON;
|
||||
mScreenBrightness = PowerManager.BRIGHTNESS_ON;
|
||||
scheduleScreenUpdate();
|
||||
|
||||
@@ -122,25 +121,25 @@ final class DisplayPowerState {
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets whether the screen is on or off.
|
||||
* Sets whether the screen is on, off, or dozing.
|
||||
*/
|
||||
public void setScreenOn(boolean on) {
|
||||
if (mScreenOn != on) {
|
||||
public void setScreenState(int state) {
|
||||
if (mScreenState != state) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "setScreenOn: on=" + on);
|
||||
Slog.d(TAG, "setScreenState: state=" + state);
|
||||
}
|
||||
|
||||
mScreenOn = on;
|
||||
mScreenState = state;
|
||||
mScreenReady = false;
|
||||
scheduleScreenUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the screen is on.
|
||||
* Gets the desired screen state.
|
||||
*/
|
||||
public boolean isScreenOn() {
|
||||
return mScreenOn;
|
||||
public int getScreenState() {
|
||||
return mScreenState;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +154,7 @@ final class DisplayPowerState {
|
||||
}
|
||||
|
||||
mScreenBrightness = brightness;
|
||||
if (mScreenOn) {
|
||||
if (mScreenState != Display.STATE_OFF) {
|
||||
mScreenReady = false;
|
||||
scheduleScreenUpdate();
|
||||
}
|
||||
@@ -219,7 +218,7 @@ final class DisplayPowerState {
|
||||
}
|
||||
|
||||
mElectronBeamLevel = level;
|
||||
if (mScreenOn) {
|
||||
if (mScreenState != Display.STATE_OFF) {
|
||||
mScreenReady = false;
|
||||
scheduleScreenUpdate(); // update backlight brightness
|
||||
}
|
||||
@@ -256,7 +255,7 @@ final class DisplayPowerState {
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println();
|
||||
pw.println("Display Power State:");
|
||||
pw.println(" mScreenOn=" + mScreenOn);
|
||||
pw.println(" mScreenState=" + Display.stateToString(mScreenState));
|
||||
pw.println(" mScreenBrightness=" + mScreenBrightness);
|
||||
pw.println(" mScreenReady=" + mScreenReady);
|
||||
pw.println(" mScreenUpdatePending=" + mScreenUpdatePending);
|
||||
@@ -302,8 +301,9 @@ final class DisplayPowerState {
|
||||
public void run() {
|
||||
mScreenUpdatePending = false;
|
||||
|
||||
int brightness = mScreenOn && mElectronBeamLevel > 0f ? mScreenBrightness : 0;
|
||||
if (mPhotonicModulator.setState(mScreenOn, brightness)) {
|
||||
int brightness = mScreenState != Display.STATE_OFF
|
||||
&& mElectronBeamLevel > 0f ? mScreenBrightness : 0;
|
||||
if (mPhotonicModulator.setState(mScreenState, brightness)) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Screen ready");
|
||||
}
|
||||
@@ -335,26 +335,26 @@ final class DisplayPowerState {
|
||||
* Updates the state of the screen and backlight asynchronously on a separate thread.
|
||||
*/
|
||||
private final class PhotonicModulator {
|
||||
private static final boolean INITIAL_SCREEN_ON = false; // unknown, assume off
|
||||
private static final int INITIAL_SCREEN_STATE = Display.STATE_OFF; // unknown, assume off
|
||||
private static final int INITIAL_BACKLIGHT = -1; // unknown
|
||||
|
||||
private final Object mLock = new Object();
|
||||
|
||||
private boolean mPendingOn = INITIAL_SCREEN_ON;
|
||||
private int mPendingState = INITIAL_SCREEN_STATE;
|
||||
private int mPendingBacklight = INITIAL_BACKLIGHT;
|
||||
private boolean mActualOn = INITIAL_SCREEN_ON;
|
||||
private int mActualState = INITIAL_SCREEN_STATE;
|
||||
private int mActualBacklight = INITIAL_BACKLIGHT;
|
||||
private boolean mChangeInProgress;
|
||||
|
||||
public boolean setState(boolean on, int backlight) {
|
||||
public boolean setState(int state, int backlight) {
|
||||
synchronized (mLock) {
|
||||
if (on != mPendingOn || backlight != mPendingBacklight) {
|
||||
if (state != mPendingState || backlight != mPendingBacklight) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Requesting new screen state: on=" + on
|
||||
+ ", backlight=" + backlight);
|
||||
Slog.d(TAG, "Requesting new screen state: state="
|
||||
+ Display.stateToString(state) + ", backlight=" + backlight);
|
||||
}
|
||||
|
||||
mPendingOn = on;
|
||||
mPendingState = state;
|
||||
mPendingBacklight = backlight;
|
||||
|
||||
if (!mChangeInProgress) {
|
||||
@@ -369,9 +369,9 @@ final class DisplayPowerState {
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println();
|
||||
pw.println("Photonic Modulator State:");
|
||||
pw.println(" mPendingOn=" + mPendingOn);
|
||||
pw.println(" mPendingState=" + Display.stateToString(mPendingState));
|
||||
pw.println(" mPendingBacklight=" + mPendingBacklight);
|
||||
pw.println(" mActualOn=" + mActualOn);
|
||||
pw.println(" mActualState=" + Display.stateToString(mActualState));
|
||||
pw.println(" mActualBacklight=" + mActualBacklight);
|
||||
pw.println(" mChangeInProgress=" + mChangeInProgress);
|
||||
}
|
||||
@@ -381,35 +381,35 @@ final class DisplayPowerState {
|
||||
public void run() {
|
||||
// Apply pending changes until done.
|
||||
for (;;) {
|
||||
final boolean on;
|
||||
final boolean onChanged;
|
||||
final int state;
|
||||
final boolean stateChanged;
|
||||
final int backlight;
|
||||
final boolean backlightChanged;
|
||||
synchronized (mLock) {
|
||||
on = mPendingOn;
|
||||
onChanged = (on != mActualOn);
|
||||
state = mPendingState;
|
||||
stateChanged = (state != mActualState);
|
||||
backlight = mPendingBacklight;
|
||||
backlightChanged = (backlight != mActualBacklight);
|
||||
if (!onChanged && !backlightChanged) {
|
||||
if (!stateChanged && !backlightChanged) {
|
||||
mChangeInProgress = false;
|
||||
break;
|
||||
}
|
||||
mActualOn = on;
|
||||
mActualState = state;
|
||||
mActualBacklight = backlight;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Updating screen state: on=" + on
|
||||
+ ", backlight=" + backlight);
|
||||
Slog.d(TAG, "Updating screen state: state="
|
||||
+ Display.stateToString(state) + ", backlight=" + backlight);
|
||||
}
|
||||
if (onChanged && on) {
|
||||
mCallbacks.unblankAllDisplays();
|
||||
if (stateChanged && state != Display.STATE_OFF) {
|
||||
mBlanker.requestDisplayState(state);
|
||||
}
|
||||
if (backlightChanged) {
|
||||
mBacklight.setBrightness(backlight);
|
||||
}
|
||||
if (onChanged && !on) {
|
||||
mCallbacks.blankAllDisplays();
|
||||
if (stateChanged && state == Display.STATE_OFF) {
|
||||
mBlanker.requestDisplayState(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import android.opengl.GLES11Ext;
|
||||
import android.os.Looper;
|
||||
import android.util.FloatMath;
|
||||
import android.util.Slog;
|
||||
import android.view.Display;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.Surface.OutOfResourcesException;
|
||||
import android.view.Surface;
|
||||
@@ -74,6 +73,8 @@ final class ElectronBeam {
|
||||
// See code for details.
|
||||
private static final int DEJANK_FRAMES = 3;
|
||||
|
||||
private final int mDisplayId;
|
||||
|
||||
// Set to true when the animation context has been fully prepared.
|
||||
private boolean mPrepared;
|
||||
private int mMode;
|
||||
@@ -118,8 +119,8 @@ final class ElectronBeam {
|
||||
*/
|
||||
public static final int MODE_FADE = 2;
|
||||
|
||||
|
||||
public ElectronBeam() {
|
||||
public ElectronBeam(int displayId) {
|
||||
mDisplayId = displayId;
|
||||
mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ final class ElectronBeam {
|
||||
|
||||
// Get the display size and layer stack.
|
||||
// This is not expected to change while the electron beam surface is showing.
|
||||
DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(Display.DEFAULT_DISPLAY);
|
||||
DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(mDisplayId);
|
||||
mDisplayLayerStack = displayInfo.layerStack;
|
||||
mDisplayWidth = displayInfo.getNaturalWidth();
|
||||
mDisplayHeight = displayInfo.getNaturalHeight();
|
||||
@@ -528,7 +529,8 @@ final class ElectronBeam {
|
||||
mSurface = new Surface();
|
||||
mSurface.copyFrom(mSurfaceControl);
|
||||
|
||||
mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, mSurfaceControl);
|
||||
mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal,
|
||||
mDisplayId, mSurfaceControl);
|
||||
mSurfaceLayout.onDisplayTransaction();
|
||||
} finally {
|
||||
SurfaceControl.closeTransaction();
|
||||
@@ -687,11 +689,13 @@ final class ElectronBeam {
|
||||
*/
|
||||
private static final class NaturalSurfaceLayout implements DisplayTransactionListener {
|
||||
private final DisplayManagerInternal mDisplayManagerInternal;
|
||||
private final int mDisplayId;
|
||||
private SurfaceControl mSurfaceControl;
|
||||
|
||||
public NaturalSurfaceLayout(DisplayManagerInternal displayManagerInternal,
|
||||
SurfaceControl surfaceControl) {
|
||||
int displayId, SurfaceControl surfaceControl) {
|
||||
mDisplayManagerInternal = displayManagerInternal;
|
||||
mDisplayId = displayId;
|
||||
mSurfaceControl = surfaceControl;
|
||||
mDisplayManagerInternal.registerDisplayTransactionListener(this);
|
||||
}
|
||||
@@ -710,8 +714,7 @@ final class ElectronBeam {
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayInfo displayInfo =
|
||||
mDisplayManagerInternal.getDisplayInfo(Display.DEFAULT_DISPLAY);
|
||||
DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(mDisplayId);
|
||||
switch (displayInfo.rotation) {
|
||||
case Surface.ROTATION_0:
|
||||
mSurfaceControl.setPosition(0, 0);
|
||||
|
||||
@@ -101,7 +101,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
|
||||
private DisplayDeviceInfo mInfo;
|
||||
private boolean mHavePendingChanges;
|
||||
private boolean mBlanked;
|
||||
private int mState = Display.STATE_UNKNOWN;
|
||||
|
||||
public LocalDisplayDevice(IBinder displayToken, int builtInDisplayId,
|
||||
SurfaceControl.PhysicalDisplayInfo phys) {
|
||||
@@ -134,6 +134,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
mInfo.width = mPhys.width;
|
||||
mInfo.height = mPhys.height;
|
||||
mInfo.refreshRate = mPhys.refreshRate;
|
||||
mInfo.state = mState;
|
||||
|
||||
// Assume that all built-in displays that have secure output (eg. HDCP) also
|
||||
// support compositing from gralloc protected buffers.
|
||||
@@ -177,15 +178,16 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blankLocked() {
|
||||
mBlanked = true;
|
||||
SurfaceControl.blankDisplay(getDisplayTokenLocked());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unblankLocked() {
|
||||
mBlanked = false;
|
||||
SurfaceControl.unblankDisplay(getDisplayTokenLocked());
|
||||
public void requestDisplayStateLocked(int state) {
|
||||
if (mState != state) {
|
||||
if (state == Display.STATE_OFF && mState != Display.STATE_OFF) {
|
||||
SurfaceControl.blankDisplay(getDisplayTokenLocked());
|
||||
} else if (state != Display.STATE_OFF && mState == Display.STATE_OFF) {
|
||||
SurfaceControl.unblankDisplay(getDisplayTokenLocked());
|
||||
}
|
||||
mState = state;
|
||||
updateDeviceInfoLocked();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +195,12 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
super.dumpLocked(pw);
|
||||
pw.println("mBuiltInDisplayId=" + mBuiltInDisplayId);
|
||||
pw.println("mPhys=" + mPhys);
|
||||
pw.println("mBlanked=" + mBlanked);
|
||||
pw.println("mState=" + Display.stateToString(mState));
|
||||
}
|
||||
|
||||
private void updateDeviceInfoLocked() {
|
||||
mInfo = null;
|
||||
sendDisplayDeviceEventLocked(this, DISPLAY_DEVICE_EVENT_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ final class LogicalDisplay {
|
||||
mInfo.copyFrom(mOverrideDisplayInfo);
|
||||
mInfo.layerStack = mBaseDisplayInfo.layerStack;
|
||||
mInfo.name = mBaseDisplayInfo.name;
|
||||
mInfo.state = mBaseDisplayInfo.state;
|
||||
} else {
|
||||
mInfo.copyFrom(mBaseDisplayInfo);
|
||||
}
|
||||
@@ -212,6 +213,7 @@ final class LogicalDisplay {
|
||||
mBaseDisplayInfo.logicalDensityDpi = deviceInfo.densityDpi;
|
||||
mBaseDisplayInfo.physicalXDpi = deviceInfo.xDpi;
|
||||
mBaseDisplayInfo.physicalYDpi = deviceInfo.yDpi;
|
||||
mBaseDisplayInfo.state = deviceInfo.state;
|
||||
mBaseDisplayInfo.smallestNominalAppWidth = deviceInfo.width;
|
||||
mBaseDisplayInfo.smallestNominalAppHeight = deviceInfo.height;
|
||||
mBaseDisplayInfo.largestNominalAppWidth = deviceInfo.width;
|
||||
|
||||
@@ -194,12 +194,14 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
||||
private final int mDensityDpi;
|
||||
private final boolean mSecure;
|
||||
|
||||
private Surface mSurface;
|
||||
private int mState;
|
||||
private SurfaceTexture mSurfaceTexture;
|
||||
private Surface mSurface;
|
||||
private DisplayDeviceInfo mInfo;
|
||||
|
||||
public OverlayDisplayDevice(IBinder displayToken, String name,
|
||||
int width, int height, float refreshRate, int densityDpi, boolean secure,
|
||||
int width, int height, float refreshRate,
|
||||
int densityDpi, boolean secure, int state,
|
||||
SurfaceTexture surfaceTexture) {
|
||||
super(OverlayDisplayAdapter.this, displayToken);
|
||||
mName = name;
|
||||
@@ -208,6 +210,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
||||
mRefreshRate = refreshRate;
|
||||
mDensityDpi = densityDpi;
|
||||
mSecure = secure;
|
||||
mState = state;
|
||||
mSurfaceTexture = surfaceTexture;
|
||||
}
|
||||
|
||||
@@ -230,6 +233,11 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void setStateLocked(int state) {
|
||||
mState = state;
|
||||
mInfo = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
|
||||
if (mInfo == null) {
|
||||
@@ -247,6 +255,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
||||
}
|
||||
mInfo.type = Display.TYPE_OVERLAY;
|
||||
mInfo.touch = DisplayDeviceInfo.TOUCH_NONE;
|
||||
mInfo.state = mState;
|
||||
}
|
||||
return mInfo;
|
||||
}
|
||||
@@ -288,11 +297,12 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
||||
|
||||
// Called on the UI thread.
|
||||
@Override
|
||||
public void onWindowCreated(SurfaceTexture surfaceTexture, float refreshRate) {
|
||||
public void onWindowCreated(SurfaceTexture surfaceTexture, float refreshRate, int state) {
|
||||
synchronized (getSyncRoot()) {
|
||||
IBinder displayToken = SurfaceControl.createDisplay(mName, mSecure);
|
||||
mDevice = new OverlayDisplayDevice(displayToken, mName,
|
||||
mWidth, mHeight, refreshRate, mDensityDpi, mSecure, surfaceTexture);
|
||||
mWidth, mHeight, refreshRate, mDensityDpi, mSecure,
|
||||
state, surfaceTexture);
|
||||
|
||||
sendDisplayDeviceEventLocked(mDevice, DISPLAY_DEVICE_EVENT_ADDED);
|
||||
}
|
||||
@@ -309,6 +319,17 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
// Called on the UI thread.
|
||||
@Override
|
||||
public void onStateChanged(int state) {
|
||||
synchronized (getSyncRoot()) {
|
||||
if (mDevice != null) {
|
||||
mDevice.setStateLocked(state);
|
||||
sendDisplayDeviceEventLocked(mDevice, DISPLAY_DEVICE_EVENT_CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpLocked(PrintWriter pw) {
|
||||
pw.println(" " + mName + ":");
|
||||
pw.println(" mWidth=" + mWidth);
|
||||
|
||||
@@ -282,6 +282,7 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
|
||||
if (displayId == mDefaultDisplay.getDisplayId()) {
|
||||
if (updateDefaultDisplayInfo()) {
|
||||
relayout();
|
||||
mListener.onStateChanged(mDefaultDisplayInfo.state);
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
@@ -301,7 +302,8 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,
|
||||
int width, int height) {
|
||||
mListener.onWindowCreated(surfaceTexture, mDefaultDisplayInfo.refreshRate);
|
||||
mListener.onWindowCreated(surfaceTexture, mDefaultDisplayInfo.refreshRate,
|
||||
mDefaultDisplayInfo.state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -370,7 +372,9 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
|
||||
* Watches for significant changes in the overlay display window lifecycle.
|
||||
*/
|
||||
public interface Listener {
|
||||
public void onWindowCreated(SurfaceTexture surfaceTexture, float refreshRate);
|
||||
public void onWindowCreated(SurfaceTexture surfaceTexture,
|
||||
float refreshRate, int state);
|
||||
public void onWindowDestroyed();
|
||||
public void onStateChanged(int state);
|
||||
}
|
||||
}
|
||||
@@ -185,6 +185,7 @@ public class InputManagerService extends IInputManager.Stub
|
||||
InputChannel fromChannel, InputChannel toChannel);
|
||||
private static native void nativeSetPointerSpeed(long ptr, int speed);
|
||||
private static native void nativeSetShowTouches(long ptr, boolean enabled);
|
||||
private static native void nativeSetInteractive(long ptr, boolean interactive);
|
||||
private static native void nativeReloadCalibration(long ptr);
|
||||
private static native void nativeVibrate(long ptr, int deviceId, long[] pattern,
|
||||
int repeat, int token);
|
||||
@@ -1404,14 +1405,13 @@ public class InputManagerService extends IInputManager.Stub
|
||||
}
|
||||
|
||||
// Native callback.
|
||||
private int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) {
|
||||
return mWindowManagerCallbacks.interceptKeyBeforeQueueing(
|
||||
event, policyFlags, isScreenOn);
|
||||
private int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
|
||||
return mWindowManagerCallbacks.interceptKeyBeforeQueueing(event, policyFlags);
|
||||
}
|
||||
|
||||
// Native callback.
|
||||
private int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags) {
|
||||
return mWindowManagerCallbacks.interceptMotionBeforeQueueingWhenScreenOff(
|
||||
private int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) {
|
||||
return mWindowManagerCallbacks.interceptWakeMotionBeforeQueueing(
|
||||
whenNanos, policyFlags);
|
||||
}
|
||||
|
||||
@@ -1570,9 +1570,9 @@ public class InputManagerService extends IInputManager.Stub
|
||||
public long notifyANR(InputApplicationHandle inputApplicationHandle,
|
||||
InputWindowHandle inputWindowHandle, String reason);
|
||||
|
||||
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
|
||||
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
|
||||
|
||||
public int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags);
|
||||
public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags);
|
||||
|
||||
public long interceptKeyBeforeDispatching(InputWindowHandle focus,
|
||||
KeyEvent event, int policyFlags);
|
||||
@@ -1740,5 +1740,10 @@ public class InputManagerService extends IInputManager.Stub
|
||||
public boolean injectInputEvent(InputEvent event, int displayId, int mode) {
|
||||
return injectInputEventInternal(event, displayId, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteractive(boolean interactive) {
|
||||
nativeSetInteractive(mPtr, interactive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1730,7 +1730,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
||||
private void updateScreenOn() {
|
||||
synchronized (mRulesLock) {
|
||||
try {
|
||||
mScreenOn = mPowerManager.isScreenOn();
|
||||
mScreenOn = mPowerManager.isInteractive();
|
||||
} catch (RemoteException e) {
|
||||
// ignored; service lives in system_server
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.app.ActivityManagerNative;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.input.InputManagerInternal;
|
||||
import android.media.AudioManager;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
@@ -86,6 +87,7 @@ final class Notifier {
|
||||
private final ScreenOnBlocker mScreenOnBlocker;
|
||||
private final WindowManagerPolicy mPolicy;
|
||||
private final ActivityManagerInternal mActivityManagerInternal;
|
||||
private final InputManagerInternal mInputManagerInternal;
|
||||
|
||||
private final NotifierHandler mHandler;
|
||||
private final Intent mScreenOnIntent;
|
||||
@@ -121,6 +123,7 @@ final class Notifier {
|
||||
mScreenOnBlocker = screenOnBlocker;
|
||||
mPolicy = policy;
|
||||
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
|
||||
mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
|
||||
|
||||
mHandler = new NotifierHandler(looper);
|
||||
mScreenOnIntent = new Intent(Intent.ACTION_SCREEN_ON);
|
||||
@@ -232,73 +235,58 @@ final class Notifier {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the device is waking up from sleep and the
|
||||
* display is about to be turned on.
|
||||
* Notifies that the device is changing interactive state.
|
||||
*/
|
||||
public void onWakeUpStarted() {
|
||||
public void onInteractiveStateChangeStarted(boolean interactive, int reason) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "onWakeUpStarted");
|
||||
Slog.d(TAG, "onInteractiveChangeStarted: interactive=" + interactive
|
||||
+ ", reason=" + reason);
|
||||
}
|
||||
|
||||
synchronized (mLock) {
|
||||
if (mActualPowerState != POWER_STATE_AWAKE) {
|
||||
mActualPowerState = POWER_STATE_AWAKE;
|
||||
mPendingWakeUpBroadcast = true;
|
||||
if (!mScreenOnBlockerAcquired) {
|
||||
mScreenOnBlockerAcquired = true;
|
||||
mScreenOnBlocker.acquire();
|
||||
if (interactive) {
|
||||
// Waking up...
|
||||
if (mActualPowerState != POWER_STATE_AWAKE) {
|
||||
mActualPowerState = POWER_STATE_AWAKE;
|
||||
mPendingWakeUpBroadcast = true;
|
||||
if (!mScreenOnBlockerAcquired) {
|
||||
mScreenOnBlockerAcquired = true;
|
||||
mScreenOnBlocker.acquire();
|
||||
}
|
||||
updatePendingBroadcastLocked();
|
||||
}
|
||||
updatePendingBroadcastLocked();
|
||||
} else {
|
||||
// Going to sleep...
|
||||
mLastGoToSleepReason = reason;
|
||||
}
|
||||
mInputManagerInternal.setInteractive(interactive);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the device has finished waking up from sleep
|
||||
* and the display has been turned on.
|
||||
* Notifies that the device has finished changing interactive state.
|
||||
*/
|
||||
public void onWakeUpFinished() {
|
||||
public void onInteractiveStateChangeFinished(boolean interactive) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "onWakeUpFinished");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the device is going to sleep.
|
||||
*/
|
||||
public void onGoToSleepStarted(int reason) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "onGoToSleepStarted");
|
||||
Slog.d(TAG, "onInteractiveChangeFinished");
|
||||
}
|
||||
|
||||
synchronized (mLock) {
|
||||
mLastGoToSleepReason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the device has finished going to sleep and the
|
||||
* display has been turned off.
|
||||
*
|
||||
* This is a good time to make transitions that we don't want the user to see,
|
||||
* such as bringing the key guard to focus. There's no guarantee for this,
|
||||
* however because the user could turn the device on again at any time.
|
||||
* Some things may need to be protected by other mechanisms that defer screen on.
|
||||
*/
|
||||
public void onGoToSleepFinished() {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "onGoToSleepFinished");
|
||||
}
|
||||
|
||||
synchronized (mLock) {
|
||||
if (mActualPowerState != POWER_STATE_ASLEEP) {
|
||||
mActualPowerState = POWER_STATE_ASLEEP;
|
||||
mPendingGoToSleepBroadcast = true;
|
||||
if (mUserActivityPending) {
|
||||
mUserActivityPending = false;
|
||||
mHandler.removeMessages(MSG_USER_ACTIVITY);
|
||||
if (!interactive) {
|
||||
// Finished going to sleep...
|
||||
// This is a good time to make transitions that we don't want the user to see,
|
||||
// such as bringing the key guard to focus. There's no guarantee for this,
|
||||
// however because the user could turn the device on again at any time.
|
||||
// Some things may need to be protected by other mechanisms that defer screen on.
|
||||
if (mActualPowerState != POWER_STATE_ASLEEP) {
|
||||
mActualPowerState = POWER_STATE_ASLEEP;
|
||||
mPendingGoToSleepBroadcast = true;
|
||||
if (mUserActivityPending) {
|
||||
mUserActivityPending = false;
|
||||
mHandler.removeMessages(MSG_USER_ACTIVITY);
|
||||
}
|
||||
updatePendingBroadcastLocked();
|
||||
}
|
||||
updatePendingBroadcastLocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.util.TimeUtils;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManagerPolicy;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@@ -209,6 +210,10 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
// A bitfield that summarizes the state of all active wakelocks.
|
||||
private int mWakeLockSummary;
|
||||
|
||||
// True if the device is in an interactive state.
|
||||
private boolean mInteractive;
|
||||
private boolean mInteractiveChanging;
|
||||
|
||||
// If true, instructs the display controller to wait for the proximity sensor to
|
||||
// go negative before turning the screen on.
|
||||
private boolean mRequestWaitForNegativeProximity;
|
||||
@@ -217,11 +222,6 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
private long mLastWakeTime;
|
||||
private long mLastSleepTime;
|
||||
|
||||
// True if we need to send a wake up or go to sleep finished notification
|
||||
// when the display is ready.
|
||||
private boolean mSendWakeUpFinishedNotificationWhenReady;
|
||||
private boolean mSendGoToSleepFinishedNotificationWhenReady;
|
||||
|
||||
// Timestamp of the last call to user activity.
|
||||
private long mLastUserActivityTime;
|
||||
private long mLastUserActivityTimeNoChangeLights;
|
||||
@@ -265,11 +265,11 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
// True if auto-suspend mode is enabled.
|
||||
// Refer to autosuspend.h.
|
||||
private boolean mAutoSuspendModeEnabled;
|
||||
private boolean mHalAutoSuspendModeEnabled;
|
||||
|
||||
// True if interactive mode is enabled.
|
||||
// Refer to power.h.
|
||||
private boolean mInteractiveModeEnabled;
|
||||
private boolean mHalInteractiveModeEnabled;
|
||||
|
||||
// True if the device is plugged into a power source.
|
||||
private boolean mIsPowered;
|
||||
@@ -289,10 +289,10 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
private int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
|
||||
|
||||
// True to decouple auto-suspend mode from the display state.
|
||||
private boolean mDecoupleAutoSuspendModeFromDisplayConfig;
|
||||
private boolean mDecoupleHalAutoSuspendModeFromDisplayConfig;
|
||||
|
||||
// True to decouple interactive mode from the display state.
|
||||
private boolean mDecoupleInteractiveModeFromDisplayConfig;
|
||||
private boolean mDecoupleHalInteractiveModeFromDisplayConfig;
|
||||
|
||||
// True if the device should wake up when plugged or unplugged.
|
||||
private boolean mWakeUpWhenPluggedOrUnpluggedConfig;
|
||||
@@ -397,7 +397,6 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
private native void nativeInit();
|
||||
|
||||
private static native void nativeSetPowerState(boolean screenOn, boolean screenBright);
|
||||
private static native void nativeAcquireSuspendBlocker(String name);
|
||||
private static native void nativeReleaseSuspendBlocker(String name);
|
||||
private static native void nativeSetInteractive(boolean enable);
|
||||
@@ -412,13 +411,17 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
mDisplaySuspendBlocker = createSuspendBlockerLocked("PowerManagerService.Display");
|
||||
mDisplaySuspendBlocker.acquire();
|
||||
mHoldingDisplaySuspendBlocker = true;
|
||||
mHalAutoSuspendModeEnabled = false;
|
||||
mHalInteractiveModeEnabled = true;
|
||||
|
||||
mScreenOnBlocker = new ScreenOnBlockerImpl();
|
||||
mWakefulness = WAKEFULNESS_AWAKE;
|
||||
}
|
||||
mInteractive = true;
|
||||
|
||||
nativeInit();
|
||||
nativeSetPowerState(true, true);
|
||||
nativeInit();
|
||||
nativeSetAutoSuspend(false);
|
||||
nativeSetInteractive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -446,14 +449,6 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
Watchdog.getInstance().addMonitor(this);
|
||||
Watchdog.getInstance().addThread(mHandler);
|
||||
|
||||
// Forcibly turn the screen on at boot so that it is in a known power state.
|
||||
// We do this in init() rather than in the constructor because setting the
|
||||
// screen state requires a call into surface flinger which then needs to call back
|
||||
// into the activity manager to check permissions. Unfortunately the
|
||||
// activity manager is not running when the constructor is called, so we
|
||||
// have to defer setting the screen state until this point.
|
||||
mDisplayPowerCallbacks.unblankAllDisplays();
|
||||
}
|
||||
|
||||
void setPolicy(WindowManagerPolicy policy) {
|
||||
@@ -547,9 +542,9 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
private void readConfigurationLocked() {
|
||||
final Resources resources = mContext.getResources();
|
||||
|
||||
mDecoupleAutoSuspendModeFromDisplayConfig = resources.getBoolean(
|
||||
mDecoupleHalAutoSuspendModeFromDisplayConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_powerDecoupleAutoSuspendModeFromDisplay);
|
||||
mDecoupleInteractiveModeFromDisplayConfig = resources.getBoolean(
|
||||
mDecoupleHalInteractiveModeFromDisplayConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_powerDecoupleInteractiveModeFromDisplay);
|
||||
mWakeUpWhenPluggedOrUnpluggedConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_unplugTurnsOnScreen);
|
||||
@@ -867,11 +862,6 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called from native code.
|
||||
private void wakeUpFromNative(long eventTime) {
|
||||
wakeUpInternal(eventTime);
|
||||
}
|
||||
|
||||
private void wakeUpInternal(long eventTime) {
|
||||
synchronized (mLock) {
|
||||
if (wakeUpNoUpdateLocked(eventTime)) {
|
||||
@@ -902,26 +892,16 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
break;
|
||||
}
|
||||
|
||||
if (mWakefulness != WAKEFULNESS_DREAMING) {
|
||||
sendPendingNotificationsLocked();
|
||||
mNotifier.onWakeUpStarted();
|
||||
mSendWakeUpFinishedNotificationWhenReady = true;
|
||||
}
|
||||
|
||||
mLastWakeTime = eventTime;
|
||||
mWakefulness = WAKEFULNESS_AWAKE;
|
||||
mDirty |= DIRTY_WAKEFULNESS;
|
||||
mWakefulness = WAKEFULNESS_AWAKE;
|
||||
setInteractiveStateLocked(true, 0);
|
||||
|
||||
userActivityNoUpdateLocked(
|
||||
eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called from native code.
|
||||
private void goToSleepFromNative(long eventTime, int reason) {
|
||||
goToSleepInternal(eventTime, reason);
|
||||
}
|
||||
|
||||
private void goToSleepInternal(long eventTime, int reason) {
|
||||
synchronized (mLock) {
|
||||
if (goToSleepNoUpdateLocked(eventTime, reason)) {
|
||||
@@ -958,14 +938,11 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
break;
|
||||
}
|
||||
|
||||
sendPendingNotificationsLocked();
|
||||
mNotifier.onGoToSleepStarted(reason);
|
||||
mSendGoToSleepFinishedNotificationWhenReady = true;
|
||||
|
||||
mLastSleepTime = eventTime;
|
||||
mDirty |= DIRTY_WAKEFULNESS;
|
||||
mWakefulness = WAKEFULNESS_DOZING;
|
||||
mSandmanSummoned = true;
|
||||
setInteractiveStateLocked(false, reason);
|
||||
|
||||
// Report the number of wake locks that will be cleared by going to sleep.
|
||||
int numWakeLocksCleared = 0;
|
||||
@@ -1007,6 +984,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
mDirty |= DIRTY_WAKEFULNESS;
|
||||
mWakefulness = WAKEFULNESS_DREAMING;
|
||||
mSandmanSummoned = true;
|
||||
setInteractiveStateLocked(true, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1025,9 +1003,27 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
mDirty |= DIRTY_WAKEFULNESS;
|
||||
mWakefulness = WAKEFULNESS_ASLEEP;
|
||||
setInteractiveStateLocked(false, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setInteractiveStateLocked(boolean interactive, int reason) {
|
||||
if (mInteractive != interactive) {
|
||||
finishInteractiveStateChangeLocked();
|
||||
|
||||
mInteractive = interactive;
|
||||
mInteractiveChanging = true;
|
||||
mNotifier.onInteractiveStateChangeStarted(interactive, reason);
|
||||
}
|
||||
}
|
||||
|
||||
private void finishInteractiveStateChangeLocked() {
|
||||
if (mInteractiveChanging) {
|
||||
mNotifier.onInteractiveStateChangeFinished(mInteractive);
|
||||
mInteractiveChanging = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the global power state based on dirty bits recorded in mDirty.
|
||||
*
|
||||
@@ -1071,7 +1067,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
// Phase 3: Send notifications, if needed.
|
||||
if (mDisplayReady) {
|
||||
sendPendingNotificationsLocked();
|
||||
finishInteractiveStateChangeLocked();
|
||||
}
|
||||
|
||||
// Phase 4: Update suspend blocker.
|
||||
@@ -1080,17 +1076,6 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
updateSuspendBlockerLocked();
|
||||
}
|
||||
|
||||
private void sendPendingNotificationsLocked() {
|
||||
if (mSendWakeUpFinishedNotificationWhenReady) {
|
||||
mSendWakeUpFinishedNotificationWhenReady = false;
|
||||
mNotifier.onWakeUpFinished();
|
||||
}
|
||||
if (mSendGoToSleepFinishedNotificationWhenReady) {
|
||||
mSendGoToSleepFinishedNotificationWhenReady = false;
|
||||
mNotifier.onGoToSleepFinished();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the value of mIsPowered.
|
||||
* Sets DIRTY_IS_POWERED if a change occurred.
|
||||
@@ -1210,48 +1195,45 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
mWakeLockSummary |= WAKE_LOCK_CPU;
|
||||
break;
|
||||
case PowerManager.FULL_WAKE_LOCK:
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE
|
||||
|| mWakefulness == WAKEFULNESS_DREAMING) {
|
||||
mWakeLockSummary |= WAKE_LOCK_CPU
|
||||
| WAKE_LOCK_SCREEN_BRIGHT | WAKE_LOCK_BUTTON_BRIGHT;
|
||||
}
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE) {
|
||||
mWakeLockSummary |= WAKE_LOCK_STAY_AWAKE;
|
||||
}
|
||||
mWakeLockSummary |= WAKE_LOCK_SCREEN_BRIGHT | WAKE_LOCK_BUTTON_BRIGHT;
|
||||
break;
|
||||
case PowerManager.SCREEN_BRIGHT_WAKE_LOCK:
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE
|
||||
|| mWakefulness == WAKEFULNESS_DREAMING) {
|
||||
mWakeLockSummary |= WAKE_LOCK_CPU | WAKE_LOCK_SCREEN_BRIGHT;
|
||||
}
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE) {
|
||||
mWakeLockSummary |= WAKE_LOCK_STAY_AWAKE;
|
||||
}
|
||||
mWakeLockSummary |= WAKE_LOCK_SCREEN_BRIGHT;
|
||||
break;
|
||||
case PowerManager.SCREEN_DIM_WAKE_LOCK:
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE
|
||||
|| mWakefulness == WAKEFULNESS_DREAMING) {
|
||||
mWakeLockSummary |= WAKE_LOCK_CPU | WAKE_LOCK_SCREEN_DIM;
|
||||
}
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE) {
|
||||
mWakeLockSummary |= WAKE_LOCK_STAY_AWAKE;
|
||||
}
|
||||
mWakeLockSummary |= WAKE_LOCK_SCREEN_DIM;
|
||||
break;
|
||||
case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK:
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE
|
||||
|| mWakefulness == WAKEFULNESS_DREAMING
|
||||
|| mWakefulness == WAKEFULNESS_DOZING) {
|
||||
mWakeLockSummary |= WAKE_LOCK_PROXIMITY_SCREEN_OFF;
|
||||
}
|
||||
mWakeLockSummary |= WAKE_LOCK_PROXIMITY_SCREEN_OFF;
|
||||
break;
|
||||
case PowerManager.DOZE_WAKE_LOCK:
|
||||
if (mWakefulness == WAKEFULNESS_DOZING) {
|
||||
mWakeLockSummary |= WAKE_LOCK_DOZE;
|
||||
}
|
||||
mWakeLockSummary |= WAKE_LOCK_DOZE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel wake locks that make no sense based on the current state.
|
||||
if (mWakefulness != WAKEFULNESS_DOZING) {
|
||||
mWakeLockSummary &= ~WAKE_LOCK_DOZE;
|
||||
}
|
||||
if (mWakefulness == WAKEFULNESS_ASLEEP
|
||||
|| (mWakeLockSummary & WAKE_LOCK_DOZE) != 0) {
|
||||
mWakeLockSummary &= ~(WAKE_LOCK_SCREEN_BRIGHT | WAKE_LOCK_SCREEN_DIM
|
||||
| WAKE_LOCK_BUTTON_BRIGHT);
|
||||
if (mWakefulness == WAKEFULNESS_ASLEEP) {
|
||||
mWakeLockSummary &= ~WAKE_LOCK_PROXIMITY_SCREEN_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
// Infer implied wake locks where necessary based on the current state.
|
||||
if ((mWakeLockSummary & (WAKE_LOCK_SCREEN_BRIGHT | WAKE_LOCK_SCREEN_DIM)) != 0) {
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE) {
|
||||
mWakeLockSummary |= WAKE_LOCK_CPU | WAKE_LOCK_STAY_AWAKE;
|
||||
} else if (mWakefulness == WAKEFULNESS_DREAMING) {
|
||||
mWakeLockSummary |= WAKE_LOCK_CPU;
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG_SPEW) {
|
||||
Slog.d(TAG, "updateWakeLockSummaryLocked: mWakefulness="
|
||||
+ wakefulnessToString(mWakefulness)
|
||||
@@ -1269,12 +1251,14 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
*/
|
||||
private void updateUserActivitySummaryLocked(long now, int dirty) {
|
||||
// Update the status of the user activity timeout timer.
|
||||
if ((dirty & (DIRTY_USER_ACTIVITY | DIRTY_WAKEFULNESS | DIRTY_SETTINGS)) != 0) {
|
||||
if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY
|
||||
| DIRTY_WAKEFULNESS | DIRTY_SETTINGS)) != 0) {
|
||||
mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT);
|
||||
|
||||
long nextTimeout = 0;
|
||||
if (mWakefulness == WAKEFULNESS_AWAKE
|
||||
|| mWakefulness == WAKEFULNESS_DREAMING) {
|
||||
|| mWakefulness == WAKEFULNESS_DREAMING
|
||||
|| mWakefulness == WAKEFULNESS_DOZING) {
|
||||
final int screenOffTimeout = getScreenOffTimeoutLocked();
|
||||
final int screenDimDuration = getScreenDimDurationLocked(screenOffTimeout);
|
||||
|
||||
@@ -1598,8 +1582,6 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
| DIRTY_SETTINGS | DIRTY_SCREEN_ON_BLOCKER_RELEASED)) != 0) {
|
||||
final int newScreenState = getDesiredScreenPowerStateLocked();
|
||||
mDisplayPowerRequest.screenState = newScreenState;
|
||||
nativeSetPowerState(isScreenOnLocked(),
|
||||
newScreenState == DisplayPowerRequest.SCREEN_STATE_BRIGHT);
|
||||
|
||||
int screenBrightness = mScreenBrightnessSettingDefault;
|
||||
float screenAutoBrightnessAdjustment = 0.0f;
|
||||
@@ -1681,7 +1663,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
private final DisplayManagerInternal.DisplayPowerCallbacks mDisplayPowerCallbacks =
|
||||
new DisplayManagerInternal.DisplayPowerCallbacks() {
|
||||
private boolean mBlanked;
|
||||
private int mDisplayState = Display.STATE_UNKNOWN;
|
||||
|
||||
@Override
|
||||
public void onStateChanged() {
|
||||
@@ -1711,6 +1693,33 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayStateChange(int state) {
|
||||
// This method is only needed to support legacy display blanking behavior
|
||||
// where the display's power state is coupled to suspend or to the power HAL.
|
||||
// The order of operations matters here.
|
||||
synchronized (mLock) {
|
||||
if (mDisplayState != state) {
|
||||
mDisplayState = state;
|
||||
if (state == Display.STATE_OFF) {
|
||||
if (!mDecoupleHalInteractiveModeFromDisplayConfig) {
|
||||
setHalInteractiveModeLocked(false);
|
||||
}
|
||||
if (!mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
||||
setHalAutoSuspendModeLocked(true);
|
||||
}
|
||||
} else {
|
||||
if (!mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
||||
setHalAutoSuspendModeLocked(false);
|
||||
}
|
||||
if (!mDecoupleHalInteractiveModeFromDisplayConfig) {
|
||||
setHalInteractiveModeLocked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acquireSuspendBlocker() {
|
||||
mDisplaySuspendBlocker.acquire();
|
||||
@@ -1721,38 +1730,10 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
mDisplaySuspendBlocker.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blankAllDisplays() {
|
||||
synchronized (this) {
|
||||
mBlanked = true;
|
||||
mDisplayManagerInternal.blankAllDisplaysFromPowerManager();
|
||||
if (!mDecoupleInteractiveModeFromDisplayConfig) {
|
||||
setInteractiveModeLocked(false);
|
||||
}
|
||||
if (!mDecoupleAutoSuspendModeFromDisplayConfig) {
|
||||
setAutoSuspendModeLocked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unblankAllDisplays() {
|
||||
synchronized (this) {
|
||||
if (!mDecoupleAutoSuspendModeFromDisplayConfig) {
|
||||
setAutoSuspendModeLocked(false);
|
||||
}
|
||||
if (!mDecoupleInteractiveModeFromDisplayConfig) {
|
||||
setInteractiveModeLocked(true);
|
||||
}
|
||||
mDisplayManagerInternal.unblankAllDisplaysFromPowerManager();
|
||||
mBlanked = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
synchronized (this) {
|
||||
return "blanked=" + mBlanked;
|
||||
return "state=" + Display.stateToString(mDisplayState);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1773,11 +1754,11 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
// Disable auto-suspend if needed.
|
||||
if (!autoSuspend) {
|
||||
if (mDecoupleAutoSuspendModeFromDisplayConfig) {
|
||||
setAutoSuspendModeLocked(false);
|
||||
if (mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
||||
setHalAutoSuspendModeLocked(false);
|
||||
}
|
||||
if (mDecoupleInteractiveModeFromDisplayConfig) {
|
||||
setInteractiveModeLocked(true);
|
||||
if (mDecoupleHalInteractiveModeFromDisplayConfig) {
|
||||
setHalInteractiveModeLocked(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1803,11 +1784,11 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
// Enable auto-suspend if needed.
|
||||
if (autoSuspend) {
|
||||
if (mDecoupleInteractiveModeFromDisplayConfig) {
|
||||
setInteractiveModeLocked(false);
|
||||
if (mDecoupleHalInteractiveModeFromDisplayConfig) {
|
||||
setHalInteractiveModeLocked(false);
|
||||
}
|
||||
if (mDecoupleAutoSuspendModeFromDisplayConfig) {
|
||||
setAutoSuspendModeLocked(true);
|
||||
if (mDecoupleHalAutoSuspendModeFromDisplayConfig) {
|
||||
setHalAutoSuspendModeLocked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1834,42 +1815,32 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setAutoSuspendModeLocked(boolean enable) {
|
||||
if (enable != mAutoSuspendModeEnabled) {
|
||||
private void setHalAutoSuspendModeLocked(boolean enable) {
|
||||
if (enable != mHalAutoSuspendModeEnabled) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Setting auto-suspend mode to " + enable);
|
||||
Slog.d(TAG, "Setting HAL auto-suspend mode to " + enable);
|
||||
}
|
||||
mAutoSuspendModeEnabled = enable;
|
||||
mHalAutoSuspendModeEnabled = enable;
|
||||
nativeSetAutoSuspend(enable);
|
||||
}
|
||||
}
|
||||
|
||||
private void setInteractiveModeLocked(boolean enable) {
|
||||
if (enable != mInteractiveModeEnabled) {
|
||||
private void setHalInteractiveModeLocked(boolean enable) {
|
||||
if (enable != mHalInteractiveModeEnabled) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Setting interactive mode to " + enable);
|
||||
Slog.d(TAG, "Setting HAL interactive mode to " + enable);
|
||||
}
|
||||
mInteractiveModeEnabled = enable;
|
||||
mHalInteractiveModeEnabled = enable;
|
||||
nativeSetInteractive(enable);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isScreenOnInternal() {
|
||||
private boolean isInteractiveInternal() {
|
||||
synchronized (mLock) {
|
||||
// XXX This is a temporary hack to let certain parts of the system pretend the
|
||||
// screen is still on even when dozing and we would normally want to report
|
||||
// screen off. Will be removed when the window manager is modified to use
|
||||
// the true blanking state of the display.
|
||||
return isScreenOnLocked()
|
||||
|| mWakefulness == WAKEFULNESS_DOZING;
|
||||
return mInteractive;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isScreenOnLocked() {
|
||||
return mWakefulness == WAKEFULNESS_AWAKE
|
||||
|| mWakefulness == WAKEFULNESS_DREAMING;
|
||||
}
|
||||
|
||||
private void handleBatteryStateChangedLocked() {
|
||||
mDirty |= DIRTY_BATTERY_STATE;
|
||||
updatePowerStateLocked();
|
||||
@@ -2090,6 +2061,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
pw.println("Power Manager State:");
|
||||
pw.println(" mDirty=0x" + Integer.toHexString(mDirty));
|
||||
pw.println(" mWakefulness=" + wakefulnessToString(mWakefulness));
|
||||
pw.println(" mInteractive=" + mInteractive);
|
||||
pw.println(" mIsPowered=" + mIsPowered);
|
||||
pw.println(" mPlugType=" + mPlugType);
|
||||
pw.println(" mBatteryLevel=" + mBatteryLevel);
|
||||
@@ -2099,8 +2071,8 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
pw.println(" mProximityPositive=" + mProximityPositive);
|
||||
pw.println(" mBootCompleted=" + mBootCompleted);
|
||||
pw.println(" mSystemReady=" + mSystemReady);
|
||||
pw.println(" mAutoSuspendModeEnabled=" + mAutoSuspendModeEnabled);
|
||||
pw.println(" mInteactiveModeEnabled=" + mInteractiveModeEnabled);
|
||||
pw.println(" mHalAutoSuspendModeEnabled=" + mHalAutoSuspendModeEnabled);
|
||||
pw.println(" mHalInteractiveModeEnabled=" + mHalInteractiveModeEnabled);
|
||||
pw.println(" mWakeLockSummary=0x" + Integer.toHexString(mWakeLockSummary));
|
||||
pw.println(" mUserActivitySummary=0x" + Integer.toHexString(mUserActivitySummary));
|
||||
pw.println(" mRequestWaitForNegativeProximity=" + mRequestWaitForNegativeProximity);
|
||||
@@ -2108,10 +2080,6 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
pw.println(" mSandmanSummoned=" + mSandmanSummoned);
|
||||
pw.println(" mLastWakeTime=" + TimeUtils.formatUptime(mLastWakeTime));
|
||||
pw.println(" mLastSleepTime=" + TimeUtils.formatUptime(mLastSleepTime));
|
||||
pw.println(" mSendWakeUpFinishedNotificationWhenReady="
|
||||
+ mSendWakeUpFinishedNotificationWhenReady);
|
||||
pw.println(" mSendGoToSleepFinishedNotificationWhenReady="
|
||||
+ mSendGoToSleepFinishedNotificationWhenReady);
|
||||
pw.println(" mLastUserActivityTime=" + TimeUtils.formatUptime(mLastUserActivityTime));
|
||||
pw.println(" mLastUserActivityTimeNoChangeLights="
|
||||
+ TimeUtils.formatUptime(mLastUserActivityTimeNoChangeLights));
|
||||
@@ -2121,10 +2089,10 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
|
||||
pw.println();
|
||||
pw.println("Settings and Configuration:");
|
||||
pw.println(" mDecoupleAutoSuspendModeFromDisplayConfig="
|
||||
+ mDecoupleAutoSuspendModeFromDisplayConfig);
|
||||
pw.println(" mDecoupleInteractiveModeFromDisplayConfig="
|
||||
+ mDecoupleInteractiveModeFromDisplayConfig);
|
||||
pw.println(" mDecoupleHalAutoSuspendModeFromDisplayConfig="
|
||||
+ mDecoupleHalAutoSuspendModeFromDisplayConfig);
|
||||
pw.println(" mDecoupleHalInteractiveModeFromDisplayConfig="
|
||||
+ mDecoupleHalInteractiveModeFromDisplayConfig);
|
||||
pw.println(" mWakeUpWhenPluggedOrUnpluggedConfig="
|
||||
+ mWakeUpWhenPluggedOrUnpluggedConfig);
|
||||
pw.println(" mSuspendWhenScreenOffDueToProximityConfig="
|
||||
@@ -2725,10 +2693,10 @@ public final class PowerManagerService extends com.android.server.SystemService
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public boolean isScreenOn() {
|
||||
public boolean isInteractive() {
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return isScreenOnInternal();
|
||||
return isInteractiveInternal();
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
|
||||
@@ -355,17 +355,16 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
||||
/* Provides an opportunity for the window manager policy to intercept early key
|
||||
* processing as soon as the key has been read from the device. */
|
||||
@Override
|
||||
public int interceptKeyBeforeQueueing(
|
||||
KeyEvent event, int policyFlags, boolean isScreenOn) {
|
||||
return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags, isScreenOn);
|
||||
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
|
||||
return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags);
|
||||
}
|
||||
|
||||
/* Provides an opportunity for the window manager policy to intercept early
|
||||
* motion event processing when the screen is off since these events are normally
|
||||
* dropped. */
|
||||
@Override
|
||||
public int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags) {
|
||||
return mService.mPolicy.interceptMotionBeforeQueueingWhenScreenOff(whenNanos, policyFlags);
|
||||
public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) {
|
||||
return mService.mPolicy.interceptWakeMotionBeforeQueueing(whenNanos, policyFlags);
|
||||
}
|
||||
|
||||
/* Provides an opportunity for the window manager policy to process a key before
|
||||
|
||||
@@ -71,7 +71,7 @@ static struct {
|
||||
jmethodID notifyANR;
|
||||
jmethodID filterInputEvent;
|
||||
jmethodID interceptKeyBeforeQueueing;
|
||||
jmethodID interceptMotionBeforeQueueingWhenScreenOff;
|
||||
jmethodID interceptWakeMotionBeforeQueueing;
|
||||
jmethodID interceptKeyBeforeDispatching;
|
||||
jmethodID dispatchUnhandledKey;
|
||||
jmethodID checkInjectEventsPermission;
|
||||
@@ -189,6 +189,7 @@ public:
|
||||
void setSystemUiVisibility(int32_t visibility);
|
||||
void setPointerSpeed(int32_t speed);
|
||||
void setShowTouches(bool enabled);
|
||||
void setInteractive(bool interactive);
|
||||
void reloadCalibration();
|
||||
|
||||
/* --- InputReaderPolicyInterface implementation --- */
|
||||
@@ -214,7 +215,6 @@ public:
|
||||
virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle);
|
||||
virtual bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags);
|
||||
virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig);
|
||||
virtual bool isKeyRepeatEnabled();
|
||||
virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags);
|
||||
virtual void interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags);
|
||||
virtual nsecs_t interceptKeyBeforeDispatching(
|
||||
@@ -262,14 +262,12 @@ private:
|
||||
wp<PointerController> pointerController;
|
||||
} mLocked;
|
||||
|
||||
volatile bool mInteractive;
|
||||
|
||||
void updateInactivityTimeoutLocked(const sp<PointerController>& controller);
|
||||
void handleInterceptActions(jint wmActions, nsecs_t when, uint32_t& policyFlags);
|
||||
void ensureSpriteControllerLocked();
|
||||
|
||||
// Power manager interactions.
|
||||
bool isScreenOn();
|
||||
bool isScreenBright();
|
||||
|
||||
static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName);
|
||||
|
||||
static inline JNIEnv* jniEnv() {
|
||||
@@ -281,7 +279,7 @@ private:
|
||||
|
||||
NativeInputManager::NativeInputManager(jobject contextObj,
|
||||
jobject serviceObj, const sp<Looper>& looper) :
|
||||
mLooper(looper) {
|
||||
mLooper(looper), mInteractive(true) {
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
mContextObj = env->NewGlobalRef(contextObj);
|
||||
@@ -637,11 +635,6 @@ void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration
|
||||
}
|
||||
}
|
||||
|
||||
bool NativeInputManager::isKeyRepeatEnabled() {
|
||||
// Only enable automatic key repeating when the screen is on.
|
||||
return isScreenOn();
|
||||
}
|
||||
|
||||
void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowHandleObjArray) {
|
||||
Vector<sp<InputWindowHandle> > windowHandles;
|
||||
|
||||
@@ -753,19 +746,15 @@ void NativeInputManager::setShowTouches(bool enabled) {
|
||||
InputReaderConfiguration::CHANGE_SHOW_TOUCHES);
|
||||
}
|
||||
|
||||
void NativeInputManager::setInteractive(bool interactive) {
|
||||
mInteractive = interactive;
|
||||
}
|
||||
|
||||
void NativeInputManager::reloadCalibration() {
|
||||
mInputManager->getReader()->requestRefreshConfiguration(
|
||||
InputReaderConfiguration::TOUCH_AFFINE_TRANSFORMATION);
|
||||
}
|
||||
|
||||
bool NativeInputManager::isScreenOn() {
|
||||
return android_server_PowerManagerService_isScreenOn();
|
||||
}
|
||||
|
||||
bool NativeInputManager::isScreenBright() {
|
||||
return android_server_PowerManagerService_isScreenBright();
|
||||
}
|
||||
|
||||
TouchAffineTransformation NativeInputManager::getTouchAffineTransformation(
|
||||
JNIEnv *env, jfloatArray matrixArr) {
|
||||
ScopedFloatArrayRO matrix(env, matrixArr);
|
||||
@@ -841,18 +830,18 @@ void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent,
|
||||
// - Ignore untrusted events and pass them along.
|
||||
// - Ask the window manager what to do with normal events and trusted injected events.
|
||||
// - For normal events wake and brighten the screen if currently off or dim.
|
||||
if (mInteractive) {
|
||||
policyFlags |= POLICY_FLAG_INTERACTIVE;
|
||||
}
|
||||
if ((policyFlags & POLICY_FLAG_TRUSTED)) {
|
||||
nsecs_t when = keyEvent->getEventTime();
|
||||
bool isScreenOn = this->isScreenOn();
|
||||
bool isScreenBright = this->isScreenBright();
|
||||
|
||||
JNIEnv* env = jniEnv();
|
||||
jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
|
||||
jint wmActions;
|
||||
if (keyEventObj) {
|
||||
wmActions = env->CallIntMethod(mServiceObj,
|
||||
gServiceClassInfo.interceptKeyBeforeQueueing,
|
||||
keyEventObj, policyFlags, isScreenOn);
|
||||
keyEventObj, policyFlags);
|
||||
if (checkAndClearExceptionFromCallback(env, "interceptKeyBeforeQueueing")) {
|
||||
wmActions = 0;
|
||||
}
|
||||
@@ -863,16 +852,6 @@ void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent,
|
||||
wmActions = 0;
|
||||
}
|
||||
|
||||
if (!(policyFlags & POLICY_FLAG_INJECTED)) {
|
||||
if (!isScreenOn) {
|
||||
policyFlags |= POLICY_FLAG_WOKE_HERE;
|
||||
}
|
||||
|
||||
if (!isScreenBright) {
|
||||
policyFlags |= POLICY_FLAG_BRIGHT_HERE;
|
||||
}
|
||||
}
|
||||
|
||||
handleInterceptActions(wmActions, when, /*byref*/ policyFlags);
|
||||
} else {
|
||||
policyFlags |= POLICY_FLAG_PASS_TO_USER;
|
||||
@@ -885,24 +864,22 @@ void NativeInputManager::interceptMotionBeforeQueueing(nsecs_t when, uint32_t& p
|
||||
// - No special filtering for injected events required at this time.
|
||||
// - Filter normal events based on screen state.
|
||||
// - For normal events brighten (but do not wake) the screen if currently dim.
|
||||
if (mInteractive) {
|
||||
policyFlags |= POLICY_FLAG_INTERACTIVE;
|
||||
}
|
||||
if ((policyFlags & POLICY_FLAG_TRUSTED) && !(policyFlags & POLICY_FLAG_INJECTED)) {
|
||||
if (isScreenOn()) {
|
||||
if (policyFlags & POLICY_FLAG_INTERACTIVE) {
|
||||
policyFlags |= POLICY_FLAG_PASS_TO_USER;
|
||||
|
||||
if (!isScreenBright()) {
|
||||
policyFlags |= POLICY_FLAG_BRIGHT_HERE;
|
||||
}
|
||||
} else {
|
||||
} else if (policyFlags & (POLICY_FLAG_WAKE | POLICY_FLAG_WAKE_DROPPED)) {
|
||||
JNIEnv* env = jniEnv();
|
||||
jint wmActions = env->CallIntMethod(mServiceObj,
|
||||
gServiceClassInfo.interceptMotionBeforeQueueingWhenScreenOff,
|
||||
gServiceClassInfo.interceptWakeMotionBeforeQueueing,
|
||||
when, policyFlags);
|
||||
if (checkAndClearExceptionFromCallback(env,
|
||||
"interceptMotionBeforeQueueingWhenScreenOff")) {
|
||||
"interceptWakeMotionBeforeQueueing")) {
|
||||
wmActions = 0;
|
||||
}
|
||||
|
||||
policyFlags |= POLICY_FLAG_WOKE_HERE | POLICY_FLAG_BRIGHT_HERE;
|
||||
handleInterceptActions(wmActions, when, /*byref*/ policyFlags);
|
||||
}
|
||||
} else {
|
||||
@@ -1285,6 +1262,13 @@ static void nativeSetShowTouches(JNIEnv* env,
|
||||
im->setShowTouches(enabled);
|
||||
}
|
||||
|
||||
static void nativeSetInteractive(JNIEnv* env,
|
||||
jclass clazz, jlong ptr, jboolean interactive) {
|
||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
||||
|
||||
im->setInteractive(interactive);
|
||||
}
|
||||
|
||||
static void nativeReloadCalibration(JNIEnv* env, jclass clazz, jlong ptr) {
|
||||
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
|
||||
im->reloadCalibration();
|
||||
@@ -1395,6 +1379,8 @@ static JNINativeMethod gInputManagerMethods[] = {
|
||||
(void*) nativeSetPointerSpeed },
|
||||
{ "nativeSetShowTouches", "(JZ)V",
|
||||
(void*) nativeSetShowTouches },
|
||||
{ "nativeSetInteractive", "(JZ)V",
|
||||
(void*) nativeSetInteractive },
|
||||
{ "nativeReloadCalibration", "(J)V",
|
||||
(void*) nativeReloadCalibration },
|
||||
{ "nativeVibrate", "(JI[JII)V",
|
||||
@@ -1453,11 +1439,10 @@ int register_android_server_InputManager(JNIEnv* env) {
|
||||
"filterInputEvent", "(Landroid/view/InputEvent;I)Z");
|
||||
|
||||
GET_METHOD_ID(gServiceClassInfo.interceptKeyBeforeQueueing, clazz,
|
||||
"interceptKeyBeforeQueueing", "(Landroid/view/KeyEvent;IZ)I");
|
||||
"interceptKeyBeforeQueueing", "(Landroid/view/KeyEvent;I)I");
|
||||
|
||||
GET_METHOD_ID(gServiceClassInfo.interceptMotionBeforeQueueingWhenScreenOff,
|
||||
clazz,
|
||||
"interceptMotionBeforeQueueingWhenScreenOff", "(JI)I");
|
||||
GET_METHOD_ID(gServiceClassInfo.interceptWakeMotionBeforeQueueing, clazz,
|
||||
"interceptWakeMotionBeforeQueueing", "(JI)I");
|
||||
|
||||
GET_METHOD_ID(gServiceClassInfo.interceptKeyBeforeDispatching, clazz,
|
||||
"interceptKeyBeforeDispatching",
|
||||
|
||||
@@ -42,8 +42,6 @@ namespace android {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static struct {
|
||||
jmethodID wakeUpFromNative;
|
||||
jmethodID goToSleepFromNative;
|
||||
jmethodID userActivityFromNative;
|
||||
} gPowerManagerServiceClassInfo;
|
||||
|
||||
@@ -52,10 +50,6 @@ static struct {
|
||||
static jobject gPowerManagerServiceObj;
|
||||
static struct power_module* gPowerModule;
|
||||
|
||||
static Mutex gPowerManagerLock;
|
||||
static bool gScreenOn;
|
||||
static bool gScreenBright;
|
||||
|
||||
static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1];
|
||||
|
||||
// Throttling interval for user activity calls.
|
||||
@@ -73,16 +67,6 @@ static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodNa
|
||||
return false;
|
||||
}
|
||||
|
||||
bool android_server_PowerManagerService_isScreenOn() {
|
||||
AutoMutex _l(gPowerManagerLock);
|
||||
return gScreenOn;
|
||||
}
|
||||
|
||||
bool android_server_PowerManagerService_isScreenBright() {
|
||||
AutoMutex _l(gPowerManagerLock);
|
||||
return gScreenBright;
|
||||
}
|
||||
|
||||
void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t eventType) {
|
||||
// Tell the power HAL when user activity occurs.
|
||||
if (gPowerModule && gPowerModule->powerHint) {
|
||||
@@ -114,28 +98,6 @@ void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t
|
||||
}
|
||||
}
|
||||
|
||||
void android_server_PowerManagerService_wakeUp(nsecs_t eventTime) {
|
||||
if (gPowerManagerServiceObj) {
|
||||
JNIEnv* env = AndroidRuntime::getJNIEnv();
|
||||
|
||||
env->CallVoidMethod(gPowerManagerServiceObj,
|
||||
gPowerManagerServiceClassInfo.wakeUpFromNative,
|
||||
nanoseconds_to_milliseconds(eventTime));
|
||||
checkAndClearExceptionFromCallback(env, "wakeUpFromNative");
|
||||
}
|
||||
}
|
||||
|
||||
void android_server_PowerManagerService_goToSleep(nsecs_t eventTime) {
|
||||
if (gPowerManagerServiceObj) {
|
||||
JNIEnv* env = AndroidRuntime::getJNIEnv();
|
||||
|
||||
env->CallVoidMethod(gPowerManagerServiceObj,
|
||||
gPowerManagerServiceClassInfo.goToSleepFromNative,
|
||||
nanoseconds_to_milliseconds(eventTime), 0);
|
||||
checkAndClearExceptionFromCallback(env, "goToSleepFromNative");
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static void nativeInit(JNIEnv* env, jobject obj) {
|
||||
@@ -150,13 +112,6 @@ static void nativeInit(JNIEnv* env, jobject obj) {
|
||||
}
|
||||
}
|
||||
|
||||
static void nativeSetPowerState(JNIEnv* env,
|
||||
jclass clazz, jboolean screenOn, jboolean screenBright) {
|
||||
AutoMutex _l(gPowerManagerLock);
|
||||
gScreenOn = screenOn;
|
||||
gScreenBright = screenBright;
|
||||
}
|
||||
|
||||
static void nativeAcquireSuspendBlocker(JNIEnv *env, jclass clazz, jstring nameStr) {
|
||||
ScopedUtfChars name(env, nameStr);
|
||||
acquire_wake_lock(PARTIAL_WAKE_LOCK, name.c_str());
|
||||
@@ -207,8 +162,6 @@ static JNINativeMethod gPowerManagerServiceMethods[] = {
|
||||
/* name, signature, funcPtr */
|
||||
{ "nativeInit", "()V",
|
||||
(void*) nativeInit },
|
||||
{ "nativeSetPowerState", "(ZZ)V",
|
||||
(void*) nativeSetPowerState },
|
||||
{ "nativeAcquireSuspendBlocker", "(Ljava/lang/String;)V",
|
||||
(void*) nativeAcquireSuspendBlocker },
|
||||
{ "nativeReleaseSuspendBlocker", "(Ljava/lang/String;)V",
|
||||
@@ -243,12 +196,6 @@ int register_android_server_PowerManagerService(JNIEnv* env) {
|
||||
jclass clazz;
|
||||
FIND_CLASS(clazz, "com/android/server/power/PowerManagerService");
|
||||
|
||||
GET_METHOD_ID(gPowerManagerServiceClassInfo.wakeUpFromNative, clazz,
|
||||
"wakeUpFromNative", "(J)V");
|
||||
|
||||
GET_METHOD_ID(gPowerManagerServiceClassInfo.goToSleepFromNative, clazz,
|
||||
"goToSleepFromNative", "(JI)V");
|
||||
|
||||
GET_METHOD_ID(gPowerManagerServiceClassInfo.userActivityFromNative, clazz,
|
||||
"userActivityFromNative", "(JII)V");
|
||||
|
||||
@@ -256,8 +203,6 @@ int register_android_server_PowerManagerService(JNIEnv* env) {
|
||||
for (int i = 0; i <= USER_ACTIVITY_EVENT_LAST; i++) {
|
||||
gLastEventTime[i] = LLONG_MIN;
|
||||
}
|
||||
gScreenOn = true;
|
||||
gScreenBright = true;
|
||||
gPowerManagerServiceObj = NULL;
|
||||
gPowerModule = NULL;
|
||||
return 0;
|
||||
|
||||
@@ -24,11 +24,7 @@
|
||||
|
||||
namespace android {
|
||||
|
||||
extern bool android_server_PowerManagerService_isScreenOn();
|
||||
extern bool android_server_PowerManagerService_isScreenBright();
|
||||
extern void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t eventType);
|
||||
extern void android_server_PowerManagerService_wakeUp(nsecs_t eventTime);
|
||||
extern void android_server_PowerManagerService_goToSleep(nsecs_t eventTime);
|
||||
|
||||
} // namespace android
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ public class DozeTestDream extends DreamService {
|
||||
setLowProfile(true);
|
||||
setFullscreen(true);
|
||||
setContentView(R.layout.dream);
|
||||
setScreenBright(false);
|
||||
|
||||
mAlarmClock = (TextView)findViewById(R.id.alarm_clock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user