blob: cb1e4972f89c33e7795386c0b20dde47293e0781 [file] [log] [blame]
Heemin Seogf401cf22018-12-06 16:34:00 -08001/*
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
17package com.android.car.settings.system;
18
davidln8cd37362018-12-12 10:51:39 -080019import android.car.drivingstate.CarUxRestrictions;
Heemin Seogf401cf22018-12-06 16:34:00 -080020import android.car.userlib.CarUserManagerHelper;
21import android.content.Context;
Anthony Hugh492f1842019-07-11 13:50:15 -070022import android.os.UserManager;
Heemin Seogf401cf22018-12-06 16:34:00 -080023
davidln8cd37362018-12-12 10:51:39 -080024import androidx.preference.Preference;
25
Heemin Seogf401cf22018-12-06 16:34:00 -080026import com.android.car.settings.common.FragmentController;
davidln8cd37362018-12-12 10:51:39 -080027import com.android.car.settings.common.PreferenceController;
Heemin Seogf401cf22018-12-06 16:34:00 -080028import com.android.car.settings.development.DevelopmentSettingsUtil;
29
30/** Controls the visibility of the developer options setting. */
davidln8cd37362018-12-12 10:51:39 -080031public class DeveloperOptionsEntryPreferenceController extends PreferenceController<Preference> {
Heemin Seogf401cf22018-12-06 16:34:00 -080032
33 private CarUserManagerHelper mCarUserManagerHelper;
Anthony Hugh492f1842019-07-11 13:50:15 -070034 private UserManager mUserManager;
Heemin Seogf401cf22018-12-06 16:34:00 -080035
davidln8cd37362018-12-12 10:51:39 -080036 public DeveloperOptionsEntryPreferenceController(Context context, String preferenceKey,
37 FragmentController fragmentController, CarUxRestrictions uxRestrictions) {
38 super(context, preferenceKey, fragmentController, uxRestrictions);
39 mCarUserManagerHelper = new CarUserManagerHelper(context);
Anthony Hugh492f1842019-07-11 13:50:15 -070040 mUserManager = UserManager.get(context);
Heemin Seogf401cf22018-12-06 16:34:00 -080041 }
42
43 @Override
davidln8cd37362018-12-12 10:51:39 -080044 protected Class<Preference> getPreferenceType() {
45 return Preference.class;
46 }
47
48 @Override
49 protected int getAvailabilityStatus() {
50 return DevelopmentSettingsUtil.isDevelopmentSettingsEnabled(getContext(),
Anthony Hugh492f1842019-07-11 13:50:15 -070051 mCarUserManagerHelper, mUserManager) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
Heemin Seogf401cf22018-12-06 16:34:00 -080052 }
53}