private void updateUsbNotification() {
      if (mNotificationManager == null || !mUseUsbNotification) return;
      int id = 0;
      Resources r = mContext.getResources();
      if (mConnected || mHostConnected) {
        if (!mUsbDataUnlocked) {
          id = com.android.internal.R.string.usb_charging_notification_title;
        } else if (UsbManager.containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_MTP)) {
          id = com.android.internal.R.string.usb_mtp_notification_title;
        } else if (UsbManager.containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_PTP)) {
          id = com.android.internal.R.string.usb_ptp_notification_title;
        } else if (UsbManager.containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_MIDI)) {
          id = com.android.internal.R.string.usb_midi_notification_title;
        } else if (UsbManager.containsFunction(
            mCurrentFunctions, UsbManager.USB_FUNCTION_ACCESSORY)) {
          id = com.android.internal.R.string.usb_accessory_notification_title;
        } else {
          id = com.android.internal.R.string.usb_charging_notification_title;
        }
      }
      if (id != mUsbNotificationId) {
        // clear notification if title needs changing
        if (mUsbNotificationId != 0) {
          mNotificationManager.cancelAsUser(null, mUsbNotificationId, UserHandle.ALL);
          mUsbNotificationId = 0;
        }
        if (id != 0) {
          CharSequence message = r.getText(com.android.internal.R.string.usb_notification_message);
          CharSequence title = r.getText(id);

          Intent intent =
              Intent.makeRestartActivityTask(
                  new ComponentName(
                      "com.android.settings",
                      "com.android.settings.deviceinfo.UsbModeChooserActivity"));
          PendingIntent pi =
              PendingIntent.getActivityAsUser(mContext, 0, intent, 0, null, UserHandle.CURRENT);

          Notification notification =
              new Notification.Builder(mContext)
                  .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
                  .setWhen(0)
                  .setOngoing(true)
                  .setTicker(title)
                  .setDefaults(0) // please be quiet
                  .setPriority(Notification.PRIORITY_MIN)
                  .setColor(
                      mContext.getColor(
                          com.android.internal.R.color.system_notification_accent_color))
                  .setContentTitle(title)
                  .setContentText(message)
                  .setContentIntent(pi)
                  .setVisibility(Notification.VISIBILITY_PUBLIC)
                  .build();
          mNotificationManager.notifyAsUser(null, id, notification, UserHandle.ALL);
          mUsbNotificationId = id;
        }
      }
    }
 @DSSafe(DSCat.SAFE_LIST)
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:30:28.964 -0500",
     hash_original_method = "D1E9FB8E8179D25455F859F7C92E2CD3",
     hash_generated_method = "7F80C001EA19CF1555F49F2FDA14BEBE")
 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
   return Intent.makeRestartActivityTask(mainActivity);
 }
    private void updateUsbNotification() {
      if (mNotificationManager == null || !mUseUsbNotification) return;
      int id = 0;
      Resources r = mContext.getResources();
      if (mConnected) {
        if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_MTP)) {
          id = com.android.internal.R.string.usb_mtp_notification_title;
        } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_PTP)) {
          id = com.android.internal.R.string.usb_ptp_notification_title;
        } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_MASS_STORAGE)) {
          id = com.android.internal.R.string.usb_cd_installer_notification_title;
        } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ACCESSORY)) {
          id = com.android.internal.R.string.usb_accessory_notification_title;
        } else {
          // There is a different notification for USB tethering so we don't need one here
          // if (!containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_RNDIS)) {
          //    Slog.e(TAG, "No known USB function in updateUsbNotification");
          // }
        }
      }
      if (id != mUsbNotificationId) {
        // clear notification if title needs changing
        if (mUsbNotificationId != 0) {
          mNotificationManager.cancelAsUser(null, mUsbNotificationId, UserHandle.ALL);
          mUsbNotificationId = 0;
        }
        if (id != 0) {
          CharSequence message = r.getText(com.android.internal.R.string.usb_notification_message);
          CharSequence title = r.getText(id);

          Notification notification = new Notification();
          notification.icon = com.android.internal.R.drawable.stat_sys_data_usb;
          notification.when = 0;
          notification.flags = Notification.FLAG_ONGOING_EVENT;
          notification.tickerText = title;
          notification.defaults = 0; // please be quiet
          notification.sound = null;
          notification.vibrate = null;
          notification.priority = Notification.PRIORITY_MIN;

          Intent intent =
              Intent.makeRestartActivityTask(
                  new ComponentName("com.android.settings", "com.android.settings.UsbSettings"));
          PendingIntent pi =
              PendingIntent.getActivityAsUser(mContext, 0, intent, 0, null, UserHandle.CURRENT);
          notification.setLatestEventInfo(mContext, title, message, pi);
          mNotificationManager.notifyAsUser(null, id, notification, UserHandle.ALL);
          mUsbNotificationId = id;
        }
      }
    }
    private void updateAdbNotification() {
      if (mNotificationManager == null) return;
      final int id = com.android.internal.R.string.adb_active_notification_title;
      boolean hideNotification =
          "0".equals(SystemProperties.get("persist.adb.notify"))
              || Settings.Secure.getInt(
                      mContext.getContentResolver(), Settings.Secure.ADB_NOTIFY, 1)
                  == 0;

      if (mAdbEnabled && mConnected && !mAdbNotificationShown && !hideNotification) {
        Resources r = mContext.getResources();
        CharSequence title = r.getText(id);
        CharSequence message =
            r.getText(com.android.internal.R.string.adb_active_notification_message);

        Intent intent =
            Intent.makeRestartActivityTask(
                new ComponentName(
                    "com.android.settings", "com.android.settings.DevelopmentSettings"));
        PendingIntent pi =
            PendingIntent.getActivityAsUser(mContext, 0, intent, 0, null, UserHandle.CURRENT);

        Notification notification =
            new Notification.Builder(mContext)
                .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
                .setWhen(0)
                .setOngoing(true)
                .setTicker(title)
                .setDefaults(0) // please be quiet
                .setPriority(Notification.PRIORITY_LOW)
                .setColor(
                    mContext.getColor(
                        com.android.internal.R.color.system_notification_accent_color))
                .setContentTitle(title)
                .setContentText(message)
                .setContentIntent(pi)
                .setVisibility(Notification.VISIBILITY_PUBLIC)
                .build();

        mAdbNotificationShown = true;
        mNotificationManager.notifyAsUser(null, id, notification, UserHandle.ALL);
      } else if (mAdbNotificationShown) {
        mAdbNotificationShown = false;
        mNotificationManager.cancelAsUser(null, id, UserHandle.ALL);
      }
    }
    private void updateAdbNotification() {
      if (mNotificationManager == null) return;
      final int id = com.android.internal.R.string.adb_active_notification_title;
      if (mAdbEnabled && mConnected) {
        if ("0".equals(SystemProperties.get("persist.adb.notify"))
            || Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ADB_NOTIFY, 1)
                == 0) return;

        if (!mAdbNotificationShown) {
          Resources r = mContext.getResources();
          CharSequence title = r.getText(id);
          CharSequence message =
              r.getText(com.android.internal.R.string.adb_active_notification_message);

          Notification notification = new Notification();
          notification.icon = com.android.internal.R.drawable.stat_sys_adb;
          notification.when = 0;
          notification.flags = Notification.FLAG_ONGOING_EVENT;
          notification.tickerText = title;
          notification.defaults = 0; // please be quiet
          notification.sound = null;
          notification.vibrate = null;
          notification.priority = Notification.PRIORITY_LOW;

          Intent intent =
              Intent.makeRestartActivityTask(
                  new ComponentName(
                      "com.android.settings", "com.android.settings.DevelopmentSettings"));
          PendingIntent pi =
              PendingIntent.getActivityAsUser(mContext, 0, intent, 0, null, UserHandle.CURRENT);
          notification.setLatestEventInfo(mContext, title, message, pi);
          mAdbNotificationShown = true;
          mNotificationManager.notifyAsUser(null, id, notification, UserHandle.ALL);
        }
      } else if (mAdbNotificationShown) {
        mAdbNotificationShown = false;
        mNotificationManager.cancelAsUser(null, id, UserHandle.ALL);
      }
    }