1 /* 2 * Copyright (C) 2012 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 17 package com.android.location.provider; 18 19 import android.annotation.NonNull; 20 import android.location.provider.ProviderProperties; 21 22 import java.util.Objects; 23 24 /** 25 * Represents provider properties for unbundled applications. 26 * 27 * <p>IMPORTANT: This class is effectively a public API for unbundled applications, and must remain 28 * API stable. 29 */ 30 public final class ProviderPropertiesUnbundled { 31 32 /** 33 * Create new instance of {@link ProviderPropertiesUnbundled} with the given arguments. 34 */ create(boolean requiresNetwork, boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, int powerUsage, int accuracy)35 public static @NonNull ProviderPropertiesUnbundled create(boolean requiresNetwork, 36 boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, 37 boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, 38 int powerUsage, int accuracy) { 39 return new ProviderPropertiesUnbundled(new ProviderProperties.Builder() 40 .setHasNetworkRequirement(requiresNetwork) 41 .setHasSatelliteRequirement(requiresSatellite) 42 .setHasCellRequirement(requiresCell) 43 .setHasMonetaryCost(requiresCell) 44 .setHasAltitudeSupport(requiresCell) 45 .setHasSpeedSupport(requiresCell) 46 .setHasBearingSupport(requiresCell) 47 .setPowerUsage(powerUsage) 48 .setAccuracy(accuracy) 49 .build()); 50 } 51 52 private final ProviderProperties mProperties; 53 ProviderPropertiesUnbundled(ProviderProperties properties)54 private ProviderPropertiesUnbundled(ProviderProperties properties) { 55 mProperties = Objects.requireNonNull(properties); 56 } 57 58 /** @hide */ getProviderProperties()59 public @NonNull ProviderProperties getProviderProperties() { 60 return mProperties; 61 } 62 63 @Override toString()64 public String toString() { 65 return mProperties.toString(); 66 } 67 68 @Override equals(Object o)69 public boolean equals(Object o) { 70 if (this == o) { 71 return true; 72 } 73 if (o == null || getClass() != o.getClass()) { 74 return false; 75 } 76 77 ProviderPropertiesUnbundled that = (ProviderPropertiesUnbundled) o; 78 return mProperties.equals(that.mProperties); 79 } 80 81 @Override hashCode()82 public int hashCode() { 83 return Objects.hash(mProperties); 84 } 85 } 86