Home | History | Annotate | Download | only in hfp
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.bluetooth.hfp;
     17 
     18 /**
     19  * An object that represents AG indicator enable states
     20  */
     21 public class HeadsetAgIndicatorEnableState extends HeadsetMessageObject {
     22     public boolean service;
     23     public boolean roam;
     24     public boolean signal;
     25     public boolean battery;
     26 
     27     HeadsetAgIndicatorEnableState(boolean newService, boolean newRoam, boolean newSignal,
     28             boolean newBattery) {
     29         service = newService;
     30         roam = newRoam;
     31         signal = newSignal;
     32         battery = newBattery;
     33     }
     34 
     35     @Override
     36     public boolean equals(Object obj) {
     37         if (!(obj instanceof HeadsetAgIndicatorEnableState)) {
     38             return false;
     39         }
     40         HeadsetAgIndicatorEnableState other = (HeadsetAgIndicatorEnableState) obj;
     41         return service == other.service && roam == other.roam && signal == other.signal
     42                 && battery == other.battery;
     43     }
     44 
     45     @Override
     46     public int hashCode() {
     47         int result = 0;
     48         if (service) result += 1;
     49         if (roam) result += 2;
     50         if (signal) result += 4;
     51         if (battery) result += 8;
     52         return result;
     53     }
     54 
     55     @Override
     56     public void buildString(StringBuilder builder) {
     57         if (builder == null) {
     58             return;
     59         }
     60         builder.append(this.getClass().getSimpleName())
     61                 .append("[service=")
     62                 .append(service)
     63                 .append(", roam=")
     64                 .append(roam)
     65                 .append(", signal=")
     66                 .append(signal)
     67                 .append(", battery=")
     68                 .append(battery)
     69                 .append("]");
     70     }
     71 }
     72