From 4af5b9276e48b606a2ec9f24adee2072eee0a1bf Mon Sep 17 00:00:00 2001 From: Antony Sargent Date: Tue, 28 Feb 2017 10:22:14 -0800 Subject: [PATCH] New design for instant apps in app details header Bug: 35098444 Test: make RunSettingsRoboTests In the previous design for instant apps, some metadata about the app such as developer title, maturity rating, etc. was going to be shown in the app header. In the latest design, we instead are just showing a little label that says "Instant app". The two CL's for this topic work together to change this: frameworks/base : adds code to work around the problem that robolectric doesn't know about the new isInstantApp method of the ApplicationInfo class, so we need to avoid calling it during tests. pacakges/apps/Settings: removes the code that previously displayed the instant app metadata, and instead just insert the "Instant app" label. Change-Id: Ie436085d4a257a1dd90b64d34d6ef15b8df369fd --- .../settingslib/applications/AppUtils.java | 14 +++++++++- .../instantapps/InstantAppDataProvider.java | 28 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 packages/SettingsLib/src/com/android/settingslib/applications/instantapps/InstantAppDataProvider.java diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java b/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java index 7f7249f0f9087..b06b0328f8fd3 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java @@ -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; } diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/instantapps/InstantAppDataProvider.java b/packages/SettingsLib/src/com/android/settingslib/applications/instantapps/InstantAppDataProvider.java new file mode 100644 index 0000000000000..8b15715f5a6f2 --- /dev/null +++ b/packages/SettingsLib/src/com/android/settingslib/applications/instantapps/InstantAppDataProvider.java @@ -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); +}