1 /* 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 17 package android.location; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.SystemApi; 22 import android.content.Context; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 import android.os.Process; 26 27 import java.util.Locale; 28 import java.util.Objects; 29 30 /** 31 * This class was originally shipped out-of-band from the normal API processes as a separate drop 32 * before SystemApi existed. Now that SystemApi does exist, this class has been retroactively 33 * published through SystemApi. 34 * 35 * @deprecated Do not use. 36 * @hide 37 */ 38 @Deprecated 39 @SystemApi 40 public class GeocoderParams implements Parcelable { 41 42 private final int mUid; 43 private final String mPackageName; 44 private final @Nullable String mAttributionTag; 45 private final Locale mLocale; 46 GeocoderParams(Context context)47 public GeocoderParams(Context context) { 48 this(context, Locale.getDefault()); 49 } 50 GeocoderParams(Context context, Locale locale)51 public GeocoderParams(Context context, Locale locale) { 52 this(Process.myUid(), context.getPackageName(), context.getAttributionTag(), locale); 53 } 54 GeocoderParams( int uid, String packageName, @Nullable String attributionTag, Locale locale)55 public GeocoderParams( 56 int uid, String packageName, @Nullable String attributionTag, Locale locale) { 57 mUid = uid; 58 mPackageName = Objects.requireNonNull(packageName); 59 mAttributionTag = attributionTag; 60 mLocale = Objects.requireNonNull(locale); 61 } 62 63 /** 64 * Returns the client UID. 65 */ getClientUid()66 public int getClientUid() { 67 return mUid; 68 } 69 70 /** 71 * Returns the client package name. 72 */ getClientPackage()73 public @NonNull String getClientPackage() { 74 return mPackageName; 75 } 76 77 /** 78 * Returns the client attribution tag. 79 */ getClientAttributionTag()80 public @Nullable String getClientAttributionTag() { 81 return mAttributionTag; 82 } 83 84 /** 85 * Returns the locale. 86 */ getLocale()87 public @NonNull Locale getLocale() { 88 return mLocale; 89 } 90 91 public static final @NonNull Parcelable.Creator<GeocoderParams> CREATOR = 92 new Parcelable.Creator<>() { 93 public GeocoderParams createFromParcel(Parcel in) { 94 int uid = in.readInt(); 95 String packageName = in.readString8(); 96 String attributionTag = in.readString8(); 97 String language = in.readString8(); 98 String country = in.readString8(); 99 String variant = in.readString8(); 100 101 return new GeocoderParams( 102 uid, 103 packageName, 104 attributionTag, 105 new Locale(language, country, variant)); 106 } 107 108 public GeocoderParams[] newArray(int size) { 109 return new GeocoderParams[size]; 110 } 111 }; 112 113 @Override describeContents()114 public int describeContents() { 115 return 0; 116 } 117 118 @Override writeToParcel(Parcel parcel, int flags)119 public void writeToParcel(Parcel parcel, int flags) { 120 parcel.writeInt(mUid); 121 parcel.writeString8(mPackageName); 122 parcel.writeString8(mAttributionTag); 123 parcel.writeString8(mLocale.getLanguage()); 124 parcel.writeString8(mLocale.getCountry()); 125 parcel.writeString8(mLocale.getVariant()); 126 } 127 } 128