org.chromium.chrome.browser.notifications.NotificationConstants Java Examples

The following examples show how to use org.chromium.chrome.browser.notifications.NotificationConstants. 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: UrlManager.java    From delion with Apache License 2.0 6 votes vote down vote up
private void createNotification() {
    PendingIntent pendingIntent = createListUrlsIntent();

    // Get values to display.
    Resources resources = mContext.getResources();
    String title = resources.getString(R.string.physical_web_notification_title);
    Bitmap largeIcon = BitmapFactory.decodeResource(resources,
            R.drawable.physical_web_notification_large);

    // Create the notification.
    Notification notification = new NotificationCompat.Builder(mContext)
            .setLargeIcon(largeIcon)
            .setSmallIcon(R.drawable.ic_chrome)
            .setContentTitle(title)
            .setContentIntent(pendingIntent)
            .setPriority(NotificationCompat.PRIORITY_MIN)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setLocalOnly(true)
            .build();
    mNotificationManager.notify(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB,
                                notification);
}
 
Example #2
Source File: PhysicalWebBroadcastService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Surfaces a notification to the user that the Physical Web is broadcasting.
 * The notification specifies the URL that is being broadcast. It cannot be swiped away,
 * but broadcasting can be terminated with the stop button on the notification.
 */
private void createBroadcastNotification(String displayUrl) {
    Context context = getApplicationContext();
    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(
            context, 0, new Intent(STOP_SERVICE), PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationManagerProxy notificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE));
    ChromeNotificationBuilder notificationBuilder =
            NotificationBuilderFactory
                    .createChromeNotificationBuilder(
                            true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_BROWSER)
                    .setSmallIcon(R.drawable.ic_image_white_24dp)
                    .setContentTitle(getString(R.string.physical_web_broadcast_notification))
                    .setContentText(displayUrl)
                    .setOngoing(true)
                    .addAction(android.R.drawable.ic_menu_close_clear_cancel,
                            getString(R.string.physical_web_stop_broadcast), stopPendingIntent);
    notificationManager.notify(
            NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB, notificationBuilder.build());
    NotificationUmaTracker.getInstance().onNotificationShown(
            NotificationUmaTracker.PHYSICAL_WEB, ChannelDefinitions.CHANNEL_ID_BROWSER);
}
 
Example #3
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a notification to be displayed.
 * @param iconId Id of the notification icon.
 * @param title Title of the notification.
 * @param contentText Notification content text to be displayed.
 * @return notification builder that builds the notification to be displayed
 */
private ChromeNotificationBuilder buildNotification(
        int iconId, String title, String contentText) {
    Bundle extras = new Bundle();
    extras.putInt(EXTRA_NOTIFICATION_BUNDLE_ICON_ID, iconId);

    ChromeNotificationBuilder builder =
            NotificationBuilderFactory
                    .createChromeNotificationBuilder(
                            true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_DOWNLOADS)
                    .setContentTitle(
                            DownloadUtils.getAbbreviatedFileName(title, MAX_FILE_NAME_LENGTH))
                    .setSmallIcon(iconId)
                    .setLocalOnly(true)
                    .setAutoCancel(true)
                    .setContentText(contentText)
                    .setGroup(NotificationConstants.GROUP_DOWNLOADS)
                    .addExtras(extras);
    return builder;
}
 
Example #4
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @return The summary {@link StatusBarNotification} if one is showing.
 */
@TargetApi(Build.VERSION_CODES.M)
private static StatusBarNotification getSummaryNotification(NotificationManager manager) {
    if (!useForegroundService()) return null;

    StatusBarNotification[] notifications = manager.getActiveNotifications();
    for (StatusBarNotification notification : notifications) {
        boolean isDownloadsGroup = TextUtils.equals(notification.getNotification().getGroup(),
                NotificationConstants.GROUP_DOWNLOADS);
        boolean isSummaryNotification =
                notification.getId() == NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY;
        if (isDownloadsGroup && isSummaryNotification) return notification;
    }

    return null;
}
 
Example #5
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Returns whether or not there are any download notifications showing that aren't the summary
 * notification.
 * @param notificationIdToIgnore If not -1, the id of a notification to ignore and
 *                               assume is closing or about to be closed.
 * @return Whether or not there are valid download notifications currently visible.
 */
@TargetApi(Build.VERSION_CODES.M)
private static boolean hasDownloadNotifications(
        NotificationManager manager, int notificationIdToIgnore) {
    if (!useForegroundService()) return false;

    StatusBarNotification[] notifications = manager.getActiveNotifications();
    for (StatusBarNotification notification : notifications) {
        boolean isDownloadsGroup = TextUtils.equals(notification.getNotification().getGroup(),
                NotificationConstants.GROUP_DOWNLOADS);
        boolean isSummaryNotification =
                notification.getId() == NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY;
        boolean isIgnoredNotification =
                notificationIdToIgnore != -1 && notificationIdToIgnore == notification.getId();
        if (isDownloadsGroup && !isSummaryNotification && !isIgnoredNotification) return true;
    }

    return false;
}
 
Example #6
Source File: UrlManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void createNotification() {
    PendingIntent pendingIntent = createListUrlsIntent();

    // Get values to display.
    Resources resources = mContext.getResources();
    String title = resources.getString(R.string.physical_web_notification_title);
    Bitmap largeIcon = BitmapFactory.decodeResource(resources,
            R.drawable.physical_web_notification_large);

    // Create the notification.
    Notification notification = new NotificationCompat.Builder(mContext)
            .setLargeIcon(largeIcon)
            .setSmallIcon(R.drawable.ic_chrome)
            .setContentTitle(title)
            .setContentIntent(pendingIntent)
            .setPriority(NotificationCompat.PRIORITY_MIN)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setLocalOnly(true)
            .build();
    mNotificationManager.notify(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB,
                                notification);
}
 
Example #7
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * On >= O Android releases, puts this service into a foreground state, binding it to the
 * {@link Notification} generated by {@link #buildSummaryNotification(Context)}.
 */
@VisibleForTesting
void startForegroundInternal() {
    if (!useForegroundService()) return;
    Notification notification =
            buildSummaryNotification(getApplicationContext(), mNotificationManager);
    startForeground(NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY, notification);
}
 
Example #8
Source File: SyncNotificationController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Builds and shows a notification for the |message|.
 *
 * @param message Resource id of the message to display in the notification.
 * @param intent Intent to send when the user activates the notification.
 */
private void showSyncNotification(int message, Intent intent) {
    String title = mApplicationContext.getString(R.string.app_name);
    String text = mApplicationContext.getString(R.string.sign_in_sync) + ": "
            + mApplicationContext.getString(message);

    PendingIntent contentIntent = PendingIntent.getActivity(mApplicationContext, 0, intent, 0);

    // There is no need to provide a group summary notification because the NOTIFICATION_ID_SYNC
    // notification id ensures there's only one sync notification at a time.
    ChromeNotificationBuilder builder =
            NotificationBuilderFactory
                    .createChromeNotificationBuilder(
                            true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_BROWSER)
                    .setAutoCancel(true)
                    .setContentIntent(contentIntent)
                    .setContentTitle(title)
                    .setContentText(text)
                    .setSmallIcon(R.drawable.ic_chrome)
                    .setTicker(text)
                    .setLocalOnly(true)
                    .setGroup(NotificationConstants.GROUP_SYNC);

    Notification notification = builder.buildWithBigTextStyle(text);

    mNotificationManager.notify(NotificationConstants.NOTIFICATION_ID_SYNC, notification);
    NotificationUmaTracker.getInstance().onNotificationShown(
            NotificationUmaTracker.SYNC, ChannelDefinitions.CHANNEL_ID_BROWSER);
}
 
Example #9
Source File: SyncNotificationController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Callback for {@link ProfileSyncService.SyncStateChangedListener}.
 */
@Override
public void syncStateChanged() {
    ThreadUtils.assertOnUiThread();

    // Auth errors take precedence over passphrase errors.
    if (!AndroidSyncSettings.isSyncEnabled(mApplicationContext)) {
        mNotificationManager.cancel(NotificationConstants.NOTIFICATION_ID_SYNC);
        return;
    }
    if (shouldSyncAuthErrorBeShown()) {
        showSyncNotification(
                mProfileSyncService.getAuthError().getMessage(), createSettingsIntent());
    } else if (mProfileSyncService.isEngineInitialized()
            && mProfileSyncService.isPassphraseRequiredForDecryption()) {
        if (mProfileSyncService.isPassphrasePrompted()) {
            return;
        }
        switch (mProfileSyncService.getPassphraseType()) {
            case IMPLICIT_PASSPHRASE: // Falling through intentionally.
            case FROZEN_IMPLICIT_PASSPHRASE: // Falling through intentionally.
            case CUSTOM_PASSPHRASE:
                showSyncNotification(R.string.sync_need_passphrase, createPasswordIntent());
                break;
            case KEYSTORE_PASSPHRASE: // Falling through intentionally.
            default:
                mNotificationManager.cancel(NotificationConstants.NOTIFICATION_ID_SYNC);
                return;
        }
    } else {
        mNotificationManager.cancel(NotificationConstants.NOTIFICATION_ID_SYNC);
        return;
    }
}
 
Example #10
Source File: IncognitoNotificationManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the close all incognito notification.
 */
public static void showIncognitoNotification() {
    Context context = ContextUtils.getApplicationContext();
    String actionMessage =
            context.getResources().getString(R.string.close_all_incognito_notification);
    String title = context.getResources().getString(R.string.app_name);

    ChromeNotificationBuilder builder =
            NotificationBuilderFactory
                    .createChromeNotificationBuilder(
                            true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_INCOGNITO)
                    .setContentTitle(title)
                    .setContentIntent(
                            IncognitoNotificationService.getRemoveAllIncognitoTabsIntent(
                                    context))
                    .setContentText(actionMessage)
                    .setOngoing(true)
                    .setVisibility(Notification.VISIBILITY_SECRET)
                    .setSmallIcon(R.drawable.incognito_statusbar)
                    .setShowWhen(false)
                    .setLocalOnly(true)
                    .setGroup(NotificationConstants.GROUP_INCOGNITO);
    NotificationManager nm =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(INCOGNITO_TABS_OPEN_TAG, INCOGNITO_TABS_OPEN_ID, builder.build());
    NotificationUmaTracker.getInstance().onNotificationShown(
            NotificationUmaTracker.CLOSE_INCOGNITO, ChannelDefinitions.CHANNEL_ID_INCOGNITO);
}
 
Example #11
Source File: UrlManager.java    From delion with Apache License 2.0 5 votes vote down vote up
private void createOptInNotification(boolean highPriority) {
    PendingIntent pendingIntent = createOptInIntent();

    int priority = highPriority ? NotificationCompat.PRIORITY_HIGH
            : NotificationCompat.PRIORITY_MIN;

    // Get values to display.
    Resources resources = mContext.getResources();
    String title = resources.getString(R.string.physical_web_optin_notification_title);
    String text = resources.getString(R.string.physical_web_optin_notification_text);
    Bitmap largeIcon = BitmapFactory.decodeResource(resources, R.mipmap.app_icon);

    // Create the notification.
    Notification notification = new NotificationCompat.Builder(mContext)
            .setLargeIcon(largeIcon)
            .setSmallIcon(R.drawable.ic_physical_web_notification)
            .setContentTitle(title)
            .setContentText(text)
            .setContentIntent(pendingIntent)
            .setPriority(priority)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setAutoCancel(true)
            .setLocalOnly(true)
            .build();
    mNotificationManager.notify(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB,
                                notification);
}
 
Example #12
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a summary notification that represents all downloads.
 * {@see #buildSummaryNotification(Context)}.
 * @param context A context used to query Android strings and resources.
 * @param iconId  The id of an icon to use for the notification.
 * @return        a {@link Notification} that represents the summary icon for all downloads.
 */
private static Notification buildSummaryNotificationWithIcon(Context context, int iconId) {
    ChromeNotificationBuilder builder =
            NotificationBuilderFactory
                    .createChromeNotificationBuilder(
                            true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_DOWNLOADS)
                    .setContentTitle(
                            context.getString(R.string.download_notification_summary_title))
                    .setSubText(context.getString(R.string.menu_downloads))
                    .setSmallIcon(iconId)
                    .setLocalOnly(true)
                    .setGroup(NotificationConstants.GROUP_DOWNLOADS)
                    .setGroupSummary(true);
    Bundle extras = new Bundle();
    extras.putInt(EXTRA_NOTIFICATION_BUNDLE_ICON_ID, iconId);
    builder.addExtras(extras);

    // This notification should not actually be shown.  But if it is, set the click intent to
    // open downloads home.
    // TODO(dtrainor): Only do this if we have no transient downloads.
    Intent downloadHomeIntent = buildActionIntent(
            context, DownloadManager.ACTION_NOTIFICATION_CLICKED, null, false);
    builder.setContentIntent(PendingIntent.getBroadcast(context,
            NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY, downloadHomeIntent,
            PendingIntent.FLAG_UPDATE_CURRENT));

    return builder.build();
}
 
Example #13
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the notification summary with a new icon, if necessary.
 * @param removedNotificationId The id of a notification that is currently closing and should be
 *                              ignored.  -1 if no notifications are being closed.
 * @param addedNotification     A {@link Pair} of <id, Notification> of a notification that is
 *                              currently being added and should be used in addition to or in
 *                              place of the existing icons.
 */
private static void updateSummaryIcon(Context context, NotificationManager manager,
        int removedNotificationId, Pair<Integer, Notification> addedNotification) {
    if (!useForegroundService()) return;

    Pair<Boolean, Integer> icon =
            getSummaryIcon(context, manager, removedNotificationId, addedNotification);
    if (!icon.first || !hasDownloadNotifications(manager, removedNotificationId)) return;

    manager.notify(NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY,
            buildSummaryNotificationWithIcon(context, icon.second));
}
 
Example #14
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Checks to see if the summary notification is alone and, if so, hides it.  If the summary
 * notification thinks it's in the foreground, this will start the service with the goal of
 * shutting it down.  That is because if the service is in the foreground it's not possible to
 * stop it through the notification manager.
 * @param removedNotificationId The id of the notification that was just removed or {@code -1}
 *                              if this does not apply.
 */
@TargetApi(Build.VERSION_CODES.M)
public static void hideDanglingSummaryNotification(Context context, int removedNotificationId) {
    if (!useForegroundService()) return;

    NotificationManager manager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (hasDownloadNotifications(manager, removedNotificationId)) return;

    StatusBarNotification summary = getSummaryNotification(manager);
    if (summary == null) return;

    boolean isForeground =
            (summary.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;

    if (BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER)
                    .isStartupSuccessfullyCompleted()) {
        RecordHistogram.recordBooleanHistogram(
                "MobileDownload.Notification.FixingSummaryLeak", isForeground);
    }

    if (isForeground) {
        // If it is a foreground notification, we are in a bad state.  We don't have any
        // other download notifications, but we can't close the summary.  Try to start
        // up the service and quit through that path?
        startDownloadNotificationService(context, new Intent(ACTION_DOWNLOAD_FAIL_SAFE));
    } else {
        manager.cancel(NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY);
    }
}
 
Example #15
Source File: DownloadBroadcastReceiver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called to open a particular download item.  Falls back to opening Download Home.
 * @param context Context of the receiver.
 * @param intent Intent from the android DownloadManager.
 */
private void openDownload(final Context context, Intent intent) {
    int notificationId = IntentUtils.safeGetIntExtra(
            intent, NotificationConstants.EXTRA_NOTIFICATION_ID, -1);
    DownloadNotificationService.hideDanglingSummaryNotification(context, notificationId);

    long ids[] =
            intent.getLongArrayExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS);
    if (ids == null || ids.length == 0) {
        DownloadManagerService.openDownloadsPage(context);
        return;
    }

    long id = ids[0];
    Uri uri = DownloadManagerDelegate.getContentUriFromDownloadManager(context, id);
    if (uri == null) {
        DownloadManagerService.openDownloadsPage(context);
        return;
    }

    String downloadFilename = IntentUtils.safeGetStringExtra(
            intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_PATH);
    boolean isSupportedMimeType =  IntentUtils.safeGetBooleanExtra(
            intent, DownloadNotificationService.EXTRA_IS_SUPPORTED_MIME_TYPE, false);
    boolean isOffTheRecord = IntentUtils.safeGetBooleanExtra(
            intent, DownloadNotificationService.EXTRA_IS_OFF_THE_RECORD, false);
    ContentId contentId = DownloadNotificationService.getContentIdFromIntent(intent);
    DownloadManagerService.openDownloadedContent(
            context, downloadFilename, isSupportedMimeType, isOffTheRecord, contentId.id, id);
}
 
Example #16
Source File: UrlManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void createOptInNotification(boolean highPriority) {
    PendingIntent pendingIntent = createOptInIntent();

    int priority = highPriority ? NotificationCompat.PRIORITY_HIGH
            : NotificationCompat.PRIORITY_MIN;

    // Get values to display.
    Resources resources = mContext.getResources();
    String title = resources.getString(R.string.physical_web_optin_notification_title);
    String text = resources.getString(R.string.physical_web_optin_notification_text);
    Bitmap largeIcon = BitmapFactory.decodeResource(resources, R.mipmap.app_icon);

    // Create the notification.
    Notification notification = new NotificationCompat.Builder(mContext)
            .setLargeIcon(largeIcon)
            .setSmallIcon(R.drawable.ic_physical_web_notification)
            .setContentTitle(title)
            .setContentText(text)
            .setContentIntent(pendingIntent)
            .setPriority(priority)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setAutoCancel(true)
            .setLocalOnly(true)
            .build();
    mNotificationManager.notify(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB,
                                notification);
}
 
Example #17
Source File: SyncNotificationController.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Callback for {@link ProfileSyncService.SyncStateChangedListener}.
 */
@Override
public void syncStateChanged() {
    ThreadUtils.assertOnUiThread();

    int message;
    Intent intent;

    // Auth errors take precedence over passphrase errors.
    if (!AndroidSyncSettings.isSyncEnabled(mApplicationContext)) {
        mNotificationController.cancelNotification(NotificationConstants.NOTIFICATION_ID_SYNC);
        return;
    }
    if (shouldSyncAuthErrorBeShown()) {
        message = mProfileSyncService.getAuthError().getMessage();
        intent = createSettingsIntent();
    } else if (mProfileSyncService.isBackendInitialized()
            && mProfileSyncService.isPassphraseRequiredForDecryption()) {
        if (mProfileSyncService.isPassphrasePrompted()) {
            return;
        }
        switch (mProfileSyncService.getPassphraseType()) {
            case IMPLICIT_PASSPHRASE: // Falling through intentionally.
            case FROZEN_IMPLICIT_PASSPHRASE: // Falling through intentionally.
            case CUSTOM_PASSPHRASE:
                message = R.string.sync_need_passphrase;
                intent = createPasswordIntent();
                break;
            case KEYSTORE_PASSPHRASE: // Falling through intentionally.
            default:
                mNotificationController.cancelNotification(
                        NotificationConstants.NOTIFICATION_ID_SYNC);
                return;
        }
    } else {
        mNotificationController.cancelNotification(NotificationConstants.NOTIFICATION_ID_SYNC);
        return;
    }

    mNotificationController.updateSingleNotification(NotificationConstants.NOTIFICATION_ID_SYNC,
            GoogleServicesNotificationController.formatMessageParts(
                    mApplicationContext, R.string.sign_in_sync, message),
            intent);
}
 
Example #18
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Cancels the existing summary notification.  Moved to a helper method for test mocking.
 */
@VisibleForTesting
void cancelSummaryNotification() {
    mNotificationManager.cancel(NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY);
}
 
Example #19
Source File: PhysicalWebBroadcastService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Turns off URL broadcasting. */
private void disableUrlBroadcasting() {
    NotificationManagerProxy notificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE));
    notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB);
}
 
Example #20
Source File: SyncNotificationController.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Callback for {@link ProfileSyncService.SyncStateChangedListener}.
 */
@Override
public void syncStateChanged() {
    ThreadUtils.assertOnUiThread();

    int message;
    Intent intent;

    // Auth errors take precedence over passphrase errors.
    if (!AndroidSyncSettings.isSyncEnabled(mApplicationContext)) {
        mNotificationController.cancelNotification(NotificationConstants.NOTIFICATION_ID_SYNC);
        return;
    }
    if (shouldSyncAuthErrorBeShown()) {
        message = mProfileSyncService.getAuthError().getMessage();
        intent = createSettingsIntent();
    } else if (mProfileSyncService.isBackendInitialized()
            && mProfileSyncService.isPassphraseRequiredForDecryption()) {
        if (mProfileSyncService.isPassphrasePrompted()) {
            return;
        }
        switch (mProfileSyncService.getPassphraseType()) {
            case IMPLICIT_PASSPHRASE: // Falling through intentionally.
            case FROZEN_IMPLICIT_PASSPHRASE: // Falling through intentionally.
            case CUSTOM_PASSPHRASE:
                message = R.string.sync_need_passphrase;
                intent = createPasswordIntent();
                break;
            case KEYSTORE_PASSPHRASE: // Falling through intentionally.
            default:
                mNotificationController.cancelNotification(
                        NotificationConstants.NOTIFICATION_ID_SYNC);
                return;
        }
    } else {
        mNotificationController.cancelNotification(NotificationConstants.NOTIFICATION_ID_SYNC);
        return;
    }

    mNotificationController.updateSingleNotification(NotificationConstants.NOTIFICATION_ID_SYNC,
            GoogleServicesNotificationController.formatMessageParts(
                    mApplicationContext, R.string.sign_in_sync, message),
            intent);
}
 
Example #21
Source File: UrlManager.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Clear the URLManager's notification.
 * Typically, this should not be called except when we want to clear the notification without
 * modifying the list of URLs, as is the case when we want to remove stale notifications.
 */
public void clearNotification() {
    mNotificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB);
    cancelClearNotificationAlarm();
}
 
Example #22
Source File: UrlManager.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Clear the URLManager's notification.
 * Typically, this should not be called except when we want to clear the notification without
 * modifying the list of URLs, as is the case when we want to remove stale notifications.
 */
public void clearNotification() {
    mNotificationManager.cancel(NotificationConstants.NOTIFICATION_ID_PHYSICAL_WEB);
    cancelClearNotificationAlarm();
}