Bug 1415929 - [1.0] Move Android app data directory out of setting to an environment variable. r=snorp

This commit is contained in:
Eugen Sawin 2017-11-09 18:22:16 +01:00
parent e1c8aba28f
commit 41e3646a3a
4 changed files with 20 additions and 23 deletions

View File

@ -6,7 +6,6 @@
package org.mozilla.gecko; package org.mozilla.gecko;
import java.io.File;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -477,16 +476,6 @@ public class GeckoSession implements Parcelable {
preload(appContext, /* geckoArgs */ null, multiprocess); preload(appContext, /* geckoArgs */ null, multiprocess);
} }
if (mSettings.getString(GeckoSessionSettings.DATA_DIR) == null) {
final File dataDir = new File(appContext.getApplicationInfo().dataDir);
try {
mSettings.setString(GeckoSessionSettings.DATA_DIR,
dataDir.getCanonicalPath());
} catch (final java.io.IOException e) {
Log.e(LOGTAG, "Failed to resolve app data directory");
}
}
final String chromeUri = mSettings.getString(GeckoSessionSettings.CHROME_URI); final String chromeUri = mSettings.getString(GeckoSessionSettings.CHROME_URI);
final int screenId = mSettings.getInt(GeckoSessionSettings.SCREEN_ID); final int screenId = mSettings.getInt(GeckoSessionSettings.SCREEN_ID);
final boolean isPrivate = mSettings.getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE); final boolean isPrivate = mSettings.getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE);

View File

@ -84,12 +84,6 @@ public final class GeckoSessionSettings implements Parcelable {
public static final Key<Boolean> USE_REMOTE_DEBUGGER = public static final Key<Boolean> USE_REMOTE_DEBUGGER =
new Key<Boolean>("useRemoteDebugger"); new Key<Boolean>("useRemoteDebugger");
public static final Key<String> DEBUGGER_SOCKET_DIR =
new Key<String>("debuggerSocketDir");
/* package */ static final Key<String> DATA_DIR =
new Key<String>("dataDir", /* initOnly */ true, /* values */ null);
private final GeckoSession mSession; private final GeckoSession mSession;
private final GeckoBundle mBundle; private final GeckoBundle mBundle;
@ -108,7 +102,6 @@ public final class GeckoSessionSettings implements Parcelable {
mBundle.putBoolean(USE_MULTIPROCESS.name, true); mBundle.putBoolean(USE_MULTIPROCESS.name, true);
mBundle.putInt(DISPLAY_MODE.name, DISPLAY_MODE_BROWSER); mBundle.putInt(DISPLAY_MODE.name, DISPLAY_MODE_BROWSER);
mBundle.putBoolean(USE_REMOTE_DEBUGGER.name, false); mBundle.putBoolean(USE_REMOTE_DEBUGGER.name, false);
mBundle.putString(DEBUGGER_SOCKET_DIR.name, null);
} }
/* package */ GeckoSessionSettings(final GeckoSessionSettings settings, /* package */ GeckoSessionSettings(final GeckoSessionSettings settings,

View File

@ -125,6 +125,13 @@ public final class GeckoLoader {
} }
} }
try {
final File dataDir = new File(context.getApplicationInfo().dataDir);
putenv("MOZ_ANDROID_DATA_DIR=" + dataDir.getCanonicalPath());
} catch (final java.io.IOException e) {
Log.e(LOGTAG, "Failed to resolve app data directory");
}
putenv("MOZ_ANDROID_PACKAGE_NAME=" + context.getPackageName()); putenv("MOZ_ANDROID_PACKAGE_NAME=" + context.getPackageName());
setupDownloadEnvironment(context); setupDownloadEnvironment(context);

View File

@ -50,15 +50,23 @@ class GeckoViewRemoteDebugger extends GeckoViewModule {
"resource://gre/modules/dbg-browser-actors.js"); "resource://gre/modules/dbg-browser-actors.js");
DebuggerServer.allowChromeProcess = true; DebuggerServer.allowChromeProcess = true;
} }
this._isEnabled = true;
this._usbDebugger.stop();
let windowId = this.window.QueryInterface(Ci.nsIInterfaceRequestor) let windowId = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils) .getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID; .outerWindowID;
let portOrPath = (this.settings.debuggerSocketDir || this.settings.dataDir) + let env = Cc["@mozilla.org/process/environment;1"]
"/firefox-debugger-socket-" + .getService(Ci.nsIEnvironment);
windowId; let dataDir = env.get("MOZ_ANDROID_DATA_DIR");
if (!dataDir) {
debug("Missing env MOZ_ANDROID_DATA_DIR - aborting debugger server start");
return;
}
this._isEnabled = true;
this._usbDebugger.stop();
let portOrPath = dataDir + "/firefox-debugger-socket-" + windowId;
this._usbDebugger.start(portOrPath); this._usbDebugger.start(portOrPath);
} }