1 /* 2 * Copyright (C) 2017 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.car.settings.applications; 17 18 import android.content.Intent; 19 import android.content.pm.PackageManager; 20 import android.content.pm.ResolveInfo; 21 import android.os.Bundle; 22 23 import com.android.car.settings.R; 24 import com.android.car.settings.common.ListSettingsFragment; 25 import com.android.car.settings.common.TypedPagedListAdapter; 26 27 import java.util.ArrayList; 28 import java.util.List; 29 30 /** 31 * Lists all installed applications and their summary. 32 */ 33 public class ApplicationSettingsFragment extends ListSettingsFragment { 34 getInstance()35 public static ApplicationSettingsFragment getInstance() { 36 ApplicationSettingsFragment applicationSettingsFragment = new ApplicationSettingsFragment(); 37 Bundle bundle = ListSettingsFragment.getBundle(); 38 bundle.putInt(EXTRA_TITLE_ID, R.string.applications_settings); 39 applicationSettingsFragment.setArguments(bundle); 40 return applicationSettingsFragment; 41 } 42 43 @Override getLineItems()44 public ArrayList<TypedPagedListAdapter.LineItem> getLineItems() { 45 PackageManager pm = getContext().getPackageManager(); 46 Intent intent= new Intent(Intent.ACTION_MAIN); 47 intent.addCategory(Intent.CATEGORY_LAUNCHER); 48 List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 49 PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS 50 | PackageManager.MATCH_DISABLED_COMPONENTS); 51 ArrayList<TypedPagedListAdapter.LineItem> items = new ArrayList<>(); 52 for (ResolveInfo resolveInfo : resolveInfos) { 53 items.add(new ApplicationLineItem(getContext(), pm, resolveInfo, mFragmentController)); 54 } 55 return items; 56 } 57 } 58