• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.location.provider;
18 
19 import android.os.IBinder;
20 
21 import android.location.Address;
22 import android.location.GeocoderParams;
23 import android.location.IGeocodeProvider;
24 
25 import java.util.List;
26 
27 /**
28  * An abstract superclass for geocode providers that are implemented
29  * outside of the core android platform.
30  * Geocode providers can be implemented as services and return the result of
31  * {@link GeocodeProvider#getBinder()} in its getBinder() method.
32  *
33  * @hide
34  */
35 public abstract class GeocodeProvider {
36 
37     private IGeocodeProvider.Stub mProvider = new IGeocodeProvider.Stub() {
38         public String getFromLocation(double latitude, double longitude, int maxResults,
39                 GeocoderParams params, List<Address> addrs) {
40             return GeocodeProvider.this.onGetFromLocation(latitude, longitude, maxResults,
41                     params, addrs);
42         }
43 
44         public String getFromLocationName(String locationName,
45                 double lowerLeftLatitude, double lowerLeftLongitude,
46                 double upperRightLatitude, double upperRightLongitude, int maxResults,
47                 GeocoderParams params, List<Address> addrs) {
48             return GeocodeProvider.this.onGetFromLocationName(locationName, lowerLeftLatitude,
49                     lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
50                     maxResults, params, addrs);
51         }
52     };
53 
54     /**
55      * This method is overridden to implement the
56      * {@link android.location.Geocoder#getFromLocation(double, double, int)} method.
57      * Classes implementing this method should not hold a reference to the params parameter.
58      */
onGetFromLocation(double latitude, double longitude, int maxResults, GeocoderParams params, List<Address> addrs)59     public abstract String onGetFromLocation(double latitude, double longitude, int maxResults,
60             GeocoderParams params, List<Address> addrs);
61 
62     /**
63      * This method is overridden to implement the
64      * {@link android.location.Geocoder#getFromLocationName(String, int, double, double, double, double)} method.
65      * Classes implementing this method should not hold a reference to the params parameter.
66      */
onGetFromLocationName(String locationName, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude, int maxResults, GeocoderParams params, List<Address> addrs)67     public abstract String onGetFromLocationName(String locationName,
68             double lowerLeftLatitude, double lowerLeftLongitude,
69             double upperRightLatitude, double upperRightLongitude, int maxResults,
70             GeocoderParams params, List<Address> addrs);
71 
72     /**
73      * Returns the Binder interface for the geocode provider.
74      * This is intended to be used for the onBind() method of
75      * a service that implements a geocoder service.
76      *
77      * @return the IBinder instance for the provider
78      */
getBinder()79     public IBinder getBinder() {
80         return mProvider;
81     }
82 }
83