package com.epson.mobilephone.common.ble.util;

import android.bluetooth.BluetoothDevice;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;

public class ScannedDevice implements Parcelable {
    public static final Parcelable.Creator<ScannedDevice> CREATOR = new Parcelable.Creator<ScannedDevice>() {
        public ScannedDevice createFromParcel(Parcel parcel) {
            return new ScannedDevice(parcel);
        }

        public ScannedDevice[] newArray(int i) {
            return new ScannedDevice[i];
        }
    };
    public static final int HIGH_SIGNAL = -60;
    public static final int INVALID_SIGNAL = 127;
    public static final int LOW_SIGNAL = -75;
    public static final int MID_SIGNAL = -70;
    public static final String TYPE = "ScannedDevice";
    private static final String UNKNOWN = "Unknown";
    private BluetoothDevice mDevice;
    private String mDisplayName;
    private byte[] mHardwareType;
    private int mRssi;

    public int describeContents() {
        return 0;
    }

    protected ScannedDevice(Parcel parcel) {
        mDevice = (BluetoothDevice) parcel.readParcelable(BluetoothDevice.class.getClassLoader());
        mRssi = parcel.readInt();
        mDisplayName = parcel.readString();
        mHardwareType = parcel.createByteArray();
    }

    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeParcelable(mDevice, i);
        parcel.writeInt(mRssi);
        parcel.writeString(mDisplayName);
        parcel.writeByteArray(mHardwareType);
    }

    public ScannedDevice(BluetoothDevice bluetoothDevice, int i, String str, byte[] bArr) {
        if (bluetoothDevice != null) {
            mDevice = bluetoothDevice;
            if (Build.VERSION.SDK_INT >= 21) {
                mDisplayName = str;
            } else {
                mDisplayName = mDevice.getName();
            }
            String str2 = mDisplayName;
            if (str2 == null || str2.length() == 0) {
                mDisplayName = UNKNOWN;
            }
            mRssi = i;
            mHardwareType = bArr;
            return;
        }
        throw new IllegalArgumentException("BluetoothDevice is null");
    }

    public BluetoothDevice getDevice() {
        return mDevice;
    }

    public int getRssi() {
        return mRssi;
    }

    public void setRssi(int i) {
        mRssi = i;
    }

    public byte[] getHardwareType() {
        return mHardwareType;
    }

    public String getDisplayName() {
        return mDisplayName;
    }
}
