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