1 /*
2  * Copyright (C) 2018 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.settings.testutils;
18 
19 import android.content.Context;
20 import android.provider.Settings;
21 
22 import com.android.settings.core.SliderPreferenceController;
23 
24 public class FakeSliderController extends SliderPreferenceController {
25 
26     public static final String AVAILABILITY_KEY = "fake_slider_availability_key";
27 
28     public static final int MAX_VALUE = 9;
29 
30     private static final String SETTING_KEY = "fake_slider_key";
31 
FakeSliderController(Context context, String key)32     public FakeSliderController(Context context, String key) {
33         super(context, key);
34     }
35 
36     @Override
getSliderPosition()37     public int getSliderPosition() {
38         return Settings.System.getInt(mContext.getContentResolver(), SETTING_KEY, 0);
39     }
40 
41     @Override
setSliderPosition(int position)42     public boolean setSliderPosition(int position) {
43         return Settings.System.putInt(mContext.getContentResolver(), SETTING_KEY, position);
44     }
45 
46     @Override
getMax()47     public int getMax() {
48         return MAX_VALUE;
49     }
50 
51     @Override
getMin()52     public int getMin() {
53         return 0;
54     }
55 
56     @Override
getAvailabilityStatus()57     public int getAvailabilityStatus() {
58         return Settings.Global.getInt(mContext.getContentResolver(), AVAILABILITY_KEY, AVAILABLE);
59     }
60 
61     @Override
isSliceable()62     public boolean isSliceable() {
63         return true;
64     }
65 }
66