org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager Java Examples

The following examples show how to use org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager. 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: ChromeMinidumpUploaderDelegate.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public CrashReportingPermissionManager createCrashReportingPermissionManager() {
    return new CrashReportingPermissionManager() {
        @Override
        public boolean isClientInMetricsSample() {
            return mPermissions.getBoolean(IS_CLIENT_IN_METRICS_SAMPLE, true);
        }

        @Override
        public boolean isNetworkAvailableForCrashUploads() {
            return NetworkPermissionUtil.isNetworkUnmetered(mConnectivityManager);
        }

        @Override
        public boolean isUsageAndCrashReportingPermittedByUser() {
            return PrivacyPreferencesManager.getInstance()
                    .isUsageAndCrashReportingPermittedByUser();
        }

        @Override
        public boolean isUploadEnabledForTests() {
            return mPermissions.getBoolean(IS_UPLOAD_ENABLED_FOR_TESTS, false);
        }
    };
}
 
Example #2
Source File: UmaSessionStats.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the state of the MetricsService to account for the user's preferences.
 */
public void updateMetricsServiceState() {
    boolean mayRecordStats = !PrivacyPreferencesManager.getInstance()
            .isNeverUploadCrashDump();
    boolean mayUploadStats = mReportingPermissionManager.isUmaUploadPermitted();

    // Re-start the MetricsService with the given parameters.
    nativeUpdateMetricsServiceState(mayRecordStats, mayUploadStats);
}
 
Example #3
Source File: PhysicalWeb.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Performs various Physical Web operations that should happen on startup.
 */
public static void onChromeStart() {
    // In the case that the user has disabled our flag and restarted, this is a minimal code
    // path to disable our subscription to Nearby.
    if (!featureIsEnabled()) {
        new NearbyBackgroundSubscription(NearbySubscription.UNSUBSCRIBE).run();
        return;
    }

    // If this user is in the default state, we need to check if we should enable Physical Web.
    if (isOnboarding() && shouldAutoEnablePhysicalWeb()) {
        PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(true);
    }

    updateScans();
    // The PhysicalWebUma call in this method should be called only when the native library
    // is loaded.  This is always the case on chrome startup.
    PhysicalWebUma.uploadDeferredMetrics();

    // We can remove this block after M60.
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            ContextUtils.getAppSharedPreferences().edit()
                    .remove("physical_web_notify_count")
                    .apply();
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: FirstRunGlueImpl.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void acceptTermsOfService(Context appContext, boolean allowCrashUpload) {
    PrivacyPreferencesManager.getInstance().initCrashUploadPreference(allowCrashUpload);
    PrefServiceBridge.getInstance().setEulaAccepted();
}
 
Example #12
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 #13
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 #14
Source File: FirstRunFlowSequencer.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void setDefaultMetricsAndCrashReporting() {
    PrivacyPreferencesManager.getInstance().setUsageAndCrashReporting(
            FirstRunActivity.DEFAULT_METRICS_AND_CRASH_REPORTING);
}
 
Example #15
Source File: FirstRunFlowSequencer.java    From delion with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void enableCrashUpload() {
    PrivacyPreferencesManager.getInstance().initCrashUploadPreference(true);
}
 
Example #16
Source File: FirstRunFlowSequencer.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected void setDefaultMetricsAndCrashReporting() {
    PrivacyPreferencesManager.getInstance().setUsageAndCrashReporting(
            FirstRunActivity.DEFAULT_METRICS_AND_CRASH_REPORTING);
}
 
Example #17
Source File: FirstRunGlueImpl.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isNeverUploadCrashDump(Context appContext) {
    return PrivacyPreferencesManager.getInstance().isNeverUploadCrashDump();
}
 
Example #18
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 #19
Source File: PrecacheLauncher.java    From AndroidChromium with Apache License 2.0 3 votes vote down vote up
/**
 * Updates the PrecacheController with whether conditions are right for precaching. All of
 * the following must be true:
 *
 * <ul>
 *   <li>The predictive network actions preference is enabled.</li>
 *   <li>Sync is enabled for sessions and it is not encrypted with a secondary passphrase.</li>
 *   <li>Either the Precache field trial or the precache commandline flag is enabled.</li>
 * </ul>
 *
 * This should be called only after the sync backend has been initialized. Must be called on the
 * UI thread.
 *
 * @param context any context within the application
 */
private void updateEnabledSync(Context context) {
    // PrefServiceBridge.getInstance() and nativeShouldRun() can only be executed on the UI
    // thread.
    ThreadUtils.assertOnUiThread();

    boolean prerenderEnabled = PrivacyPreferencesManager.getInstance().shouldPrerender();
    boolean shouldRun = nativeShouldRun();

    mPrerenderEnabled = prerenderEnabled;
    mShouldRun = shouldRun;

    PrecacheController.setIsPrecachingEnabled(context, prerenderEnabled && shouldRun);
    Log.v(TAG, "updateEnabledSync complete");
}
 
Example #20
Source File: PrecacheLauncher.java    From 365browser with Apache License 2.0 3 votes vote down vote up
/**
 * Updates the PrecacheController with whether conditions are right for precaching. All of
 * the following must be true:
 *
 * <ul>
 *   <li>The predictive network actions preference is enabled.</li>
 *   <li>Sync is enabled for sessions and it is not encrypted with a secondary passphrase.</li>
 *   <li>Either the Precache field trial or the precache commandline flag is enabled.</li>
 * </ul>
 *
 * This should be called only after the sync backend has been initialized. Must be called on the
 * UI thread.
 *
 * @param context any context within the application
 */
private void updateEnabledSync(Context context) {
    // PrefServiceBridge.getInstance() and nativeShouldRun() can only be executed on the UI
    // thread.
    ThreadUtils.assertOnUiThread();

    boolean prerenderEnabled = PrivacyPreferencesManager.getInstance().shouldPrerender();
    boolean shouldRun = nativeShouldRun();

    mPrerenderEnabled = prerenderEnabled;
    mShouldRun = shouldRun;

    PrecacheController.setIsPrecachingEnabled(context, prerenderEnabled && shouldRun);
    Log.v(TAG, "updateEnabledSync complete");
}
 
Example #21
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());
}
 
Example #22
Source File: PhysicalWeb.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the Physical Web onboard flow is active and the user has
 * not yet elected to either enable or decline the feature.
 *
 * @param context An instance of android.content.Context
 * @return boolean {@code true} if onboarding is complete.
 */
public static boolean isOnboarding(Context context) {
    return PrivacyPreferencesManager.getInstance().isPhysicalWebOnboarding();
}
 
Example #23
Source File: PhysicalWeb.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the Physical Web preference is switched to On.
 *
 * @param context An instance of android.content.Context
 * @return boolean {@code true} if the preference is On.
 */
public static boolean isPhysicalWebPreferenceEnabled(Context context) {
    return PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled();
}
 
Example #24
Source File: PhysicalWeb.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the Physical Web preference is switched to On.
 *
 * @return boolean {@code true} if the preference is On.
 */
public static boolean isPhysicalWebPreferenceEnabled() {
    return PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled();
}
 
Example #25
Source File: PhysicalWeb.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the Physical Web onboard flow is active and the user has
 * not yet elected to either enable or decline the feature.
 *
 * @return boolean {@code true} if onboarding is complete.
 */
public static boolean isOnboarding() {
    return PrivacyPreferencesManager.getInstance().isPhysicalWebOnboarding();
}
 
Example #26
Source File: PhysicalWeb.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the Physical Web onboard flow is active and the user has
 * not yet elected to either enable or decline the feature.
 *
 * @return boolean {@code true} if onboarding is complete.
 */
public static boolean isOnboarding() {
    return PrivacyPreferencesManager.getInstance().isPhysicalWebOnboarding();
}
 
Example #27
Source File: PhysicalWeb.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether the Physical Web preference is switched to On.
 *
 * @return boolean {@code true} if the preference is On.
 */
public static boolean isPhysicalWebPreferenceEnabled() {
    return PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled();
}