diff options
author | Preeti Ahuja <preetia@codeaurora.org> | 2015-07-07 12:08:55 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:29:35 -0600 |
commit | 9f0f676fb5c5710fdac21e141f56e3bcc4a072ba (patch) | |
tree | 143cad3f76f49409043e4b49a22d6457be6f0861 | |
parent | b7a497d0cf60c997b7cf2a199a212a231b69bd91 (diff) | |
download | android_packages_apps_Stk-9f0f676fb5c5710fdac21e141f56e3bcc4a072ba.tar.gz android_packages_apps_Stk-9f0f676fb5c5710fdac21e141f56e3bcc4a072ba.tar.bz2 android_packages_apps_Stk-9f0f676fb5c5710fdac21e141f56e3bcc4a072ba.zip |
STK: Add support for idle screen(home screen)
Treat home screen(Launcher screen) as the idle screen
for the purpose of stk.
Change-Id: Ic4511b272e216d8e0e7ce99eb0db338d4a65cd60
-rw-r--r-- | AndroidManifest.xml | 1 | ||||
-rwxr-xr-x | src/com/android/stk/StkAppService.java | 18 | ||||
-rw-r--r-- | src/com/android/stk/StkCmdReceiver.java | 2 |
3 files changed, 18 insertions, 3 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1cac861..acd1e5c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -108,6 +108,7 @@ <action android:name= "android.intent.action.stk.icc_status_change" /> <action android:name= "android.intent.action.stk.alpha_notify" /> <action android:name= "android.intent.action.LOCALE_CHANGED" /> + <action android:name= "org.codeaurora.action.stk.idle_screen"/> </intent-filter> </receiver> diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java index 71c657f..5760599 100755 --- a/src/com/android/stk/StkAppService.java +++ b/src/com/android/stk/StkAppService.java @@ -247,6 +247,7 @@ public class StkAppService extends Service implements Runnable { static final int STATE_EXIST = 1; private static final String PACKAGE_NAME = "com.android.stk"; + private static final String PACKAGE_NAME_HOME_SCREEN="com.android.launcher"; private static final String STK_MENU_ACTIVITY_NAME = PACKAGE_NAME + ".StkMenuActivity"; private static final String STK_INPUT_ACTIVITY_NAME = PACKAGE_NAME + ".StkInputActivity"; private static final String STK_DIALOG_ACTIVITY_NAME = PACKAGE_NAME + ".StkDialogActivity"; @@ -254,6 +255,10 @@ public class StkAppService extends Service implements Runnable { private static final int STK_NOTIFICATION_ID = 333; private static final String LOG_TAG = new Object(){}.getClass().getEnclosingClass().getName(); + // Broadcast sent from Launcher when the screen switched to idle state(home screen). + public static final String CAT_IDLE_SCREEN_ACTION = + "org.codeaurora.action.stk.idle_screen"; + // Inner class used for queuing telephony messages (proactive commands, // session end) while the service is busy processing a previous message. private class DelayedCmd { @@ -681,11 +686,20 @@ public class StkAppService extends Service implements Runnable { } /* - * If the device is not in an interactive state, we can assume + * If the device is on home screen, we can assume * that the screen is idle. */ private boolean isScreenIdle() { - return (!mPowerManager.isInteractive()); + ActivityManager mAcivityManager = (ActivityManager) mContext + .getSystemService(ACTIVITY_SERVICE); + String currentPackageName = mAcivityManager.getRunningTasks(1).get(0).topActivity + .getPackageName(); + CatLog.d(this, "isScreenIdle, package name : " + currentPackageName); + if (null != currentPackageName) { + return currentPackageName.equals(PACKAGE_NAME_HOME_SCREEN); + } + + return false; } private void handleIdleScreen(int slotId) { diff --git a/src/com/android/stk/StkCmdReceiver.java b/src/com/android/stk/StkCmdReceiver.java index 508e7f8..217f7b7 100644 --- a/src/com/android/stk/StkCmdReceiver.java +++ b/src/com/android/stk/StkCmdReceiver.java @@ -46,7 +46,7 @@ public class StkCmdReceiver extends BroadcastReceiver { handleLocaleChange(context); } else if (action.equals(AppInterface.CAT_ALPHA_NOTIFY_ACTION)) { handleAction(context, intent, StkAppService.OP_ALPHA_NOTIFY); - } else if (action.equals(Intent.ACTION_SCREEN_OFF)) { + } else if (action.equals(StkAppService.CAT_IDLE_SCREEN_ACTION)) { handleIdleScreen(context); } } |