blob: 67fedf5653ea892f6492aa04ce8d076f114665ac [file]
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.content.Context;
import android.hardware.usb.flags.Flags;
import android.os.SystemProperties;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
public class DisableUserspaceAoaPreferenceController extends TogglePreferenceController
implements RebootConfirmationDialogHost {
private static final String PREF_KEY = "disable_userspace_aoa";
private static final String PROPERTY_FORCE_DISABLE_USERSPACE_AOA =
"persist.sys.usb.force_disable_userspace_aoa";
@Nullable private Fragment mFragment;
public DisableUserspaceAoaPreferenceController(Context context, @Nullable Fragment fragment) {
super(context, PREF_KEY);
mFragment = fragment;
}
@Override
public int getAvailabilityStatus() {
return Flags.enableAoaUserspaceImplementation()
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isChecked() {
return SystemProperties.getBoolean(PROPERTY_FORCE_DISABLE_USERSPACE_AOA, false);
}
@Override
public boolean setChecked(boolean isChecked) {
SystemProperties.set(PROPERTY_FORCE_DISABLE_USERSPACE_AOA, Boolean.toString(isChecked));
if (mFragment != null) {
RebootConfirmationDialogFragment.show(
mFragment, R.string.reboot_dialog_disable_userspace_aoa, this);
}
return true;
}
@Override
public int getSliceHighlightMenuRes() {
return com.android.settings.R.string.menu_key_system;
}
}