Home | History | Annotate | Download | only in location
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
      5  * except in compliance with the License. You may obtain a copy of the License at
      6  *
      7  *      http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software distributed under the
     10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     11  * KIND, either express or implied. See the License for the specific language governing
     12  * permissions and limitations under the License.
     13  */
     14 package com.android.settings.location;
     15 
     16 import android.content.Context;
     17 import android.os.UserManager;
     18 
     19 import com.android.settings.core.PreferenceControllerMixin;
     20 import com.android.settingslib.core.AbstractPreferenceController;
     21 import com.android.settingslib.core.lifecycle.Lifecycle;
     22 
     23 /**
     24  * A base controller for preferences that listens to location settings change and modifies location
     25  * settings.
     26  */
     27 public abstract class LocationBasePreferenceController extends AbstractPreferenceController
     28         implements PreferenceControllerMixin, LocationEnabler.LocationModeChangeListener {
     29 
     30     protected final UserManager mUserManager;
     31     protected final LocationEnabler mLocationEnabler;
     32 
     33     public LocationBasePreferenceController(Context context, Lifecycle lifecycle) {
     34         super(context);
     35         mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
     36         mLocationEnabler = new LocationEnabler(context, this /* listener */, lifecycle);
     37     }
     38 
     39     @Override
     40     public boolean isAvailable() {
     41         return true;
     42     }
     43 
     44 }
     45