/*
 * Copyright 2013 CellaSecure
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package edu.washington.cs.cellasecure;

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

public class Drive implements Parcelable {

    public static final String KEY_BUNDLE_DRIVE = "drive";

    private String mName;
    private BluetoothDevice mDevice;

    public Drive(String name, BluetoothDevice bt) {
        mName = name;
        mDevice = bt;
    }

    public Drive(String name, String address) {
        this(name, BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address));
    }

    @Override
    public int describeContents() { return 0; }

    public boolean isLocked() {
        // TODO: Complete me
        return true;
    }

    @Override
    public String toString() { return mName; }
    public String getName() { return mName; }
    public String getAddress() { return mDevice.getAddress(); }
    public BluetoothDevice getDevice() { return mDevice; }

    
    @Override
    public boolean equals(Object o) {
        return (o.getClass().equals(this.getClass()) &&
                ((Drive) o).getAddress().equals(this.getAddress()) &&
                ((Drive) o).getName().equals(this.getName()));

    }
    @Override
    public int hashCode() {
        return 37 * mDevice.hashCode() + 7 * mName.hashCode();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mName);
    }

}

@@ -874,72 +874,605 @@
 e%22;%0A
-%0A    private String mName;%0A    private BluetoothDevice mDevice;%0A
+    %0A    public static final Parcelable.Creator%3CDrive%3E CREATOR%0A        = new Parcelable.Creator%3CDrive%3E() %7B%0A        public Drive createFromParcel(Parcel in) %7B%0A            return new Drive(in);%0A        %7D%0A        %0A        public Drive%5B%5D newArray(int size) %7B%0A            return new Drive%5Bsize%5D;%0A        %7D%0A    %7D;%0A%0A    private String mName;%0A    private BluetoothDevice mDevice;%0A%0A    %0A    private Drive(Parcel in) %7B%0A        mName = in.readString();%0A        mDevice = in.readParcelable(null);%0A    %7D%0A    %0A    public Drive(BluetoothDevice bt) %7B%0A        mName = bt.getName();%0A        mDevice = bt;%0A    %7D%0A    
 %0A   
@@ -1615,24 +1615,33 @@
  address) %7B%0A
+        %0A
         this
@@ -2135,231 +2135,189 @@
 lic 
-boolean equals(Object o) %7B%0A        return (o.getClass().equals(this.getClass()) &&%0A                ((Drive) o).getAddress().equals(this.getAddress()) &&%0A                ((Drive) o).getName().equals(this.getName()));%0A
+int hashCode() %7B%0A        final int prime = 31;%0A        int result = 1;%0A        result = prime * result + ((mDevice == null) ? 0 : mDevice.hashCode());%0A        return result;
 %0A    %7D%0A
+%0A
     
@@ -2341,93 +2341,387 @@
 lic 
-int hashCode() %7B%0A        return 37 * mDevice.hashCode() + 7 * mName.hashCode()
+boolean equals(Object obj) %7B%0A        if (this == obj) return true;%0A        if (obj == null) return false;%0A        if (getClass() != obj.getClass()) return false;%0A        Drive other = ( Drive ) obj;%0A        if (mDevice == null) %7B%0A            if (other.mDevice != null) return false;%0A        %7D else if (!mDevice.equals(other.mDevice)) return false;%0A        return true
 ;%0A    %7D
+%0A    
 %0A%0A  
@@ -2821,16 +2821,62 @@
 mName);%0A
+        dest.writeParcelable(mDevice, flags);%0A
     %7D%0A%0A%7D

Include hashcode/equals/creator