Merge "New design for instant apps in app details header"
This commit is contained in:
committed by
Android (Google) Code Review
commit
16bc3dd1e5
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user