summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/BrowserActivity.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-04-18 16:23:14 -0700
committerJohn Reck <jreck@google.com>2012-04-18 16:27:52 -0700
commit7878f22795aae08f49c489156846ef748b064e79 (patch)
treec493d90d41a050e356339b04fc17e10107d265c9 /src/com/android/browser/BrowserActivity.java
parentf1286a455eeacd02dfcca1335e6a7a9f87433c1b (diff)
downloadpackages_apps_browser-7878f22795aae08f49c489156846ef748b064e79.zip
packages_apps_browser-7878f22795aae08f49c489156846ef748b064e79.tar.gz
packages_apps_browser-7878f22795aae08f49c489156846ef748b064e79.tar.bz2
Only process intents if user-visible
Bug: 1873726 Change-Id: I2f5fe29bdf00e5ad441e8f50c89be64b93f7842a
Diffstat (limited to 'src/com/android/browser/BrowserActivity.java')
-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();