1 /* 2 * Copyright (C) 2022 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 17 package com.android.car.settings.applications; 18 19 import android.car.drivingstate.CarUxRestrictions; 20 import android.content.Context; 21 22 import androidx.preference.Preference; 23 24 import com.android.car.settings.R; 25 import com.android.car.settings.applications.performance.PerfImpactingAppsItemManager; 26 import com.android.car.settings.common.FragmentController; 27 import com.android.car.settings.common.PreferenceController; 28 import com.android.settingslib.utils.StringUtil; 29 30 /** 31 * Controller for the entry point to performance-impacting apps settings. It fetches the number of 32 * resource overuse packages and updates the entry point preference's summary. 33 */ 34 public final class PerfImpactingAppsEntryPreferenceController extends 35 PreferenceController<Preference> implements 36 PerfImpactingAppsItemManager.PerfImpactingAppsListener { 37 PerfImpactingAppsEntryPreferenceController(Context context, String preferenceKey, FragmentController fragmentController, CarUxRestrictions uxRestrictions)38 public PerfImpactingAppsEntryPreferenceController(Context context, 39 String preferenceKey, 40 FragmentController fragmentController, 41 CarUxRestrictions uxRestrictions) { 42 super(context, preferenceKey, fragmentController, uxRestrictions); 43 } 44 45 @Override getPreferenceType()46 protected Class<Preference> getPreferenceType() { 47 return Preference.class; 48 } 49 50 @Override onPerfImpactingAppsLoaded(int disabledPackagesCount)51 public void onPerfImpactingAppsLoaded(int disabledPackagesCount) { 52 getPreference().setSummary(StringUtil.getIcuPluralsString(getContext(), 53 disabledPackagesCount, R.string.performance_impacting_apps_summary)); 54 } 55 } 56