package com.philisense.rdgo.ui.user;

import android.content.Context;
import android.telephony.TelephonyManager;

import java.util.UUID;


/**
 * Created by shaop on 2017/12/13.
 */

public class DeviceUtils {
    /*
     * File: DeviceUtils.java

     * Author: wenxiangli

     * Create: 2017/8/17 16:22
     * 获取手机的UUID信息

     */
    private Context context;

    public DeviceUtils(Context context) {
        this.context = context;
    }

    public String getUniqueID() {
        try {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            String tmDevice, tmSerial, androidId;
            tmDevice = "" + tm.getDeviceId();
            tmSerial = "" + tm.getSimSerialNumber();
            androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
            UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
            return deviceUuid.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }


}
