summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Antony Sargent <asargent@google.com> 2017-03-02 21:03:35 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-03-02 21:03:39 +0000
commit16bc3dd1e556c78dff1032227f42e98b46669735 (patch)
tree91c2aebd5920fda7e6d7cb3ef7ab9fd2e426c074
parentecf3c76cc23aa522c4b252c02c975b2360d21d0f (diff)
parent4af5b9276e48b606a2ec9f24adee2072eee0a1bf (diff)
Merge "New design for instant apps in app details header"
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java14
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/applications/instantapps/InstantAppDataProvider.java28
2 files changed, 41 insertions, 1 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java b/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java
index 7f7249f0f908..b06b0328f8fd 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 000000000000..8b15715f5a6f
--- /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);
+}