mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
Bug 870171
This commit is contained in:
parent
c65775caf0
commit
4a90977b5a
@ -1540,10 +1540,9 @@ abstract public class GeckoApp
|
||||
final Context context = GeckoApp.this;
|
||||
AnnouncementsBroadcastService.recordLastLaunch(context);
|
||||
|
||||
// Kick off our background services that fetch product
|
||||
// announcements and upload health reports. We do this by
|
||||
// invoking the broadcast receiver, which uses the system alarm
|
||||
// infrastructure to perform tasks at intervals.
|
||||
// Kick off our background services. We do this by invoking the broadcast
|
||||
// receiver, which uses the system alarm infrastructure to perform tasks at
|
||||
// intervals.
|
||||
GeckoPreferences.broadcastAnnouncementsPref(context);
|
||||
GeckoPreferences.broadcastHealthReportUploadPref(context);
|
||||
|
||||
@ -1938,6 +1937,7 @@ abstract public class GeckoApp
|
||||
public void onPause()
|
||||
{
|
||||
final BrowserHealthRecorder rec = mHealthRecorder;
|
||||
final Context context = this;
|
||||
|
||||
// In some way it's sad that Android will trigger StrictMode warnings
|
||||
// here as the whole point is to save to disk while the activity is not
|
||||
@ -1952,6 +1952,11 @@ abstract public class GeckoApp
|
||||
rec.recordSessionEnd("P", editor);
|
||||
}
|
||||
editor.commit();
|
||||
|
||||
// In theory, the first browser session will not run long enough that we need to
|
||||
// prune during it and we'd rather run it when the browser is inactive so we wait
|
||||
// until here to register the prune service.
|
||||
GeckoPreferences.broadcastHealthReportPrune(context);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -385,6 +385,11 @@ public class GeckoPreferences
|
||||
return sIsCharEncodingEnabled;
|
||||
}
|
||||
|
||||
public static void broadcastAction(final Context context, final Intent intent) {
|
||||
fillIntentWithProfileInfo(context, intent);
|
||||
context.sendBroadcast(intent, GlobalConstants.PER_ANDROID_PACKAGE_PERMISSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast an intent with <code>pref</code>, <code>branch</code>, and
|
||||
* <code>enabled</code> extras. This is intended to represent the
|
||||
@ -397,24 +402,23 @@ public class GeckoPreferences
|
||||
final String action,
|
||||
final String pref,
|
||||
final boolean value) {
|
||||
final Intent intent = new Intent(action);
|
||||
intent.setAction(action);
|
||||
intent.putExtra("pref", pref);
|
||||
intent.putExtra("branch", GeckoApp.PREFS_NAME);
|
||||
intent.putExtra("enabled", value);
|
||||
final Intent intent = new Intent(action)
|
||||
.putExtra("pref", pref)
|
||||
.putExtra("branch", GeckoApp.PREFS_NAME)
|
||||
.putExtra("enabled", value);
|
||||
broadcastAction(context, intent);
|
||||
}
|
||||
|
||||
private static void fillIntentWithProfileInfo(final Context context, final Intent intent) {
|
||||
// There is a race here, but GeckoProfile returns the default profile
|
||||
// when Gecko is not explicitly running for a different profile. In a
|
||||
// multi-profile world, this will need to be updated (possibly to
|
||||
// broadcast settings for all profiles). See Bug 882182.
|
||||
GeckoProfile profile = GeckoProfile.get(context);
|
||||
if (profile != null) {
|
||||
intent.putExtra("profileName", profile.getName());
|
||||
intent.putExtra("profilePath", profile.getDir().getAbsolutePath());
|
||||
intent.putExtra("profileName", profile.getName())
|
||||
.putExtra("profilePath", profile.getDir().getAbsolutePath());
|
||||
}
|
||||
|
||||
Log.d(LOGTAG, "Broadcast: " + action + ", " + pref + ", " + GeckoApp.PREFS_NAME + ", " + value);
|
||||
context.sendBroadcast(intent, GlobalConstants.PER_ANDROID_PACKAGE_PERMISSION);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -457,6 +461,11 @@ public class GeckoPreferences
|
||||
broadcastHealthReportUploadPref(context, value);
|
||||
}
|
||||
|
||||
public static void broadcastHealthReportPrune(final Context context) {
|
||||
final Intent intent = new Intent(HealthReportConstants.ACTION_HEALTHREPORT_PRUNE);
|
||||
broadcastAction(context, intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the named preference in the default preferences file.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user