Backed out changeset 5b3bc1699878 (bug 1244722) backed out for bustage
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 22 Apr 2016 05:52:45 +0200
changeset 325984 3f2bc870093002ac69f0772dd0befbf3db7b9f3d
parent 325983 8e2c675bcdfa618c4c1329aca2bfb8c6f81ac102
child 325985 a704f4cf969cf5925e9cddae92a59ff502501f8f
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1244722
milestone47.0a2
backs out5b3bc1699878212f1012141a4ced08232e124044
Backed out changeset 5b3bc1699878 (bug 1244722) backed out for bustage
mobile/android/base/java/org/mozilla/gecko/tabqueue/TabQueueHelper.java
--- a/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabQueueHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabQueueHelper.java
@@ -2,39 +2,37 @@
  * 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/. */
 
 package org.mozilla.gecko.tabqueue;
 
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.GeckoAppShell;
+import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.GeckoSharedPrefs;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.preferences.GeckoPreferences;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.annotation.TargetApi;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.os.Build;
-import android.graphics.PixelFormat;
+import android.provider.Settings;
 import android.support.v4.app.NotificationCompat;
 import android.support.v4.content.ContextCompat;
 import android.text.TextUtils;
 import android.util.Log;
-import android.view.View;
-import android.view.WindowManager;
-
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.util.ArrayList;
 import java.util.List;
 
 public class TabQueueHelper {
@@ -65,39 +63,17 @@ public class TabQueueHelper {
      *
      * @return true if the specified context can draw on top of other apps, false otherwise.
      */
     public static boolean canDrawOverlays(Context context) {
         if (AppConstants.Versions.preM) {
             return true; // We got the permission at install time.
         }
 
-        // It would be nice to just use Settings.canDrawOverlays() - but this helper is buggy for
-        // apps using sharedUserId (See bug 1244722).
-        // Instead we'll add and remove an invisible view. If this is successful then we seem to
-        // have permission to draw overlays.
-
-        View view = new View(context);
-        view.setVisibility(View.INVISIBLE);
-
-        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
-                1, 1,
-                WindowManager.LayoutParams.TYPE_PHONE,
-                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
-                PixelFormat.TRANSLUCENT);
-
-        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
-
-        try {
-            windowManager.addView(view, layoutParams);
-            windowManager.removeView(view);
-            return true;
-        } catch (final SecurityException | WindowManager.BadTokenException e) {
-            return false;
-        }
+        return Settings.canDrawOverlays(context);
     }
 
     /**
      * Check if we should show the tab queue prompt
      *
      * @param context
      * @return true if we should display the prompt, false if not.
      */