From e1bdfc82867e1ddfa8ba23ac267e4426472d6a27 Mon Sep 17 00:00:00 2001 From: Yoshiaki Naka Date: Fri, 15 Sep 2017 15:24:34 +0900 Subject: [PATCH] Support ENVELOPE (EVENT DOWNLOAD - User activity) command The terminal shall send the ENVELOPE (EVENT DOWNLOAD - User activity) command to the UICC when some user activity like a key-press or touch is detected if the user activity event is a part of the current event list. This change allows the SIM Toolkit application to support that event. Please refer to the specification of SET UP EVENT LIST command described in ETSI TS 102.223. Bug: 65884891 Test: Confirmed the expected seq 1.1 of ETSI TS 102.384 TC 27.22.4.16 Change-Id: I7d3faa09cd4625db53bcfe21f90570389a4ea037 --- core/java/android/view/IWindowManager.aidl | 6 +++++ .../view/WindowManagerPolicyConstants.java | 6 +++++ core/res/AndroidManifest.xml | 1 + .../server/policy/PhoneWindowManager.java | 24 +++++++++++++++++++ .../server/policy/WindowManagerPolicy.java | 6 +++++ .../server/wm/WindowManagerService.java | 9 +++++++ .../server/wm/TestWindowManagerPolicy.java | 4 ++++ 7 files changed, 56 insertions(+) diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 75940e8b61298..77a74e260811e 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -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(); } diff --git a/core/java/android/view/WindowManagerPolicyConstants.java b/core/java/android/view/WindowManagerPolicyConstants.java index a6f36bbf4ef4c..23dc9da694a60 100644 --- a/core/java/android/view/WindowManagerPolicyConstants.java +++ b/core/java/android/view/WindowManagerPolicyConstants.java @@ -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. */ diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 3324fc3cdbfde..e5cbd9b3959df 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -87,6 +87,7 @@ + diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index ab0779b8fb331..8a5d2c2c97c72 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -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; } } } @@ -7476,6 +7487,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() { @@ -7497,6 +7515,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 { diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java index ab331a5263c8e..57a83c60c3c8a 100644 --- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java +++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java @@ -1716,4 +1716,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(); } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index bdd64d5046074..af667b65706e1 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -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; diff --git a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java index 34c5db3c220b1..6784e302a5c46 100644 --- a/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java +++ b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java @@ -652,4 +652,8 @@ class TestWindowManagerPolicy implements WindowManagerPolicy { @Override public void onScreenMagnificationStateChanged(boolean active) { } + + @Override + public void requestUserActivityNotification() { + } }