/** Sets the media storage notification. */
  private synchronized void setMediaStorageNotification(
      int titleId,
      int messageId,
      int icon,
      boolean visible,
      boolean dismissable,
      PendingIntent pi) {

    if (!visible && mMediaStorageNotification == null) {
      return;
    }

    NotificationManager notificationManager =
        (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

    if (notificationManager == null) {
      return;
    }

    if (mMediaStorageNotification != null && visible) {
      /*
       * Dismiss the previous notification - we're about to
       * re-use it.
       */
      final int notificationId = mMediaStorageNotification.icon;
      notificationManager.cancel(notificationId);
    }

    if (visible) {
      Resources r = Resources.getSystem();
      CharSequence title = r.getText(titleId);
      CharSequence message = r.getText(messageId);

      if (mMediaStorageNotification == null) {
        mMediaStorageNotification = new Notification();
        mMediaStorageNotification.when = 0;
      }

      mMediaStorageNotification.defaults &= ~Notification.DEFAULT_SOUND;

      if (dismissable) {
        mMediaStorageNotification.flags = Notification.FLAG_AUTO_CANCEL;
      } else {
        mMediaStorageNotification.flags = Notification.FLAG_ONGOING_EVENT;
      }

      mMediaStorageNotification.tickerText = title;
      if (pi == null) {
        Intent intent = new Intent();
        pi = PendingIntent.getBroadcastAsUser(mContext, 0, intent, 0, UserHandle.CURRENT);
      }

      mMediaStorageNotification.icon = icon;
      mMediaStorageNotification.color =
          mContext
              .getResources()
              .getColor(com.android.internal.R.color.system_notification_accent_color);
      mMediaStorageNotification.setLatestEventInfo(mContext, title, message, pi);
      mMediaStorageNotification.visibility = Notification.VISIBILITY_PUBLIC;
      mMediaStorageNotification.category = Notification.CATEGORY_SYSTEM;
    }

    final int notificationId = mMediaStorageNotification.icon;
    if (visible) {
      notificationManager.notifyAsUser(
          null, notificationId, mMediaStorageNotification, UserHandle.ALL);
    } else {
      notificationManager.cancelAsUser(null, notificationId, UserHandle.ALL);
    }
  }
  /** Sets the USB storage notification. */
  private synchronized void setUsbStorageNotification(
      int titleId, int messageId, int icon, boolean sound, boolean visible, PendingIntent pi) {

    if (!visible && mUsbStorageNotification == null) {
      return;
    }

    NotificationManager notificationManager =
        (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

    if (notificationManager == null) {
      return;
    }

    if (visible) {
      Resources r = Resources.getSystem();
      CharSequence title = r.getText(titleId);
      CharSequence message = r.getText(messageId);

      if (mUsbStorageNotification == null) {
        mUsbStorageNotification = new Notification();
        mUsbStorageNotification.icon = icon;
        mUsbStorageNotification.when = 0;
      }

      if (sound) {
        mUsbStorageNotification.defaults |= Notification.DEFAULT_SOUND;
      } else {
        mUsbStorageNotification.defaults &= ~Notification.DEFAULT_SOUND;
      }

      mUsbStorageNotification.flags = Notification.FLAG_ONGOING_EVENT;

      mUsbStorageNotification.tickerText = title;
      if (pi == null) {
        Intent intent = new Intent();
        pi = PendingIntent.getBroadcastAsUser(mContext, 0, intent, 0, UserHandle.CURRENT);
      }
      mUsbStorageNotification.color =
          mContext
              .getResources()
              .getColor(com.android.internal.R.color.system_notification_accent_color);
      mUsbStorageNotification.setLatestEventInfo(mContext, title, message, pi);
      mUsbStorageNotification.visibility = Notification.VISIBILITY_PUBLIC;
      mUsbStorageNotification.category = Notification.CATEGORY_SYSTEM;

      final boolean adbOn =
          1
              == Settings.Global.getInt(
                  mContext.getContentResolver(), Settings.Global.ADB_ENABLED, 0);

      if (POP_UMS_ACTIVITY_ON_CONNECT && !adbOn) {
        // Pop up a full-screen alert to coach the user through enabling UMS. The average
        // user has attached the device to USB either to charge the phone (in which case
        // this is harmless) or transfer files, and in the latter case this alert saves
        // several steps (as well as subtly indicates that you shouldn't mix UMS with other
        // activities on the device).
        //
        // If ADB is enabled, however, we suppress this dialog (under the assumption that a
        // developer (a) knows how to enable UMS, and (b) is probably using USB to install
        // builds or use adb commands.
        // Modify by GIONEE
        // mUsbStorageNotification.fullScreenIntent = pi;
      }
    }

    final int notificationId = mUsbStorageNotification.icon;
    if (visible) {
      notificationManager.notifyAsUser(
          null, notificationId, mUsbStorageNotification, UserHandle.CURRENT);
    } else {
      notificationManager.cancelAsUser(null, notificationId, UserHandle.CURRENT);
    }
  }