mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-27 10:50:35 +00:00
Bug 972208 - Allow shipping default share providers in distributions. r=margaret
This commit is contained in:
parent
cdbd21421d
commit
7ff46d8666
@ -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()) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user