16fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly/* 26fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * Copyright (C) 2012 The Android Open Source Project 36fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * 46fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * Licensed under the Apache License, Version 2.0 (the "License"); 56fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * you may not use this file except in compliance with the License. 66fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * You may obtain a copy of the License at 76fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * 86fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * http://www.apache.org/licenses/LICENSE-2.0 96fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * 106fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * Unless required by applicable law or agreed to in writing, software 116fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * distributed under the License is distributed on an "AS IS" BASIS, 126fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * See the License for the specific language governing permissions and 146fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * limitations under the License. 156fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 166fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 176fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pellypackage com.android.internal.location; 186fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 196fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pellyimport android.os.Parcel; 206fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pellyimport android.os.Parcelable; 216fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 226fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly/** 236fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * A Parcelable containing (legacy) location provider properties. 246fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * This object is just used inside the framework and system services. 256fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * @hide 266fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 276fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pellypublic final class ProviderProperties implements Parcelable { 286fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 296fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * True if provider requires access to a 306fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * data network (e.g., the Internet), false otherwise. 316fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 326fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final boolean mRequiresNetwork; 336fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 346fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 356fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * True if the provider requires access to a 366fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * satellite-based positioning system (e.g., GPS), false 376fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * otherwise. 386fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 396fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final boolean mRequiresSatellite; 406fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 416fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 426fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * True if the provider requires access to an appropriate 436fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * cellular network (e.g., to make use of cell tower IDs), false 446fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * otherwise. 456fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 466fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final boolean mRequiresCell; 476fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 486fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 496fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * True if the use of this provider may result in a 506fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * monetary charge to the user, false if use is free. It is up to 516fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * each provider to give accurate information. Cell (network) usage 526fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * is not considered monetary cost. 536fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 546fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final boolean mHasMonetaryCost; 556fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 566fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 576fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * True if the provider is able to provide altitude 586fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * information, false otherwise. A provider that reports altitude 596fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * under most circumstances but may occasionally not report it 606fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * should return true. 616fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 626fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final boolean mSupportsAltitude; 636fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 646fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 656fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * True if the provider is able to provide speed 666fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * information, false otherwise. A provider that reports speed 676fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * under most circumstances but may occasionally not report it 686fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * should return true. 696fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 706fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final boolean mSupportsSpeed; 716fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 726fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 736fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * True if the provider is able to provide bearing 746fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * information, false otherwise. A provider that reports bearing 756fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * under most circumstances but may occasionally not report it 766fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * should return true. 776fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 786fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final boolean mSupportsBearing; 796fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 806fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 816fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * Power requirement for this provider. 826fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * 836fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * @return the power requirement for this provider, as one of the 846fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * constants Criteria.POWER_*. 856fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 866fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final int mPowerRequirement; 876fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 886fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly /** 896fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * Constant describing the horizontal accuracy returned 906fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * by this provider. 916fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * 926fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * @return the horizontal accuracy for this provider, as one of the 936fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly * constants Criteria.ACCURACY_COARSE or Criteria.ACCURACY_FINE 946fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly */ 956fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public final int mAccuracy; 966fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 976fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public ProviderProperties(boolean mRequiresNetwork, 986fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean mRequiresSatellite, boolean mRequiresCell, boolean mHasMonetaryCost, 996fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean mSupportsAltitude, boolean mSupportsSpeed, boolean mSupportsBearing, 1006fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly int mPowerRequirement, int mAccuracy) { 1016fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mRequiresNetwork = mRequiresNetwork; 1026fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mRequiresSatellite = mRequiresSatellite; 1036fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mRequiresCell = mRequiresCell; 1046fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mHasMonetaryCost = mHasMonetaryCost; 1056fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mSupportsAltitude = mSupportsAltitude; 1066fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mSupportsSpeed = mSupportsSpeed; 1076fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mSupportsBearing = mSupportsBearing; 1086fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mPowerRequirement = mPowerRequirement; 1096fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly this.mAccuracy = mAccuracy; 1106fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly } 1116fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 1126fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public static final Parcelable.Creator<ProviderProperties> CREATOR = 1136fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly new Parcelable.Creator<ProviderProperties>() { 1146fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly @Override 1156fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public ProviderProperties createFromParcel(Parcel in) { 1166fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean requiresNetwork = in.readInt() == 1; 1176fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean requiresSatellite = in.readInt() == 1; 1186fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean requiresCell = in.readInt() == 1; 1196fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean hasMonetaryCost = in.readInt() == 1; 1206fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean supportsAltitude = in.readInt() == 1; 1216fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean supportsSpeed = in.readInt() == 1; 1226fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly boolean supportsBearing = in.readInt() == 1; 1236fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly int powerRequirement = in.readInt(); 1246fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly int accuracy = in.readInt(); 1256fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly return new ProviderProperties(requiresNetwork, requiresSatellite, 1266fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly requiresCell, hasMonetaryCost, supportsAltitude, supportsSpeed, supportsBearing, 1276fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly powerRequirement, accuracy); 1286fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly } 1296fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly @Override 1306fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public ProviderProperties[] newArray(int size) { 1316fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly return new ProviderProperties[size]; 1326fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly } 1336fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly }; 1346fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 1356fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly @Override 1366fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public int describeContents() { 1376fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly return 0; 1386fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly } 1396fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly 1406fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly @Override 1416fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly public void writeToParcel(Parcel parcel, int flags) { 1426fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mRequiresNetwork ? 1 : 0); 1436fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mRequiresSatellite ? 1 : 0); 1446fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mRequiresCell ? 1 : 0); 1456fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mHasMonetaryCost ? 1 : 0); 1466fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mSupportsAltitude ? 1 : 0); 1476fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mSupportsSpeed ? 1 : 0); 1481332b53522e281012fefb34bfbcc68a03028f516Nick Pelly parcel.writeInt(mSupportsBearing ? 1 : 0); 1496fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mPowerRequirement); 1506fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly parcel.writeInt(mAccuracy); 1516fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly } 1526fa9ad4afcd762aea519ff61811386c23d18ddb2Nick Pelly} 153