Bug 1082201 - Turn off lock screen widget. r=mfinkle, a=backout,mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Mon, 13 Oct 2014 15:43:00 -0700
changeset 233398 a5e4cb81549489ed8c8566f66bbb57a4342081f1
parent 233397 15e99df2660c321f3ed556d554394dbf776b8ca0
child 233399 7e151ae385b91270c950e753e887e2a558e7e787
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, backout, mfinkle
bugs1082201
milestone35.0a2
Bug 1082201 - Turn off lock screen widget. r=mfinkle, a=backout,mfinkle
mobile/android/base/BrowserApp.java
mobile/android/base/GeckoProfile.java
mobile/android/base/GuestSession.java
mobile/android/base/preferences/GeckoPreferences.java
mobile/android/base/resources/xml/search_widget_info.xml
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -74,17 +74,16 @@ import org.mozilla.gecko.util.StringUtil
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.util.UIAsyncTask;
 import org.mozilla.gecko.widget.ButtonToast;
 import org.mozilla.gecko.widget.ButtonToast.ToastListener;
 import org.mozilla.gecko.widget.GeckoActionProvider;
 
 import android.app.Activity;
 import android.app.AlertDialog;
-import android.app.KeyguardManager;
 import android.content.BroadcastReceiver;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
@@ -777,29 +776,16 @@ public class BrowserApp extends GeckoApp
         final boolean enableGuestSession = GuestSession.shouldUse(this, args);
         final boolean inGuestSession = GeckoProfile.get(this).inGuestMode();
         if (enableGuestSession != inGuestSession) {
             doRestart(getIntent());
             GeckoAppShell.systemExit();
             return;
         }
 
-        final KeyguardManager manager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
-        // The test machines return null for the KeyguardService, despite running Android 4.2.
-        if (Versions.feature11Plus && manager != null) {
-            // If the keyguard is showing AND we're either in guest mode or the keyguard is insecure,
-            // allow showing this window. We do this in onResume so that we can avoid setting these flags if the keyguard
-            // is not showing since it affects Android's layout of the window.
-            if (manager.isKeyguardLocked() && (GeckoProfile.get(this).inGuestMode() || !manager.isKeyguardSecure())) {
-                GuestSession.configureWindow(getWindow());
-            } else {
-                GuestSession.unconfigureWindow(getWindow());
-            }
-        }
-
         EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener)this,
             "Prompt:ShowTop");
     }
 
     @Override
     public void onPause() {
         super.onPause();
         // Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
@@ -2998,23 +2984,17 @@ public class BrowserApp extends GeckoApp
                             args = GUEST_BROWSING_ARG;
                         } else {
                             GeckoProfile.leaveGuestSession(BrowserApp.this);
 
                             // Now's a good time to make sure we're not displaying the Guest Browsing notification.
                             GuestSession.hideNotification(BrowserApp.this);
                         }
 
-                        if (!GuestSession.isSecureKeyguardLocked(BrowserApp.this)) {
-                            doRestart(args);
-                        } else {
-                            // If the secure keyguard is up, we don't want to restart.
-                            // Just clear the guest profile data.
-                            GeckoProfile.maybeCleanupGuestProfile(BrowserApp.this);
-                        }
+                        doRestart(args);
                         GeckoAppShell.systemExit();
                     }
                 } catch(JSONException ex) {
                     Log.e(LOGTAG, "Exception reading guest mode prompt result", ex);
                 }
             }
         });
 
--- a/mobile/android/base/GeckoProfile.java
+++ b/mobile/android/base/GeckoProfile.java
@@ -210,19 +210,17 @@ public final class GeckoProfile {
             // We need to force the creation of a new guest profile if we want it outside of the normal profile path,
             // otherwise GeckoProfile.getDir will try to be smart and build it for us in the normal profiles dir.
             getGuestDir(context).mkdir();
             GeckoProfile profile = getGuestProfile(context);
 
             // If we're creating this guest session over the keyguard, don't lock it.
             // This will force the guest session to exit if the user unlocks their phone
             // and starts Fennec.
-            if (!GuestSession.isSecureKeyguardLocked(context)) {
-                profile.lock();
-            }
+            profile.lock();
 
             /*
              * Now do the things that createProfileDirectory normally does --
              * right now that's kicking off DB init.
              */
             profile.enqueueInitialization(profile.getDir());
 
             return profile;
--- a/mobile/android/base/GuestSession.java
+++ b/mobile/android/base/GuestSession.java
@@ -14,64 +14,36 @@ import android.support.v4.app.Notificati
 import android.view.Window;
 import android.view.WindowManager;
 
 // Utility methods for entering/exiting guest mode.
 public class GuestSession {
     public static final String NOTIFICATION_INTENT = "org.mozilla.gecko.GUEST_SESSION_INPROGRESS";
     private static final String LOGTAG = "GeckoGuestSession";
 
-    // Returns true if the user is using a secure keyguard, and its currently locked.
-    static boolean isSecureKeyguardLocked(Context context) {
-        final KeyguardManager manager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
-
-        // The test machines return null for the KeyguardService, despite running Android 4.2.
-        if (AppConstants.Versions.preJB || manager == null) {
-            return false;
-        }
-
-        return manager.isKeyguardLocked() && manager.isKeyguardSecure();
-    }
-
     /* Returns true if you should be in guest mode. This can be because a secure keyguard
      * is locked, or because the user has explicitly started guest mode via a dialog. If the
      * user has explicitly started Fennec in guest mode, this will return true until they
      * explicitly exit it.
      */
     public static boolean shouldUse(final Context context, final String args) {
         // Did the command line args request guest mode?
         if (args != null && args.contains(BrowserApp.GUEST_BROWSING_ARG)) {
             return true;
         }
 
-        // Otherwise, is the device locked?
-        final boolean keyguard = isSecureKeyguardLocked(context);
-        if (keyguard) {
-            return true;
-        }
-
         // Otherwise, is there a locked guest mode profile?
         final GeckoProfile profile = GeckoProfile.getGuestProfile(context);
         if (profile == null) {
             return false;
         }
 
         return profile.locked();
     }
 
-    public static void configureWindow(Window window) {
-        // In guest sessions we allow showing over the keyguard.
-        window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
-    }
-
-    public static void unconfigureWindow(Window window) {
-        // In guest sessions we allow showing over the keyguard.
-        window.clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
-    }
-
     private static PendingIntent getNotificationIntent(Context context) {
         Intent intent = new Intent(NOTIFICATION_INTENT);
         intent.setClass(context, BrowserApp.class);
         return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
     }
 
     public static void showNotification(Context context) {
         final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
--- a/mobile/android/base/preferences/GeckoPreferences.java
+++ b/mobile/android/base/preferences/GeckoPreferences.java
@@ -291,20 +291,16 @@ OnSharedPreferenceChangeListener
             return;
         }
 
         onLocaleChanged(currentLocale);
     }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        if (GeckoProfile.get(this).inGuestMode()) {
-            GuestSession.configureWindow(getWindow());
-        }
-
         // Apply the current user-selected locale, if necessary.
         checkLocale();
 
         // Track this so we can decide whether to show locale options.
         // See also the workaround below for Bug 1015209.
         localeSwitchingIsEnabled = BrowserLocaleManager.getInstance().isEnabled();
 
         // For Android v11+ where we use Fragments (v11+ only due to bug 866352),
--- a/mobile/android/base/resources/xml/search_widget_info.xml
+++ b/mobile/android/base/resources/xml/search_widget_info.xml
@@ -2,12 +2,11 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
     android:minWidth="300dp"
     android:minHeight="40dp"
     android:label="@string/search_widget_name"
-    android:widgetCategory="home_screen|keyguard"
+    android:widgetCategory="home_screen"
     android:previewImage="@drawable/launcher_widget"
-    android:initialLayout="@layout/search_widget"
-    android:initialKeyguardLayout="@layout/keyguard_widget"/>
+    android:initialLayout="@layout/search_widget"/>