1 /* 2 * Copyright (C) 2023 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.settings.users 17 18 import android.content.Context 19 import androidx.preference.PreferenceFragmentCompat 20 import com.android.settings.Utils 21 import com.android.settings.dashboard.profileselector.ProfileSelectFragment 22 23 class AutoSyncPrivateDataPreferenceController( 24 context: Context?, parent: PreferenceFragmentCompat?) 25 : AutoSyncDataPreferenceController(context, parent) { 26 init { 27 mUserHandle = Utils 28 .getProfileOfType(mUserManager, ProfileSelectFragment.ProfileType.PRIVATE) 29 } 30 getPreferenceKeynull31 override fun getPreferenceKey(): String { 32 return KEY_AUTO_SYNC_PRIVATE_ACCOUNT 33 } 34 isAvailablenull35 override fun isAvailable(): Boolean { 36 return (mUserHandle != null 37 && mUserManager.getUserInfo(mUserHandle.identifier).isPrivateProfile) 38 } 39 40 companion object { 41 private const val KEY_AUTO_SYNC_PRIVATE_ACCOUNT = "auto_sync_private_account_data" 42 } 43 }