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