InstantAppDomainsPreferenceController.java revision a0006d93bdeb24137cb29f44cfb2de020bd64f6e
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 17package com.android.settings.applications.appinfo; 18 19import android.content.Context; 20import android.content.pm.PackageManager; 21import android.support.v7.preference.Preference; 22 23import com.android.settings.Utils; 24import com.android.settings.applications.AppDomainsPreference; 25import com.android.settingslib.applications.AppUtils; 26 27import java.util.Set; 28 29public class InstantAppDomainsPreferenceController extends AppInfoPreferenceControllerBase { 30 31 private static final String KEY_INSTANT_APP_SUPPORTED_LINKS = 32 "instant_app_launch_supported_domain_urls"; 33 34 private PackageManager mPackageManager; 35 36 public InstantAppDomainsPreferenceController(Context context, AppInfoDashboardFragment parent) { 37 super(context, parent, KEY_INSTANT_APP_SUPPORTED_LINKS); 38 mPackageManager = mContext.getPackageManager(); 39 } 40 41 @Override 42 public int getAvailabilityStatus() { 43 return AppUtils.isInstant(mParent.getPackageInfo().applicationInfo) 44 ? AVAILABLE : DISABLED_FOR_USER; 45 } 46 47 @Override 48 public void updateState(Preference preference) { 49 final AppDomainsPreference instantAppDomainsPreference = (AppDomainsPreference) preference; 50 final Set<String> handledDomainSet = 51 Utils.getHandledDomains(mPackageManager, mParent.getPackageInfo().packageName); 52 final String[] handledDomains = 53 handledDomainSet.toArray(new String[handledDomainSet.size()]); 54 instantAppDomainsPreference.setTitles(handledDomains); 55 // Dummy values, unused in the implementation 56 instantAppDomainsPreference.setValues(new int[handledDomains.length]); 57 } 58 59} 60