Java Code Examples for org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager#getInstance()

The following examples show how to use org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UmaSessionStats.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updating Android preferences according to equivalent native preferences so that the values
 * can be retrieved while native preferences are not accessible.
 */
private void updatePreferences() {
    PrivacyPreferencesManager prefManager = PrivacyPreferencesManager.getInstance();

    // Update cellular experiment preference. Cellular experiment is ON by default.
    boolean cellularExperiment = true;
    if (TextUtils.equals("false", VariationsAssociatedData.getVariationParamValue(
                                        "UMA_EnableCellularLogUpload", "Enabled"))) {
        cellularExperiment = false;
    }
    prefManager.setCellularExperiment(cellularExperiment);

    // Migrate to new preferences for cellular experiment.
    if (cellularExperiment) {
        PrefServiceBridge prefBridge = PrefServiceBridge.getInstance();
        // If the native preference metrics reporting has not been set, then initialize it
        // based on the older android preference.
        if (!prefBridge.hasSetMetricsReporting()) {
            prefBridge.setMetricsReportingEnabled(prefManager.isUploadCrashDumpEnabled());
        }

        // Set new Android preference for usage and crash reporting.
        prefManager.setUsageAndCrashReporting(prefBridge.isMetricsReportingEnabled());
    }

    // Make sure preferences are in sync.
    prefManager.syncUsageAndCrashReportingPrefs();
}
 
Example 2
Source File: UmaSessionStats.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the metrics services based on a change of consent. This can happen during first-run
 * flow, and when the user changes their preferences.
 */
public static void changeMetricsReportingConsent(boolean consent) {
    PrivacyPreferencesManager privacyManager = PrivacyPreferencesManager.getInstance();
    // Update the metrics reporting preference.
    privacyManager.setUsageAndCrashReporting(consent);

    // Perform native changes needed to reflect the new consent value.
    nativeChangeMetricsReportingConsent(consent);

    updateMetricsServiceState();
}
 
Example 3
Source File: UmaSessionStats.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the state of MetricsService to account for the user's preferences.
 */
public static void updateMetricsServiceState() {
    PrivacyPreferencesManager privacyManager = PrivacyPreferencesManager.getInstance();

    // Ensure Android and Chrome local state prefs are in sync.
    privacyManager.syncUsageAndCrashReportingPrefs();

    boolean mayUploadStats = privacyManager.isMetricsUploadPermitted();

    // Re-start the MetricsService with the given parameter, and current consent.
    nativeUpdateMetricsServiceState(mayUploadStats);
}
 
Example 4
Source File: UmaSessionStats.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates relevant Android and native preferences.
 */
private void updatePreferences() {
    PrivacyPreferencesManager prefManager = PrivacyPreferencesManager.getInstance();
    prefManager.migrateUsageAndCrashPreferences();

    // Update the metrics sampling state so it's available before the native feature list is
    // available.
    prefManager.setClientInMetricsSample(UmaUtils.isClientInMetricsReportingSample());

    // Make sure preferences are in sync.
    prefManager.syncUsageAndCrashReportingPrefs();
}
 
Example 5
Source File: UmaSessionStats.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the metrics services based on a change of consent. This can happen during first-run
 * flow, and when the user changes their preferences.
 */
public static void changeMetricsReportingConsent(boolean consent) {
    PrivacyPreferencesManager privacyManager = PrivacyPreferencesManager.getInstance();
    // Update the metrics reporting preference.
    privacyManager.setUsageAndCrashReporting(consent);

    // Perform native changes needed to reflect the new consent value.
    nativeChangeMetricsReportingConsent(consent);

    updateMetricsServiceState();
}
 
Example 6
Source File: UmaSessionStats.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the state of MetricsService to account for the user's preferences.
 */
public static void updateMetricsServiceState() {
    PrivacyPreferencesManager privacyManager = PrivacyPreferencesManager.getInstance();

    // Ensure Android and Chrome local state prefs are in sync.
    privacyManager.syncUsageAndCrashReportingPrefs();

    boolean mayUploadStats = privacyManager.isMetricsUploadPermitted();

    // Re-start the MetricsService with the given parameter, and current consent.
    nativeUpdateMetricsServiceState(mayUploadStats);
}
 
Example 7
Source File: UmaSessionStats.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates relevant Android and native preferences.
 */
private void updatePreferences() {
    PrivacyPreferencesManager prefManager = PrivacyPreferencesManager.getInstance();
    prefManager.migrateUsageAndCrashPreferences();

    // Update the metrics sampling state so it's available before the native feature list is
    // available.
    prefManager.setClientInMetricsSample(UmaUtils.isClientInMetricsReportingSample());

    // Make sure preferences are in sync.
    prefManager.syncUsageAndCrashReportingPrefs();
}
 
Example 8
Source File: UmaSessionStats.java    From delion with Apache License 2.0 4 votes vote down vote up
public UmaSessionStats(Context context) {
    mContext = context;
    mIsMultiWindowCapable = context.getPackageManager().hasSystemFeature(
            SAMSUNG_MULTWINDOW_PACKAGE);
    mReportingPermissionManager = PrivacyPreferencesManager.getInstance();
}
 
Example 9
Source File: MinidumpUploadCallable.java    From delion with Apache License 2.0 4 votes vote down vote up
public MinidumpUploadCallable(File fileToUpload, File logfile, Context context) {
    this(fileToUpload, logfile, new HttpURLConnectionFactoryImpl(),
            PrivacyPreferencesManager.getInstance());
    removeOutdatedPrefs(ContextUtils.getAppSharedPreferences());
}
 
Example 10
Source File: MinidumpUploadService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Get the permission manager, can be overridden for testing.
 */
CrashReportingPermissionManager getCrashReportingPermissionManager() {
    return PrivacyPreferencesManager.getInstance();
}
 
Example 11
Source File: MinidumpUploadService.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Factory method for creating minidump callables.
 *
 * This may be overridden for tests.
 *
 * @param minidumpFile the File to upload.
 * @param logfile the Log file to write to upon successful uploads.
 * @return a new MinidumpUploadCallable.
 */
@VisibleForTesting
MinidumpUploadCallable createMinidumpUploadCallable(File minidumpFile, File logfile) {
    return new MinidumpUploadCallable(
            minidumpFile, logfile, PrivacyPreferencesManager.getInstance());
}