1 /* 2 * Copyright (C) 2015 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.launcher3.util; 18 19 import android.content.Context; 20 import android.content.pm.ApplicationInfo; 21 import android.content.pm.PackageManager; 22 import android.util.Log; 23 24 import com.android.launcher3.AppInfo; 25 import com.android.launcher3.R; 26 27 /** 28 * A wrapper class to access instant app related APIs. 29 */ 30 public class InstantAppResolver implements ResourceBasedOverride { 31 newInstance(Context context)32 public static InstantAppResolver newInstance(Context context) { 33 return Overrides.getObject( 34 InstantAppResolver.class, context, R.string.instant_app_resolver_class); 35 } 36 isInstantApp(ApplicationInfo info)37 public boolean isInstantApp(ApplicationInfo info) { 38 return false; 39 } 40 isInstantApp(AppInfo info)41 public boolean isInstantApp(AppInfo info) { 42 return false; 43 } 44 isInstantApp(Context context, String packageName)45 public boolean isInstantApp(Context context, String packageName) { 46 PackageManager packageManager = context.getPackageManager(); 47 try { 48 return isInstantApp(packageManager.getPackageInfo(packageName, 0).applicationInfo); 49 } catch (PackageManager.NameNotFoundException e) { 50 Log.e("InstantAppResolver", "Failed to determine whether package is instant app " 51 + packageName, e); 52 } 53 return false; 54 } 55 } 56