Backout bug 872806 for multiple android test failures

This commit is contained in:
Wes Kocher 2013-07-02 23:47:46 -07:00
parent 33fb0579f9
commit 94aca7fea5
5 changed files with 48 additions and 34 deletions

View File

@ -56,9 +56,15 @@ public final class Distribution {
return;
}
// This pref stores the path to the distribution directory. If it is null, Gecko
// looks for distribution files in /data/data/org.mozilla.xxx/distribution.
String pathKeyName = context.getPackageName() + ".distribution_path";
String distPath = null;
// Send a message to Gecko if we've set a distribution.
if (state == STATE_SET) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", ""));
distPath = settings.getString(pathKeyName, null);
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", distPath));
return;
}
@ -75,11 +81,16 @@ public final class Distribution {
File distDir = new File("/system/" + context.getPackageName() + "/distribution");
if (distDir.exists()) {
distributionSet = true;
<<<<<<< local
distPath = distDir.getPath();
settings.edit().putString(pathKeyName, distPath).commit();
=======
>>>>>>> other
}
}
if (distributionSet) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", ""));
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", distPath));
settings.edit().putInt(keyName, STATE_SET).commit();
} else {
settings.edit().putInt(keyName, STATE_NONE).commit();

View File

@ -7371,6 +7371,9 @@ var Distribution = {
// File used to store campaign data
_file: null,
// Path to distribution directory for distribution customizations
_path: null,
init: function dc_init() {
Services.obs.addObserver(this, "Distribution:Set", false);
Services.obs.addObserver(this, "prefservice:after-app-defaults", false);
@ -7392,6 +7395,8 @@ var Distribution = {
observe: function dc_observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "Distribution:Set":
this._path = aData;
// Reload the default prefs so we can observe "prefservice:after-app-defaults"
Services.prefs.QueryInterface(Ci.nsIObserver).observe(null, "reload-default-prefs", null);
break;
@ -7432,12 +7437,20 @@ var Distribution = {
},
getPrefs: function dc_getPrefs() {
// Get the distribution directory, and bail if it doesn't exist.
let file = FileUtils.getDir("XREAppDist", [], false);
if (!file.exists())
return;
let file;
if (this._path) {
file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(this._path);
// Store the path in a pref for DirectoryProvider to read.
Services.prefs.setCharPref("distribution.path", this._path);
} else {
// If a path isn't specified, look in the data directory:
// /data/data/org.mozilla.xxx/distribution
file = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
file.append("distribution");
}
file.append("preferences.json");
this.readJSON(file, this.applyPrefs);
},

View File

@ -2,8 +2,6 @@
* 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/. */
#filter substitution
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
@ -21,13 +19,10 @@ const NS_APP_SEARCH_DIR = "SrchPlugns";
const NS_APP_SEARCH_DIR_LIST = "SrchPluginsDL";
const NS_APP_USER_SEARCH_DIR = "UsrSrchPlugns";
const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
const XRE_APP_DISTRIBUTION_DIR = "XREAppDist";
const XRE_UPDATE_ROOT_DIR = "UpdRootD";
const ENVVAR_UPDATE_DIR = "UPDATES_DIRECTORY";
const WEBAPPS_DIR = "webappsDir";
const SYSTEM_DIST_PATH = "/system/@ANDROID_PACKAGE_NAME@/distribution";
function DirectoryProvider() {}
DirectoryProvider.prototype = {
@ -48,15 +43,6 @@ DirectoryProvider.prototype = {
let dirsvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
let profile = dirsvc.get("ProfD", Ci.nsIFile);
return profile.parent;
} else if (prop == XRE_APP_DISTRIBUTION_DIR) {
// First, check to see if there's a distribution in the data directory, then return
// the system distribution directory if that doesn't exist.
let dir = FileUtils.getDir(NS_XPCOM_CURRENT_PROCESS_DIR, ["distribution"], false);
if (!dir.exists()) {
dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
dir.initWithPath(SYSTEM_DIST_PATH);
}
return dir;
} else if (prop == XRE_UPDATE_ROOT_DIR) {
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
if (env.exists(ENVVAR_UPDATE_DIR)) {
@ -94,9 +80,20 @@ DirectoryProvider.prototype = {
* which specifies a default locale to use.
*/
_appendDistroSearchDirs: function(array) {
let distro = this.getFile(XRE_APP_DISTRIBUTION_DIR);
if (!distro.exists())
return;
let distro = FileUtils.getDir(NS_XPCOM_CURRENT_PROCESS_DIR, ["distribution"], false);
if (!distro.exists()) {
// If there's no distribution in the data directory, check for a system distribution.
let path;
try {
path = Services.prefs.getCharPref("distribution.path");
} catch (e) { }
if (!path)
return;
distro = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
distro.initWithPath(path);
}
let searchPlugins = distro.clone();
searchPlugins.append("searchplugins");

View File

@ -25,8 +25,4 @@ EXTRA_COMPONENTS = \
FilePicker.js \
$(NULL)
DEFINES += \
-DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -10,15 +10,12 @@ XPIDL_SOURCES += [
MODULE = 'MobileComponents'
EXTRA_COMPONENTS += [
'BrowserCLH.js',
'HelperAppDialog.js',
'Sidebar.js',
]
EXTRA_PP_COMPONENTS += [
'AboutRedirector.js',
'BrowserCLH.js',
'DirectoryProvider.js',
'HelperAppDialog.js',
'MobileComponents.manifest',
'SessionStore.js',
'Sidebar.js',
]