Merge "Support ENVELOPE (EVENT DOWNLOAD - User activity) command" into pi-dev

am: 805a5ecedb

Change-Id: I57f62adb94dce6ef72c389b7d1a8c590f671e923
This commit is contained in:
Jordan Liu
2018-03-08 20:15:13 +00:00
committed by android-build-merger
7 changed files with 56 additions and 0 deletions

View File

@@ -416,4 +416,10 @@ interface IWindowManager
* Returns true if window trace is enabled.
*/
boolean isWindowTraceEnabled();
/**
* Requests that the WindowManager sends WindowManagerPolicy#ACTION_USER_ACTIVITY_NOTIFICATION
* on the next user activity.
*/
void requestUserActivityNotification();
}

View File

@@ -50,6 +50,12 @@ public interface WindowManagerPolicyConstants {
int NAV_BAR_RIGHT = 1 << 1;
int NAV_BAR_BOTTOM = 1 << 2;
/**
* Broadcast sent when a user activity is detected.
*/
String ACTION_USER_ACTIVITY_NOTIFICATION =
"android.intent.action.USER_ACTIVITY_NOTIFICATION";
/**
* Sticky broadcast of the current HDMI plugged state.
*/

View File

@@ -87,6 +87,7 @@
<protected-broadcast android:name="android.intent.action.OVERLAY_CHANGED" />
<protected-broadcast android:name="android.intent.action.OVERLAY_REMOVED" />
<protected-broadcast android:name="android.intent.action.OVERLAY_PRIORITY_CHANGED" />
<protected-broadcast android:name="android.intent.action.USER_ACTIVITY_NOTIFICATION" />
<protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGED" />
<protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGING" />

View File

@@ -427,6 +427,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR);
}
private static final int USER_ACTIVITY_NOTIFICATION_DELAY = 200;
/** Amount of time (in milliseconds) to wait for windows drawn before powering on. */
static final int WAITING_FOR_DRAWN_TIMEOUT = 1000;
@@ -674,6 +676,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private boolean mPendingKeyguardOccluded;
private boolean mKeyguardOccludedChanged;
private boolean mNotifyUserActivity;
boolean mShowingDream;
private boolean mLastShowingDream;
@@ -828,6 +831,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private static final int MSG_LAUNCH_ASSIST = 26;
private static final int MSG_LAUNCH_ASSIST_LONG_PRESS = 27;
private static final int MSG_POWER_VERY_LONG_PRESS = 28;
private static final int MSG_NOTIFY_USER_ACTIVITY = 29;
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0;
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1;
@@ -929,6 +933,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
case MSG_HANDLE_ALL_APPS:
launchAllAppsAction();
break;
case MSG_NOTIFY_USER_ACTIVITY:
removeMessages(MSG_NOTIFY_USER_ACTIVITY);
Intent intent = new Intent(ACTION_USER_ACTIVITY_NOTIFICATION);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
android.Manifest.permission.USER_ACTIVITY);
break;
}
}
}
@@ -7486,6 +7497,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHandler.sendEmptyMessage(MSG_HIDE_BOOT_MESSAGE);
}
@Override
public void requestUserActivityNotification() {
if (!mNotifyUserActivity && !mHandler.hasMessages(MSG_NOTIFY_USER_ACTIVITY)) {
mNotifyUserActivity = true;
}
}
/** {@inheritDoc} */
@Override
public void userActivity() {
@@ -7507,6 +7525,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout);
}
}
if (mAwake && mNotifyUserActivity) {
mHandler.sendEmptyMessageDelayed(MSG_NOTIFY_USER_ACTIVITY,
USER_ACTIVITY_NOTIFICATION_DELAY);
mNotifyUserActivity = false;
}
}
class ScreenLockTimeout implements Runnable {

View File

@@ -1718,4 +1718,10 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
return Integer.toString(mode);
}
}
/**
* Requests that the WindowManager sends WindowManagerPolicy#ACTION_USER_ACTIVITY_NOTIFICATION
* on the next user activity.
*/
public void requestUserActivityNotification();
}

View File

@@ -6989,6 +6989,15 @@ public class WindowManagerService extends IWindowManager.Stub
mPolicy.registerShortcutKey(shortcutCode, shortcutKeyReceiver);
}
@Override
public void requestUserActivityNotification() {
if (!checkCallingPermission(android.Manifest.permission.USER_ACTIVITY,
"requestUserActivityNotification()")) {
throw new SecurityException("Requires USER_ACTIVITY permission");
}
mPolicy.requestUserActivityNotification();
}
void markForSeamlessRotation(WindowState w, boolean seamlesslyRotated) {
if (seamlesslyRotated == w.mSeamlesslyRotated) {
return;

View File

@@ -652,4 +652,8 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
@Override
public void onScreenMagnificationStateChanged(boolean active) {
}
@Override
public void requestUserActivityNotification() {
}
}