134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood/* 234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * Copyright (C) 2010 The Android Open Source Project 334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * 434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * Licensed under the Apache License, Version 2.0 (the "License"); 534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * you may not use this file except in compliance with the License. 634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * You may obtain a copy of the License at 734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * 834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * http://www.apache.org/licenses/LICENSE-2.0 934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * 1034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * Unless required by applicable law or agreed to in writing, software 1134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * distributed under the License is distributed on an "AS IS" BASIS, 1234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * See the License for the specific language governing permissions and 1434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * limitations under the License. 1534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood */ 1634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 1734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwoodpackage android.location; 1834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 1934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwoodimport android.content.Context; 2034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwoodimport android.os.Parcel; 2134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwoodimport android.os.Parcelable; 2234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 2334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwoodimport java.util.Locale; 2434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 2534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood/** 2634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * This class contains extra parameters to pass to an IGeocodeProvider 2734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * implementation from the Geocoder class. Currently this contains the 2834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * language, country and variant information from the Geocoder's locale 2934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * as well as the Geocoder client's package name for geocoder server 3034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * logging. This information is kept in a separate class to allow for 3134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * future expansion of the IGeocodeProvider interface. 32e15735a9e0c0b1448b68f2d6b3247404fc1df417Mike Lockwood * 33e15735a9e0c0b1448b68f2d6b3247404fc1df417Mike Lockwood * @hide 3434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood */ 3534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwoodpublic class GeocoderParams implements Parcelable { 3634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood private Locale mLocale; 3734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood private String mPackageName; 3834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 3934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood // used only for parcelling 4034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood private GeocoderParams() { 4134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 4234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 4334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood /** 4434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * This object is only constructed by the Geocoder class 4534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * 4634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * @hide 4734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood */ 4834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public GeocoderParams(Context context, Locale locale) { 4934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood mLocale = locale; 5034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood mPackageName = context.getPackageName(); 5134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 5234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 5334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood /** 5434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * returns the Geocoder's locale 5534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood */ 5634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public Locale getLocale() { 5734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood return mLocale; 5834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 5934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 6034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood /** 6134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood * returns the package name of the Geocoder's client 6234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood */ 6334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public String getClientPackage() { 6434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood return mPackageName; 6534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 6634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 6734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public static final Parcelable.Creator<GeocoderParams> CREATOR = 6834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood new Parcelable.Creator<GeocoderParams>() { 6934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public GeocoderParams createFromParcel(Parcel in) { 7034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood GeocoderParams gp = new GeocoderParams(); 7134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood String language = in.readString(); 7234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood String country = in.readString(); 7334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood String variant = in.readString(); 7434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood gp.mLocale = new Locale(language, country, variant); 7534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood gp.mPackageName = in.readString(); 7634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood return gp; 7734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 7834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 7934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public GeocoderParams[] newArray(int size) { 8034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood return new GeocoderParams[size]; 8134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 8234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood }; 8334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 8434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public int describeContents() { 8534901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood return 0; 8634901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 8734901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood 8834901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood public void writeToParcel(Parcel parcel, int flags) { 8934901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood parcel.writeString(mLocale.getLanguage()); 9034901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood parcel.writeString(mLocale.getCountry()); 9134901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood parcel.writeString(mLocale.getVariant()); 9234901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood parcel.writeString(mPackageName); 9334901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood } 9434901409a404c8c66914c5a8ad0f29b1bcde0e78Mike Lockwood} 95