2 * Copyright (C) 2017 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
14 package com.android.settings.enterprise;
16 import android.content.Context;
17 import android.support.v7.preference.Preference;
19 import com.android.settings.R;
20 import com.android.settings.core.DynamicAvailabilityPreferenceController;
21 import com.android.settings.core.lifecycle.Lifecycle;
22 import com.android.settings.overlay.FeatureFactory;
24 public class EnterprisePrivacyPreferenceController extends DynamicAvailabilityPreferenceController {
26 private static final String KEY_ENTERPRISE_PRIVACY = "enterprise_privacy";
27 private final EnterprisePrivacyFeatureProvider mFeatureProvider;
29 public EnterprisePrivacyPreferenceController(Context context, Lifecycle lifecycle) {
30 super(context, lifecycle);
31 mFeatureProvider = FeatureFactory.getFactory(context)
32 .getEnterprisePrivacyFeatureProvider(context);
36 public void updateState(Preference preference) {
37 final String organizationName = mFeatureProvider.getDeviceOwnerOrganizationName();
38 if (organizationName == null) {
39 preference.setSummary(R.string.enterprise_privacy_settings_summary_generic);
41 preference.setSummary(mContext.getResources().getString(
42 R.string.enterprise_privacy_settings_summary_with_name, organizationName));
47 public boolean isAvailable() {
48 final boolean available = mFeatureProvider.hasDeviceOwner();
49 notifyOnAvailabilityUpdate(available);
54 public String getPreferenceKey() {
55 return KEY_ENTERPRISE_PRIVACY;