From c63bcc380cdadbc9eabb3dabba445c19c67be027 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Tue, 6 May 2014 14:32:54 -0700 Subject: [PATCH 01/11] Bug 1006805 - Simplify HardwareUtils. r=mfinkle --- mobile/android/base/util/HardwareUtils.java | 80 ++++++++++----------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/mobile/android/base/util/HardwareUtils.java b/mobile/android/base/util/HardwareUtils.java index 632e5c6dcd2..254d2a90cb3 100644 --- a/mobile/android/base/util/HardwareUtils.java +++ b/mobile/android/base/util/HardwareUtils.java @@ -5,6 +5,10 @@ package org.mozilla.gecko.util; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Configuration; @@ -12,12 +16,6 @@ import android.os.Build; import android.util.Log; import android.view.ViewConfiguration; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public final class HardwareUtils { private static final String LOGTAG = "GeckoHardwareUtils"; @@ -34,66 +32,66 @@ public final class HardwareUtils { private static volatile int sTotalRAM = -1; - private static Context sContext; + private static volatile boolean sInited; - private static Boolean sIsLargeTablet; - private static Boolean sIsSmallTablet; - private static Boolean sIsTelevision; - private static Boolean sHasMenuButton; + // These are all set once, during init. + private static volatile boolean sIsLargeTablet; + private static volatile boolean sIsSmallTablet; + private static volatile boolean sIsTelevision; + private static volatile boolean sHasMenuButton; private HardwareUtils() { } public static void init(Context context) { - if (sContext != null) { - Log.w(LOGTAG, "HardwareUtils.init called twice!"); + if (sInited) { + // This is unavoidable, given that HardwareUtils is called from background services. + Log.d(LOGTAG, "HardwareUtils already inited."); + return; } - sContext = context; + + // Pre-populate common flags from the context. + final int screenLayoutSize = context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; + if (Build.VERSION.SDK_INT >= 11) { + sHasMenuButton = false; + if (screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_XLARGE) { + sIsLargeTablet = true; + } else if (screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_LARGE) { + sIsSmallTablet = true; + } + if (Build.VERSION.SDK_INT >= 14) { + sHasMenuButton = ViewConfiguration.get(context).hasPermanentMenuKey(); + + if (Build.VERSION.SDK_INT >= 16) { + if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) { + sIsTelevision = true; + } + } + } + } else { + sHasMenuButton = true; + } + + sInited = true; } public static boolean isTablet() { - return isLargeTablet() || isSmallTablet(); + return sIsLargeTablet || sIsSmallTablet; } public static boolean isLargeTablet() { - if (sIsLargeTablet == null) { - int screenLayout = sContext.getResources().getConfiguration().screenLayout; - sIsLargeTablet = (Build.VERSION.SDK_INT >= 11 && - ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE)); - } return sIsLargeTablet; } public static boolean isSmallTablet() { - if (sIsSmallTablet == null) { - int screenLayout = sContext.getResources().getConfiguration().screenLayout; - sIsSmallTablet = (Build.VERSION.SDK_INT >= 11 && - ((screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)); - } return sIsSmallTablet; } public static boolean isTelevision() { - if (Build.VERSION.SDK_INT < 16) { - // System feature not supported before Jelly Bean. - return false; - } - if (sIsTelevision == null) { - sIsTelevision = sContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION); - } return sIsTelevision; } public static boolean hasMenuButton() { - if (sHasMenuButton == null) { - sHasMenuButton = Boolean.TRUE; - if (Build.VERSION.SDK_INT >= 11) { - sHasMenuButton = Boolean.FALSE; - } - if (Build.VERSION.SDK_INT >= 14) { - sHasMenuButton = ViewConfiguration.get(sContext).hasPermanentMenuKey(); - } - } return sHasMenuButton; } From fbc5973a424903ec067aaf756762c12ff2a7c7c2 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Fri, 18 Apr 2014 15:01:56 -0400 Subject: [PATCH 02/11] bug 995777 - browser.properties: rename getUserMedia.videoDevice.prompt to reflect new string r=mfinkle --- mobile/android/chrome/content/WebrtcUI.js | 4 ++-- .../android/locales/en-US/chrome/browser.properties | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mobile/android/chrome/content/WebrtcUI.js b/mobile/android/chrome/content/WebrtcUI.js index fd55ff569c1..81a65be8378 100644 --- a/mobile/android/chrome/content/WebrtcUI.js +++ b/mobile/android/chrome/content/WebrtcUI.js @@ -197,8 +197,8 @@ var WebrtcUI = { if (videoDevices.length > 1 || audioDevices.length > 0) { // Only show the No Video option if there are also Audio devices to choose from if (audioDevices.length > 0) - extraItems = [ Strings.browser.GetStringFromName("getUserMedia.videoDevice.none") ]; - this._addDevicesToOptions(videoDevices, "videoDevice", options, extraItems); + extraItems = [ Strings.browser.GetStringFromName("getUserMedia.videoSource.none") ]; + this._addDevicesToOptions(videoDevices, "videoSource", options, extraItems); } if (audioDevices.length > 1 || videoDevices.length > 0) { diff --git a/mobile/android/locales/en-US/chrome/browser.properties b/mobile/android/locales/en-US/chrome/browser.properties index f0598416fca..1ae3cb38ba2 100644 --- a/mobile/android/locales/en-US/chrome/browser.properties +++ b/mobile/android/locales/en-US/chrome/browser.properties @@ -299,12 +299,12 @@ getUserMedia.shareMicrophone.message = Would you like to share your microphone w getUserMedia.shareCameraAndMicrophone.message = Would you like to share your camera and microphone with %S? getUserMedia.denyRequest.label = Don't Share getUserMedia.shareRequest.label = Share -getUserMedia.videoDevice.default = Camera %S -getUserMedia.videoDevice.frontCamera = Front facing camera -getUserMedia.videoDevice.backCamera = Back facing camera -getUserMedia.videoDevice.none = No Video -getUserMedia.videoDevice.tabShare = Choose a tab to stream -getUserMedia.videoDevice.prompt = Video source +getUserMedia.videoSource.default = Camera %S +getUserMedia.videoSource.frontCamera = Front facing camera +getUserMedia.videoSource.backCamera = Back facing camera +getUserMedia.videoSource.none = No Video +getUserMedia.videoSource.tabShare = Choose a tab to stream +getUserMedia.videoSource.prompt = Video source getUserMedia.audioDevice.default = Microphone %S getUserMedia.audioDevice.none = No Audio getUserMedia.audioDevice.prompt = Microphone to use From 6a48bf3ea1e1d0885d4c7570b3a584576f11c256 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Tue, 6 May 2014 14:40:05 -0400 Subject: [PATCH 03/11] bug 1006494 - SimpleServiceDiscovery shouldn't add a trailing slash to services' location r=mfinkle --- mobile/android/modules/SimpleServiceDiscovery.jsm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mobile/android/modules/SimpleServiceDiscovery.jsm b/mobile/android/modules/SimpleServiceDiscovery.jsm index 0423f2967b8..4a53acd9abe 100644 --- a/mobile/android/modules/SimpleServiceDiscovery.jsm +++ b/mobile/android/modules/SimpleServiceDiscovery.jsm @@ -57,11 +57,10 @@ var SimpleServiceDiscovery = { _searchRepeat: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer), _forceTrailingSlash: function(aURL) { - // Some devices add the trailing '/' and some don't. Let's make sure - // it's there for consistency. - if (!aURL.endsWith("/")) { - aURL += "/"; - } + // Cleanup the URL to make it consistent across devices + try { + aURL = Services.io.newURI(aURL, null, null).spec; + } catch(e) {} return aURL; }, From 80da9e20fd5941f2fbd9e72debb4f4a648c66635 Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Wed, 7 May 2014 09:58:18 +1000 Subject: [PATCH 04/11] Bug 1002914 (part 1) - refactor the chat window so it can be used by loop and social. r=mixedpuppy --- browser/base/content/browser-sets.inc | 12 +- browser/base/content/browser-social.js | 35 +--- browser/base/content/socialchat.xml | 157 +++++++------- .../test/social/browser_social_chatwindow.js | 78 ++----- .../test/social/browser_social_errorPage.js | 31 +++ browser/base/content/test/social/head.js | 4 - browser/modules/Chat.jsm | 191 ++++++++++++++++++ browser/modules/moz.build | 1 + toolkit/components/social/MozSocialAPI.jsm | 101 ++------- 9 files changed, 354 insertions(+), 256 deletions(-) create mode 100644 browser/modules/Chat.jsm diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc index 89e6cb5b69d..9fa8c57df79 100644 --- a/browser/base/content/browser-sets.inc +++ b/browser/base/content/browser-sets.inc @@ -119,8 +119,8 @@