Skip to content

Commit b696de5

Browse files
author
Jeff Brown
committed
Move and rename user activity event type constants.
Change-Id: Ie565808796773b6896e71ddfac6aaaf8031de846
1 parent 155fc70 commit b696de5

File tree

9 files changed

+44
-30
lines changed

9 files changed

+44
-30
lines changed

core/java/android/os/LocalPowerManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818

1919
/** @hide */
2020
public interface LocalPowerManager {
21-
// Note: be sure to update BatteryStats if adding or modifying event constants.
22-
23-
public static final int OTHER_EVENT = 0;
24-
public static final int BUTTON_EVENT = 1;
25-
public static final int TOUCH_EVENT = 2;
26-
2721
public static final int POKE_LOCK_IGNORE_TOUCH_EVENTS = 0x1;
2822

2923
public static final int POKE_LOCK_SHORT_TIMEOUT = 0x2;

core/java/android/os/PowerManager.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,27 @@ public final class PowerManager {
250250
*/
251251
public static final int BRIGHTNESS_OFF = 0;
252252

253+
// Note: Be sure to update android.os.BatteryStats and PowerManager.h
254+
// if adding or modifying user activity event constants.
255+
256+
/**
257+
* User activity event type: Unspecified event type.
258+
* @hide
259+
*/
260+
public static final int USER_ACTIVITY_EVENT_OTHER = 0;
261+
262+
/**
263+
* User activity event type: Button or key pressed or released.
264+
* @hide
265+
*/
266+
public static final int USER_ACTIVITY_EVENT_BUTTON = 1;
267+
268+
/**
269+
* User activity event type: Touch down, move or up.
270+
* @hide
271+
*/
272+
public static final int USER_ACTIVITY_EVENT_TOUCH = 2;
273+
253274
final IPowerManager mService;
254275
final Handler mHandler;
255276

include/androidfw/PowerManager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
namespace android {
2222

2323
enum {
24-
POWER_MANAGER_OTHER_EVENT = 0,
25-
POWER_MANAGER_BUTTON_EVENT = 1,
26-
POWER_MANAGER_TOUCH_EVENT = 2,
24+
USER_ACTIVITY_EVENT_OTHER = 0,
25+
USER_ACTIVITY_EVENT_BUTTON = 1,
26+
USER_ACTIVITY_EVENT_TOUCH = 2,
2727

28-
POWER_MANAGER_LAST_EVENT = POWER_MANAGER_TOUCH_EVENT, // Last valid event code.
28+
USER_ACTIVITY_EVENT_LAST = USER_ACTIVITY_EVENT_TOUCH, // Last valid event code.
2929
};
3030

3131
} // namespace android

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,11 +3021,11 @@ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
30213021
KeyEvent.KEYCODE_POWER, mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED);
30223022
} else {
30233023
mPowerManager.userActivity(SystemClock.uptimeMillis(), false,
3024-
LocalPowerManager.BUTTON_EVENT);
3024+
PowerManager.USER_ACTIVITY_EVENT_BUTTON);
30253025
}
30263026
} else if (!mLidControlsSleep) {
30273027
mPowerManager.userActivity(SystemClock.uptimeMillis(), false,
3028-
LocalPowerManager.OTHER_EVENT);
3028+
PowerManager.USER_ACTIVITY_EVENT_OTHER);
30293029
}
30303030
}
30313031

@@ -4319,7 +4319,7 @@ public void screenOnStoppedLw() {
43194319
if (mPowerManager.isScreenOn()) {
43204320
if (mKeyguardMediator != null && !mKeyguardMediator.isShowingAndNotHidden()) {
43214321
long curTime = SystemClock.uptimeMillis();
4322-
mPowerManager.userActivity(curTime, false, LocalPowerManager.OTHER_EVENT);
4322+
mPowerManager.userActivity(curTime, false, PowerManager.USER_ACTIVITY_EVENT_OTHER);
43234323
}
43244324

43254325
synchronized (mLock) {

services/input/InputDispatcher.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ String8 InputDispatcher::getApplicationWindowLabelLocked(
16931693
}
16941694

16951695
void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
1696-
int32_t eventType = POWER_MANAGER_OTHER_EVENT;
1696+
int32_t eventType = USER_ACTIVITY_EVENT_OTHER;
16971697
switch (eventEntry->type) {
16981698
case EventEntry::TYPE_MOTION: {
16991699
const MotionEntry* motionEntry = static_cast<const MotionEntry*>(eventEntry);
@@ -1702,7 +1702,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
17021702
}
17031703

17041704
if (MotionEvent::isTouchEvent(motionEntry->source, motionEntry->action)) {
1705-
eventType = POWER_MANAGER_TOUCH_EVENT;
1705+
eventType = USER_ACTIVITY_EVENT_TOUCH;
17061706
}
17071707
break;
17081708
}
@@ -1711,7 +1711,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
17111711
if (keyEntry->flags & AKEY_EVENT_FLAG_CANCELED) {
17121712
return;
17131713
}
1714-
eventType = POWER_MANAGER_BUTTON_EVENT;
1714+
eventType = USER_ACTIVITY_EVENT_BUTTON;
17151715
break;
17161716
}
17171717
}

services/java/com/android/server/power/PowerManagerService.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ private void releaseWakeLockLocked(IBinder lock, int flags, boolean death) {
10371037
mWakeLockState = mLocks.gatherState();
10381038
// goes in the middle to reduce flicker
10391039
if ((wl.flags & PowerManager.ON_AFTER_RELEASE) != 0) {
1040-
userActivity(SystemClock.uptimeMillis(), -1, false, OTHER_EVENT, false, true);
1040+
userActivity(SystemClock.uptimeMillis(), -1, false, PowerManager.USER_ACTIVITY_EVENT_OTHER, false, true);
10411041
}
10421042
setPowerState(mWakeLockState | mUserState);
10431043
}
@@ -2467,7 +2467,7 @@ private void forceUserActivityLocked() {
24672467

24682468
public void userActivityWithForce(long time, boolean noChangeLights, boolean force) {
24692469
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
2470-
userActivity(time, -1, noChangeLights, OTHER_EVENT, force, false);
2470+
userActivity(time, -1, noChangeLights, PowerManager.USER_ACTIVITY_EVENT_OTHER, force, false);
24712471
}
24722472

24732473
public void userActivity(long time, boolean noChangeLights) {
@@ -2480,7 +2480,7 @@ public void userActivity(long time, boolean noChangeLights) {
24802480
return;
24812481
}
24822482

2483-
userActivity(time, -1, noChangeLights, OTHER_EVENT, false, false);
2483+
userActivity(time, -1, noChangeLights, PowerManager.USER_ACTIVITY_EVENT_OTHER, false, false);
24842484
}
24852485

24862486
public void userActivity(long time, boolean noChangeLights, int eventType) {
@@ -2498,13 +2498,13 @@ public void userActivity(long time, boolean noChangeLights, int eventType, boole
24982498
public void clearUserActivityTimeout(long now, long timeout) {
24992499
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
25002500
Slog.i(TAG, "clearUserActivity for " + timeout + "ms from now");
2501-
userActivity(now, timeout, false, OTHER_EVENT, false, false);
2501+
userActivity(now, timeout, false, PowerManager.USER_ACTIVITY_EVENT_OTHER, false, false);
25022502
}
25032503

25042504
private void userActivity(long time, long timeoutOverride, boolean noChangeLights,
25052505
int eventType, boolean force, boolean ignoreIfScreenOff) {
25062506

2507-
if (((mPokey & POKE_LOCK_IGNORE_TOUCH_EVENTS) != 0) && (eventType == TOUCH_EVENT)) {
2507+
if (((mPokey & POKE_LOCK_IGNORE_TOUCH_EVENTS) != 0) && (eventType == PowerManager.USER_ACTIVITY_EVENT_TOUCH)) {
25082508
if (false) {
25092509
Slog.d(TAG, "dropping touch mPokey=0x" + Integer.toHexString(mPokey));
25102510
}
@@ -2541,7 +2541,7 @@ private void userActivity(long time, long timeoutOverride, boolean noChangeLight
25412541
if ((mUserActivityAllowed && !mProximitySensorActive) || force) {
25422542
// Only turn on button backlights if a button was pressed
25432543
// and auto brightness is disabled
2544-
if (eventType == BUTTON_EVENT && !mUseSoftwareAutoBrightness) {
2544+
if (eventType == PowerManager.USER_ACTIVITY_EVENT_BUTTON && !mUseSoftwareAutoBrightness) {
25452545
mUserState = (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT);
25462546
} else {
25472547
// don't clear button/keyboard backlights when the screen is touched.
@@ -2869,7 +2869,7 @@ public void setKeyboardVisibility(boolean visible) {
28692869
lightSensorChangedLocked(value, false);
28702870
}
28712871
}
2872-
userActivity(SystemClock.uptimeMillis(), false, BUTTON_EVENT, true);
2872+
userActivity(SystemClock.uptimeMillis(), false, PowerManager.USER_ACTIVITY_EVENT_BUTTON, true);
28732873
}
28742874
}
28752875
}
@@ -3086,7 +3086,7 @@ void bootCompleted() {
30863086
Slog.d(TAG, "bootCompleted");
30873087
synchronized (mLocks) {
30883088
mBootCompleted = true;
3089-
userActivity(SystemClock.uptimeMillis(), false, BUTTON_EVENT, true);
3089+
userActivity(SystemClock.uptimeMillis(), false, PowerManager.USER_ACTIVITY_EVENT_BUTTON, true);
30903090
updateWakeLockLocked();
30913091
mLocks.notifyAll();
30923092
}

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
import android.os.Handler;
8181
import android.os.IBinder;
8282
import android.os.IRemoteCallback;
83-
import android.os.LocalPowerManager;
8483
import android.os.Looper;
8584
import android.os.Message;
8685
import android.os.Parcel;
@@ -8952,7 +8951,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
89528951
if (mTurnOnScreen) {
89538952
if (DEBUG_VISIBILITY) Slog.v(TAG, "Turning screen on after layout!");
89548953
mPowerManager.userActivity(SystemClock.uptimeMillis(), false,
8955-
LocalPowerManager.BUTTON_EVENT, true);
8954+
PowerManager.USER_ACTIVITY_EVENT_BUTTON, true);
89568955
mTurnOnScreen = false;
89578956
}
89588957

services/jni/com_android_server_input_InputManagerService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ void NativeInputManager::handleInterceptActions(jint wmActions, nsecs_t when,
903903
#if DEBUG_INPUT_DISPATCHER_POLICY
904904
ALOGD("handleInterceptActions: Poking user activity.");
905905
#endif
906-
android_server_PowerManagerService_userActivity(when, POWER_MANAGER_BUTTON_EVENT);
906+
android_server_PowerManagerService_userActivity(when, USER_ACTIVITY_EVENT_BUTTON);
907907
}
908908

909909
if (wmActions & WM_ACTION_PASS_TO_USER) {

services/jni/com_android_server_power_PowerManagerService.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static Mutex gPowerManagerLock;
5555
static bool gScreenOn;
5656
static bool gScreenBright;
5757

58-
static nsecs_t gLastEventTime[POWER_MANAGER_LAST_EVENT + 1];
58+
static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1];
5959

6060
// Throttling interval for user activity calls.
6161
static const nsecs_t MIN_TIME_BETWEEN_USERACTIVITIES = 500 * 1000000L; // 500ms
@@ -92,7 +92,7 @@ void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t
9292
// Throttle calls into user activity by event type.
9393
// We're a little conservative about argument checking here in case the caller
9494
// passes in bad data which could corrupt system state.
95-
if (eventType >= 0 && eventType <= POWER_MANAGER_LAST_EVENT) {
95+
if (eventType >= 0 && eventType <= USER_ACTIVITY_EVENT_LAST) {
9696
nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
9797
if (eventTime > now) {
9898
eventTime = now;
@@ -262,7 +262,7 @@ int register_android_server_PowerManagerService(JNIEnv* env) {
262262
"userActivity", "(JZIZ)V");
263263

264264
// Initialize
265-
for (int i = 0; i < POWER_MANAGER_LAST_EVENT; i++) {
265+
for (int i = 0; i <= USER_ACTIVITY_EVENT_LAST; i++) {
266266
gLastEventTime[i] = LLONG_MIN;
267267
}
268268
gScreenOn = true;

0 commit comments

Comments
 (0)