Files
packages_apps_Settings/src/com/android/settings/communal/CommunalPreferenceController.java
Lucas Silva e33639f117 Only show communal settings to the primary user
Fixes: 264284347
Test: flashed device, and verified settings don't appear for secondary
user. Setting still appears for primary user
Test: atest CommunalPreferenceControllerTest

Change-Id: I6686ce4dbc7d708a93131620ae93c5e0dc323995
2023-01-09 15:15:27 +00:00

46 lines
1.6 KiB
Java

/*
* Copyright (C) 2022 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.communal;
import android.content.Context;
import android.os.UserManager;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
/**
* Controls the top-level Communal settings preference.
*/
public class CommunalPreferenceController extends BasePreferenceController {
public CommunalPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
// TODO(b/257333623): Allow the communal user to be non-SystemUser user in HSUM.
return (mContext.getResources().getBoolean(R.bool.config_show_communal_settings)
&& isSystemUser())
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
private boolean isSystemUser() {
final UserManager userManager = mContext.getSystemService(UserManager.class);
return userManager != null && userManager.isSystemUser();
}
}