package com.sheep.jiuyan.samllsheep.utils;

import android.Manifest;
import android.content.Context;

import android.content.pm.PackageManager;
import android.net.wifi.WifiManager;

import android.support.v4.app.ActivityCompat;
import android.telephony.TelephonyManager;


/**
 * @ Created by Dlg
 * @ <p>TiTle:  DeviceUtils</p>
 * @ <p>Description:获取各种硬件信息</p>
 * @ date:  2017/10/29 11:48
 * @ QQ:    315096953
 */

public class DeviceUtils {

    private Context mContext;
    private TelephonyManager phone;
    private WifiManager wifi;

    public DeviceUtils(Context context) {
        phone = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        mContext = context;
    }

    public String getIMEI() {
        try {
            if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    ActivityCompat#requestPermissions
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for ActivityCompat#requestPermissions for more details.
                return "";
            }
            return phone.getDeviceId();
        } catch (Exception e) {
            return "";
        }
    }


}
