1 /* 2 * Copyright (C) 2021 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.car.settings.enterprise; 17 18 import android.car.drivingstate.CarUxRestrictions; 19 import android.content.Context; 20 21 import androidx.preference.Preference; 22 23 import com.android.car.settings.R; 24 import com.android.car.settings.common.FragmentController; 25 26 /** 27 * Controller for privacy information about the device owner. 28 * 29 * <p><b>NOTE: </b>phone provides different screens for financed devices, which we don't quite 30 * support yet (see {@code PrivacySettingsPreferenceFactory} 31 */ 32 public final class EnterprisePrivacySettingsPreferenceController 33 extends BaseEnterprisePreferenceController<Preference> { 34 EnterprisePrivacySettingsPreferenceController(Context context, String preferenceKey, FragmentController fragmentController, CarUxRestrictions uxRestrictions)35 public EnterprisePrivacySettingsPreferenceController(Context context, String preferenceKey, 36 FragmentController fragmentController, CarUxRestrictions uxRestrictions) { 37 super(context, preferenceKey, fragmentController, uxRestrictions); 38 } 39 40 @Override getDefaultAvailabilityStatus()41 protected int getDefaultAvailabilityStatus() { 42 int superStatus = super.getDefaultAvailabilityStatus(); 43 if (superStatus != AVAILABLE) { 44 mLogger.d("getAvailabilityStatus(): returning " + superStatus); 45 return superStatus; 46 } 47 48 if (!EnterpriseUtils.hasDeviceOwner(getContext())) { 49 mLogger.d("getAvailabilityStatus(): no device owner, returning " 50 + UNSUPPORTED_ON_DEVICE); 51 return UNSUPPORTED_ON_DEVICE; 52 } 53 54 return AVAILABLE; 55 } 56 57 @Override updateState(Preference preference)58 protected void updateState(Preference preference) { 59 // NOTE: phone displays different messages when the device owner org name is known, but on 60 // automotive we're always showing the generic name 61 preference.setSummary(R.string.enterprise_privacy_settings_summary_generic); 62 } 63 } 64