• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.location.util.identity.CallerIdentity;
22 import android.os.PackageTagsList;
23 
24 /**
25  * Location manager local system service interface.
26  *
27  * @hide Only for use within the system server.
28  */
29 public abstract class LocationManagerInternal {
30 
31     /**
32      * Listener for changes in provider enabled state.
33      */
34     public interface ProviderEnabledListener {
35         /**
36          * Called when the provider enabled state changes for a particular user.
37          */
onProviderEnabledChanged(String provider, int userId, boolean enabled)38         void onProviderEnabledChanged(String provider, int userId, boolean enabled);
39     }
40 
41     /**
42      * Interface for getting callbacks when an app id's location provider package tags change.
43      */
44     public interface LocationPackageTagsListener {
45 
46         /**
47          * Called when the package tags for a location provider change for a uid.
48          */
onLocationPackageTagsChanged(int uid, @NonNull PackageTagsList packageTagsList)49         void onLocationPackageTagsChanged(int uid, @NonNull PackageTagsList packageTagsList);
50     }
51 
52     /**
53      * Returns true if the given provider is enabled for the given user.
54      *
55      * @param provider A location provider as listed by {@link LocationManager#getAllProviders()}
56      * @param userId   The user id to check
57      * @return True if the provider is enabled, false otherwise
58      */
isProviderEnabledForUser(@onNull String provider, int userId)59     public abstract boolean isProviderEnabledForUser(@NonNull String provider, int userId);
60 
61     /**
62      * Adds a provider enabled listener. The given provider must exist.
63      *
64      * @param provider The provider to listen for changes
65      * @param listener The listener
66      */
addProviderEnabledListener(String provider, ProviderEnabledListener listener)67     public abstract void addProviderEnabledListener(String provider,
68             ProviderEnabledListener listener);
69 
70     /**
71      * Removes a provider enabled listener. The given provider must exist.
72      *
73      * @param provider The provider to listen for changes
74      * @param listener The listener
75      */
removeProviderEnabledListener(String provider, ProviderEnabledListener listener)76     public abstract void removeProviderEnabledListener(String provider,
77             ProviderEnabledListener listener);
78 
79     /**
80      * Returns true if the given identity is a location provider.
81      *
82      * @param provider The provider to check, or null to check every provider
83      * @param identity The identity to match
84      * @return True if the given identity matches either the given location provider or any
85      * provider, and false otherwise
86      */
isProvider(@ullable String provider, @NonNull CallerIdentity identity)87     public abstract boolean isProvider(@Nullable String provider, @NonNull CallerIdentity identity);
88 
89     /**
90      * Should only be used by GNSS code.
91      */
92     // TODO: there is no reason for this to exist as part of any API. move all the logic into gnss
sendNiResponse(int notifId, int userResponse)93     public abstract void sendNiResponse(int notifId, int userResponse);
94 
95     /**
96      * Returns the GNSS provided time.
97      *
98      * @return LocationTime object that includes the current time, according to the GNSS location
99      * provider, and the elapsed nanos since boot the current time was computed at.
100      */
getGnssTimeMillis()101     public abstract @Nullable LocationTime getGnssTimeMillis();
102 
103     /**
104      * Sets a listener for changes in an app id's location provider package tags. Passing
105      * {@code null} clears the current listener.
106      */
setLocationPackageTagsListener( @ullable LocationPackageTagsListener listener)107     public abstract void setLocationPackageTagsListener(
108             @Nullable LocationPackageTagsListener listener);
109 }
110