summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-04-18 16:29:46 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-18 16:29:46 -0700
commitb2ce8741bf389cca77aad12ff5971e51e6e6c3a5 (patch)
treec07bf544fa68c2306ff4a9e67e429b72cd2f726d /src/com/android/browser
parent0d8510ccabed0116b94e1aa7e4bf1c01d4cf7c74 (diff)
parent7878f22795aae08f49c489156846ef748b064e79 (diff)
downloadpackages_apps_Browser-b2ce8741bf389cca77aad12ff5971e51e6e6c3a5.zip
packages_apps_Browser-b2ce8741bf389cca77aad12ff5971e51e6e6c3a5.tar.gz
packages_apps_Browser-b2ce8741bf389cca77aad12ff5971e51e6e6c3a5.tar.bz2
Merge "Only process intents if user-visible"
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/BrowserActivity.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 77fac4f..1d53626 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -17,10 +17,12 @@
package com.android.browser;
import android.app.Activity;
+import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
+import android.os.PowerManager;
import android.util.Log;
import android.view.ActionMode;
import android.view.ContextMenu;
@@ -56,6 +58,11 @@ public class BrowserActivity extends Activity {
}
super.onCreate(icicle);
+ if (shouldIgnoreIntents()) {
+ finish();
+ return;
+ }
+
// If this was a web search request, pass it on to the default web
// search provider and finish this activity.
if (IntentHandler.handleWebSearchIntent(this, null, getIntent())) {
@@ -86,6 +93,7 @@ public class BrowserActivity extends Activity {
@Override
protected void onNewIntent(Intent intent) {
+ if (shouldIgnoreIntents()) return;
if (ACTION_RESTART.equals(intent.getAction())) {
Bundle outState = new Bundle();
mController.onSaveInstanceState(outState);
@@ -99,6 +107,25 @@ public class BrowserActivity extends Activity {
mController.handleNewIntent(intent);
}
+ private KeyguardManager mKeyguardManager;
+ private PowerManager mPowerManager;
+ private boolean shouldIgnoreIntents() {
+ // Only process intents if the screen is on and the device is unlocked
+ // aka, if we will be user-visible
+ if (mKeyguardManager == null) {
+ mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
+ }
+ if (mPowerManager == null) {
+ mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ }
+ boolean ignore = !mPowerManager.isScreenOn();
+ ignore |= mKeyguardManager.inKeyguardRestrictedInputMode();
+ if (LOGV_ENABLED) {
+ Log.v(LOGTAG, "ignore intents: " + ignore);
+ }
+ return ignore;
+ }
+
@Override
protected void onResume() {
super.onResume();