blob: 1c6e9b6e18362a3e7a7c86f7ba0597819e8855f2 [file] [log] [blame]
Alan Viverette3da604b2020-06-10 18:34:39 +00001/*
2 * Copyright (C) 2010 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
17package android.location;
18
19import android.compat.annotation.UnsupportedAppUsage;
20import android.content.Context;
21import android.os.Parcel;
22import android.os.Parcelable;
23
24import java.util.Locale;
25
26/**
27 * This class contains extra parameters to pass to an IGeocodeProvider
28 * implementation from the Geocoder class. Currently this contains the
29 * language, country and variant information from the Geocoder's locale
30 * as well as the Geocoder client's package name for geocoder server
31 * logging. This information is kept in a separate class to allow for
32 * future expansion of the IGeocodeProvider interface.
33 *
34 * @hide
35 */
36public class GeocoderParams implements Parcelable {
37 private Locale mLocale;
38 private String mPackageName;
39
40 // used only for parcelling
41 private GeocoderParams() {
42 }
43
44 /**
45 * This object is only constructed by the Geocoder class
46 *
47 * @hide
48 */
49 public GeocoderParams(Context context, Locale locale) {
50 mLocale = locale;
51 mPackageName = context.getPackageName();
52 }
53
54 /**
55 * returns the Geocoder's locale
56 */
57 @UnsupportedAppUsage
58 public Locale getLocale() {
59 return mLocale;
60 }
61
62 /**
63 * returns the package name of the Geocoder's client
64 */
65 @UnsupportedAppUsage
66 public String getClientPackage() {
67 return mPackageName;
68 }
69
70 public static final @android.annotation.NonNull Parcelable.Creator<GeocoderParams> CREATOR =
71 new Parcelable.Creator<GeocoderParams>() {
72 public GeocoderParams createFromParcel(Parcel in) {
73 GeocoderParams gp = new GeocoderParams();
74 String language = in.readString();
75 String country = in.readString();
76 String variant = in.readString();
77 gp.mLocale = new Locale(language, country, variant);
78 gp.mPackageName = in.readString();
79 return gp;
80 }
81
82 public GeocoderParams[] newArray(int size) {
83 return new GeocoderParams[size];
84 }
85 };
86
87 public int describeContents() {
88 return 0;
89 }
90
91 public void writeToParcel(Parcel parcel, int flags) {
92 parcel.writeString(mLocale.getLanguage());
93 parcel.writeString(mLocale.getCountry());
94 parcel.writeString(mLocale.getVariant());
95 parcel.writeString(mPackageName);
96 }
97}