Group some Security settings to a separate "Advanced settings" screen
Test: adb shell am start -a android.settings.SECURITY_SETTINGS opens Advanced Security Settings screen Test: atest SettingsUnitTests:SecurityAdvancedSettingsTest Test: atest SettingsUnitTests:SecurityAdvancedSettingsControllerTest Bug: 204416998 Change-Id: If9c6da812ffb7c046b3b00a084007950801e1d4f
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.security;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.CrossProfileApps;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
/**
|
||||
* Controller to decide the summary of "Advanced settings" option in the
|
||||
* Security settings screen.
|
||||
*/
|
||||
public class SecurityAdvancedSettingsController extends BasePreferenceController {
|
||||
|
||||
private final CrossProfileApps mCrossProfileApps;
|
||||
|
||||
public SecurityAdvancedSettingsController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
|
||||
mCrossProfileApps = context.getSystemService(CrossProfileApps.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return isWorkProfilePresent()
|
||||
? mContext.getResources().getString(
|
||||
R.string.security_advanced_settings_work_profile_settings_summary)
|
||||
: mContext.getResources().getString(
|
||||
R.string.security_advanced_settings_no_work_profile_settings_summary);
|
||||
}
|
||||
|
||||
private boolean isWorkProfilePresent() {
|
||||
return !mCrossProfileApps.getTargetUserProfiles().isEmpty();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user