From 67952e94a92a429abd0dbc758c99655f67ae2c30 Mon Sep 17 00:00:00 2001 From: Antony Sargent Date: Fri, 10 Feb 2017 11:07:42 -0800 Subject: [PATCH] Add "Instant apps" filter to app listing Bug: 35098444 Test: new test added in ApplicationsStateTest.java ; run it by doing the following commands: make SettingsLibTests -j40 adb install -r $OUT/data/app/SettingsLibTests/SettingsLibTests.apk adb shell am instrument -w com.android.settingslib In Settings->Apps&Notifications->Apps, the list of filters before this CL is: All | Enabled | Disabled With this CL, the filter list becomes: All apps | Installed apps | Disabled apps | Instant apps Change-Id: Ia2ec099f758901839a2aa84fe155ae032990092f --- .../settingslib/applications/AppUtils.java | 27 ++++++++++ .../applications/ApplicationsState.java | 52 +++++++++++++++++-- .../applications/ApplicationsStateTest.java | 29 +++++++++++ 3 files changed, 103 insertions(+), 5 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java b/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java index f6d9134c5e2b0..7f7249f0f9087 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/AppUtils.java @@ -19,9 +19,11 @@ package com.android.settingslib.applications; import android.content.ComponentName; import android.content.Context; import android.content.IntentFilter; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.hardware.usb.IUsbManager; import android.os.RemoteException; +import android.os.SystemProperties; import android.os.UserHandle; import android.util.Log; @@ -68,4 +70,29 @@ public class AppUtils { return prefActList.size() > 0; } + /** + * Returns a boolean indicating whether the given package should be considered an instant app + */ + public static boolean isInstant(ApplicationInfo info) { + if (info.isInstantApp()) { + return true; + } + + // For debugging/testing, we support setting the following property to a comma-separated + // list of search terms (typically, but not necessarily, full package names) to match + // against the package names of the app. + String propVal = SystemProperties.get("settingsdebug.instant.packages"); + if (propVal != null && !propVal.isEmpty() && info.packageName != null) { + String[] searchTerms = propVal.split(","); + if (searchTerms != null) { + for (String term : searchTerms) { + if (info.packageName.contains(term)) { + return true; + } + } + } + } + return false; + } + } diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java index 1f03b51aef9e4..fda3914d1fc08 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java @@ -98,6 +98,7 @@ public class ApplicationsState { boolean mResumed; boolean mHaveDisabledApps; + boolean mHaveInstantApps; // Information about all applications. Synchronize on mEntriesMap // to protect access to these. @@ -212,6 +213,7 @@ public class ApplicationsState { } mHaveDisabledApps = false; + mHaveInstantApps = false; for (int i=0; i