package com.xhly.manageapp.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbManager;
import android.util.Log;

public class USBReceiver extends BroadcastReceiver {
    public static final String ACTION_USB_STATE = "android.hardware.usb.action.USB_STATE";
    public static final String USB_FUNCTION_MTP = "mtp";
    public static final String USB_FUNCTION_PTP = "ptp";
    public static final String USB_FUNCTION_ADB = "adb";
    public static final String USB_CONNECTED="connected";

    @Override
    public void onReceive(Context context, Intent intent) {

        boolean booleanExtra = intent.getBooleanExtra(USB_CONNECTED, false);
        boolean booleanExtra1 = intent.getBooleanExtra(USB_FUNCTION_MTP, false);
        boolean booleanExtra2 = intent.getBooleanExtra(USB_FUNCTION_PTP, false);
        boolean booleanExtra3 = intent.getBooleanExtra(USB_FUNCTION_ADB, false);
        Log.i("USBReceiver", "获取权限成功：1.链接=="+booleanExtra+",mtp=="+booleanExtra1+",ptp=="+booleanExtra2+",adb=="+booleanExtra3);
    }
}
