예제 #1
0
  @Override
  public void start() {
    mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
    final boolean connected = mStorageManager.isUsbMassStorageConnected();
    if (DEBUG)
      Log.d(
          TAG,
          String.format(
              "Startup with UMS connection %s (media state %s)",
              mUmsAvailable, Environment.getExternalStorageState()));

    HandlerThread thr = new HandlerThread("SystemUI StorageNotification");
    thr.start();
    mAsyncEventHandler = new Handler(thr.getLooper());

    if (GN_USB_SUPPORT && isFirstBoot()) {
      setToMtpByDefault();
    }

    mStorageEventlistener = new StorageNotificationEventListener();
    mStorageEventlistener.onUsbMassStorageConnectionChanged(connected);
    mStorageManager.registerListener(mStorageEventlistener);

    IntentFilter filter = new IntentFilter();
    filter.addAction(UsbManager.ACTION_USB_STATE);
    mContext.registerReceiver(mUsbStateReceiver, filter);
  }
예제 #2
0
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();

          if (UsbManager.ACTION_USB_STATE.equals(action)) {
            mUsbDeviceConnect = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
            boolean isConnected = mStorageManager.isUsbMassStorageConnected();
            Log.v(
                TAG, "isConnected = " + isConnected + " mUsbDeviceConnect = " + mUsbDeviceConnect);
            mStorageEventlistener.onUsbMassStorageConnectionChanged(isConnected);
          }
        }
  public StorageNotification(Context context) {
    mContext = context;

    mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
    final boolean connected = mStorageManager.isUsbMassStorageConnected();
    Slog.d(
        TAG,
        String.format(
            "Startup with UMS connection %s (media state %s)",
            mUmsAvailable, Environment.getExternalStorageState()));

    HandlerThread thr = new HandlerThread("SystemUI StorageNotification");
    thr.start();
    mAsyncEventHandler = new Handler(thr.getLooper());

    onUsbMassStorageConnectionChanged(connected);
  }
  @Override
  public void start() {
    mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE);
    final boolean connected = mStorageManager.isUsbMassStorageConnected();
    if (DEBUG)
      Log.d(
          TAG,
          String.format(
              "Startup with UMS connection %s (media state %s)",
              mUmsAvailable, Environment.getExternalStorageState()));

    HandlerThread thr = new HandlerThread("SystemUI StorageNotification");
    thr.start();
    mAsyncEventHandler = new Handler(thr.getLooper());

    StorageNotificationEventListener listener = new StorageNotificationEventListener();
    listener.onUsbMassStorageConnectionChanged(connected);
    mStorageManager.registerListener(listener);
  }