mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 03:18:41 +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
|
* Returns null if there is no distribution directory or the file
|
||||||
* doesn't exist. Ensures init first.
|
* doesn't exist. Ensures init first.
|
||||||
*/
|
*/
|
||||||
private File getDistributionFile(String name) {
|
public File getDistributionFile(String name) {
|
||||||
Log.i(LOGTAG, "Getting file from distribution.");
|
Log.i(LOGTAG, "Getting file from distribution.");
|
||||||
if (this.state == STATE_UNKNOWN) {
|
if (this.state == STATE_UNKNOWN) {
|
||||||
if (!this.doInit()) {
|
if (!this.doInit()) {
|
||||||
|
@ -20,6 +20,11 @@
|
|||||||
//package android.widget;
|
//package android.widget;
|
||||||
package org.mozilla.gecko.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.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -1045,13 +1050,33 @@ public class ActivityChooserModel extends DataSetObservable {
|
|||||||
private void readHistoricalDataImpl() {
|
private void readHistoricalDataImpl() {
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
try {
|
try {
|
||||||
fis = mContext.openFileInput(mHistoryFileName);
|
GeckoProfile profile = GeckoProfile.get(mContext);
|
||||||
} catch (FileNotFoundException fnfe) {
|
File f = profile.getFile(mHistoryFileName);
|
||||||
if (DEBUG) {
|
if (!f.exists()) {
|
||||||
Log.i(LOG_TAG, "Could not open historical records file: " + mHistoryFileName);
|
// 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 {
|
try {
|
||||||
XmlPullParser parser = Xml.newPullParser();
|
XmlPullParser parser = Xml.newPullParser();
|
||||||
parser.setInput(fis, null);
|
parser.setInput(fis, null);
|
||||||
@ -1122,14 +1147,17 @@ public class ActivityChooserModel extends DataSetObservable {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Void doInBackground(Object... args) {
|
public Void doInBackground(Object... args) {
|
||||||
List<HistoricalRecord> historicalRecords = (List<HistoricalRecord>) args[0];
|
List<HistoricalRecord> historicalRecords = (List<HistoricalRecord>) args[0];
|
||||||
String hostoryFileName = (String) args[1];
|
String historyFileName = (String) args[1];
|
||||||
|
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
|
|
||||||
try {
|
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) {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user