Loading packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java +13 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.UserHandle; import android.util.Log; import com.android.settingslib.R; import com.android.settingslib.applications.instantapps.InstantAppDataProvider; import java.util.ArrayList; import java.util.List; Loading @@ -35,6 +36,13 @@ import java.util.List; public class AppUtils { private static final String TAG = "AppUtils"; /** * This should normally only be set in robolectric tests, to avoid getting a method not found * exception when calling the isInstantApp method of the ApplicationInfo class, because * robolectric does not yet have an implementation of it. */ private static InstantAppDataProvider sInstantAppDataProvider = null; public static CharSequence getLaunchByDefaultSummary(ApplicationsState.AppEntry appEntry, IUsbManager usbManager, PackageManager pm, Context context) { String packageName = appEntry.info.packageName; Loading Loading @@ -74,7 +82,11 @@ public class AppUtils { * Returns a boolean indicating whether the given package should be considered an instant app */ public static boolean isInstant(ApplicationInfo info) { if (info.isInstantApp()) { if (sInstantAppDataProvider != null) { if (sInstantAppDataProvider.isInstantApp(info)) { return true; } } else if (info.isInstantApp()) { return true; } Loading packages/SettingsLib/src/com/android/settingslib/applications/instantapps/InstantAppDataProvider.java 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settingslib.applications.instantapps; import android.content.pm.ApplicationInfo; /** * This helps deal with the fact that robolectric does not yet have an implementation of the * isInstantApp method of ApplicationInfo, so we get a method not found exception when running tests * if we try to call it directly. */ public interface InstantAppDataProvider { public boolean isInstantApp(ApplicationInfo info); } Loading
packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java +13 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.UserHandle; import android.util.Log; import com.android.settingslib.R; import com.android.settingslib.applications.instantapps.InstantAppDataProvider; import java.util.ArrayList; import java.util.List; Loading @@ -35,6 +36,13 @@ import java.util.List; public class AppUtils { private static final String TAG = "AppUtils"; /** * This should normally only be set in robolectric tests, to avoid getting a method not found * exception when calling the isInstantApp method of the ApplicationInfo class, because * robolectric does not yet have an implementation of it. */ private static InstantAppDataProvider sInstantAppDataProvider = null; public static CharSequence getLaunchByDefaultSummary(ApplicationsState.AppEntry appEntry, IUsbManager usbManager, PackageManager pm, Context context) { String packageName = appEntry.info.packageName; Loading Loading @@ -74,7 +82,11 @@ public class AppUtils { * Returns a boolean indicating whether the given package should be considered an instant app */ public static boolean isInstant(ApplicationInfo info) { if (info.isInstantApp()) { if (sInstantAppDataProvider != null) { if (sInstantAppDataProvider.isInstantApp(info)) { return true; } } else if (info.isInstantApp()) { return true; } Loading
packages/SettingsLib/src/com/android/settingslib/applications/instantapps/InstantAppDataProvider.java 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settingslib.applications.instantapps; import android.content.pm.ApplicationInfo; /** * This helps deal with the fact that robolectric does not yet have an implementation of the * isInstantApp method of ApplicationInfo, so we get a method not found exception when running tests * if we try to call it directly. */ public interface InstantAppDataProvider { public boolean isInstantApp(ApplicationInfo info); }