1 /* 2 * Copyright 2024 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.inputmethod; 18 19 import android.content.Context; 20 import android.hardware.input.InputSettings; 21 22 import androidx.annotation.NonNull; 23 24 import com.android.settings.R; 25 import com.android.settings.core.TogglePreferenceController; 26 27 public class MousePointerAccelerationPreferenceController extends TogglePreferenceController { 28 MousePointerAccelerationPreferenceController( @onNull Context context, @NonNull String key)29 public MousePointerAccelerationPreferenceController( 30 @NonNull Context context, @NonNull String key) { 31 super(context, key); 32 } 33 34 @Override isChecked()35 public boolean isChecked() { 36 return InputSettings.isMousePointerAccelerationEnabled(mContext); 37 } 38 39 @Override setChecked(boolean isChecked)40 public boolean setChecked(boolean isChecked) { 41 InputSettings.setMouseAccelerationEnabled(mContext, isChecked); 42 return true; 43 } 44 45 @Override getAvailabilityStatus()46 public int getAvailabilityStatus() { 47 if (!InputSettings.isPointerAccelerationFeatureFlagEnabled()) { 48 return UNSUPPORTED_ON_DEVICE; 49 } 50 return AVAILABLE; 51 } 52 53 @Override getSliceHighlightMenuRes()54 public int getSliceHighlightMenuRes() { 55 return R.string.menu_key_system; 56 } 57 } 58