Bug 972208 - Allow shipping default share providers in distributions. r=margaret

This commit is contained in:
Wes Johnston 2014-04-07 09:33:52 -07:00
parent cdbd21421d
commit 7ff46d8666
2 changed files with 37 additions and 9 deletions

View File

@ -280,7 +280,7 @@ public final class Distribution {
* Returns null if there is no distribution directory or the file
* doesn't exist. Ensures init first.
*/
private File getDistributionFile(String name) {
public File getDistributionFile(String name) {
Log.i(LOGTAG, "Getting file from distribution.");
if (this.state == STATE_UNKNOWN) {
if (!this.doInit()) {

View File

@ -20,6 +20,11 @@
//package android.widget;
package org.mozilla.gecko.widget;
// Mozilla: New import
import org.mozilla.gecko.Distribution;
import org.mozilla.gecko.GeckoProfile;
import java.io.File;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@ -1045,13 +1050,33 @@ public class ActivityChooserModel extends DataSetObservable {
private void readHistoricalDataImpl() {
FileInputStream fis = null;
try {
fis = mContext.openFileInput(mHistoryFileName);
} catch (FileNotFoundException fnfe) {
if (DEBUG) {
Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName);
GeckoProfile profile = GeckoProfile.get(mContext);
File f = profile.getFile(mHistoryFileName);
if (!f.exists()) {
// Fall back to the non-profile aware file if it exists...
File oldFile = new File(mHistoryFileName);
oldFile.renameTo(f);
}
fis = new FileInputStream(f);
} catch (FileNotFoundException fnfe) {
try {
Distribution dist = new Distribution(mContext);
File distFile = dist.getDistributionFile("quickshare/" + mHistoryFileName);
if (distFile == null) {
if (DEBUG) {
Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName);
}
return;
}
fis = new FileInputStream(distFile);
} catch(Exception ex) {
if (DEBUG) {
Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName);
}
return;
}
return;
}
try {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(fis, null);
@ -1122,14 +1147,17 @@ public class ActivityChooserModel extends DataSetObservable {
@SuppressWarnings("unchecked")
public Void doInBackground(Object... args) {
List<HistoricalRecord> historicalRecords = (List<HistoricalRecord>) args[0];
String hostoryFileName = (String) args[1];
String historyFileName = (String) args[1];
FileOutputStream fos = null;
try {
fos = mContext.openFileOutput(hostoryFileName, Context.MODE_PRIVATE);
// Mozilla - Update the location we save files to
GeckoProfile profile = GeckoProfile.get(mContext);
File file = profile.getFile(historyFileName);
fos = new FileOutputStream(file);
} catch (FileNotFoundException fnfe) {
Log.e(LOG_TAG, "Error writing historical recrod file: " + hostoryFileName, fnfe);
Log.e(LOG_TAG, "Error writing historical record file: " + historyFileName, fnfe);
return null;
}