summaryrefslogtreecommitdiffstats
path: root/quickstep
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-03-12 18:06:56 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-03-12 18:06:56 +0000
commit4c8fbb9c95f9952ce30669b59c041d423b46750a (patch)
tree2380f9313929f6f20c2c1c75d194adf9963c50a2 /quickstep
parentf386e49c2dc5f37a5a3a7a421a1a72ca955c0397 (diff)
parent61e084601e331a77ff5c164e405681a14a4c00f4 (diff)
downloadandroid_packages_apps_Trebuchet-4c8fbb9c95f9952ce30669b59c041d423b46750a.tar.gz
android_packages_apps_Trebuchet-4c8fbb9c95f9952ce30669b59c041d423b46750a.tar.bz2
android_packages_apps_Trebuchet-4c8fbb9c95f9952ce30669b59c041d423b46750a.zip
Merge "Adding implementation of InstantAppResolver for quickstep" into ub-launcher3-master
Diffstat (limited to 'quickstep')
-rw-r--r--quickstep/res/values/override.xml2
-rw-r--r--quickstep/src/com/android/quickstep/InstantAppResolverImpl.java77
-rw-r--r--quickstep/src/com/android/quickstep/NormalizedIconLoader.java21
3 files changed, 93 insertions, 7 deletions
diff --git a/quickstep/res/values/override.xml b/quickstep/res/values/override.xml
index ba99d81c0..2bd9f8f6f 100644
--- a/quickstep/res/values/override.xml
+++ b/quickstep/res/values/override.xml
@@ -16,5 +16,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_transition_manager_class" translatable="false">com.android.launcher3.LauncherAppTransitionManagerImpl</string>
+
+ <string name="instant_app_resolver_class" translatable="false">com.android.quickstep.InstantAppResolverImpl</string>
</resources>
diff --git a/quickstep/src/com/android/quickstep/InstantAppResolverImpl.java b/quickstep/src/com/android/quickstep/InstantAppResolverImpl.java
new file mode 100644
index 000000000..12757c0f7
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/InstantAppResolverImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2018 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.quickstep;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.InstantAppInfo;
+import android.content.pm.PackageManager;
+import android.util.Log;
+
+import com.android.launcher3.AppInfo;
+import com.android.launcher3.util.InstantAppResolver;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Implementation of InstantAppResolver using platform APIs
+ */
+@SuppressWarnings("unused")
+public class InstantAppResolverImpl extends InstantAppResolver {
+
+ private static final String TAG = "InstantAppResolverImpl";
+ public static final String COMPONENT_CLASS_MARKER = "@instantapp";
+
+ private final PackageManager mPM;
+
+ public InstantAppResolverImpl(Context context)
+ throws NoSuchMethodException, ClassNotFoundException {
+ mPM = context.getPackageManager();
+ }
+
+ @Override
+ public boolean isInstantApp(ApplicationInfo info) {
+ return info.isInstantApp();
+ }
+
+ @Override
+ public boolean isInstantApp(AppInfo info) {
+ ComponentName cn = info.getTargetComponent();
+ return cn != null && cn.getClassName().equals(COMPONENT_CLASS_MARKER);
+ }
+
+ @Override
+ public List<ApplicationInfo> getInstantApps() {
+ try {
+ List<ApplicationInfo> result = new ArrayList<>();
+ for (InstantAppInfo iai : mPM.getInstantApps()) {
+ ApplicationInfo info = iai.getApplicationInfo();
+ if (info != null) {
+ result.add(info);
+ }
+ }
+ return result;
+ } catch (SecurityException se) {
+ Log.w(TAG, "getInstantApps failed. Launcher may not be the default home app.", se);
+ } catch (Exception e) {
+ Log.e(TAG, "Error calling API: getInstantApps", e);
+ }
+ return super.getInstantApps();
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/NormalizedIconLoader.java b/quickstep/src/com/android/quickstep/NormalizedIconLoader.java
index 431fb30a1..3247312fe 100644
--- a/quickstep/src/com/android/quickstep/NormalizedIconLoader.java
+++ b/quickstep/src/com/android/quickstep/NormalizedIconLoader.java
@@ -29,6 +29,7 @@ import android.util.SparseArray;
import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.graphics.BitmapInfo;
+import com.android.launcher3.graphics.DrawableFactory;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.systemui.shared.recents.model.IconLoader;
import com.android.systemui.shared.recents.model.TaskKeyLruCache;
@@ -40,11 +41,13 @@ import com.android.systemui.shared.recents.model.TaskKeyLruCache;
public class NormalizedIconLoader extends IconLoader {
private final SparseArray<BitmapInfo> mDefaultIcons = new SparseArray<>();
+ private final DrawableFactory mDrawableFactory;
private LauncherIcons mLauncherIcons;
public NormalizedIconLoader(Context context, TaskKeyLruCache<Drawable> iconCache,
LruCache<ComponentName, ActivityInfo> activityInfoCache) {
super(context, iconCache, activityInfoCache);
+ mDrawableFactory = DrawableFactory.get(context);
}
@Override
@@ -53,7 +56,7 @@ public class NormalizedIconLoader extends IconLoader {
BitmapInfo info = mDefaultIcons.get(userId);
if (info == null) {
info = getBitmapInfo(Resources.getSystem()
- .getDrawable(android.R.drawable.sym_def_app_icon), userId);
+ .getDrawable(android.R.drawable.sym_def_app_icon), userId, false);
mDefaultIcons.put(userId, info);
}
@@ -63,22 +66,26 @@ public class NormalizedIconLoader extends IconLoader {
@Override
protected Drawable createBadgedDrawable(Drawable drawable, int userId) {
- return new FastBitmapDrawable(getBitmapInfo(drawable, userId));
+ return new FastBitmapDrawable(getBitmapInfo(drawable, userId, false));
}
- private synchronized BitmapInfo getBitmapInfo(Drawable drawable, int userId) {
+ private synchronized BitmapInfo getBitmapInfo(Drawable drawable, int userId,
+ boolean isInstantApp) {
if (mLauncherIcons == null) {
mLauncherIcons = LauncherIcons.obtain(mContext);
}
// User version code O, so that the icon is always wrapped in an adaptive icon container.
return mLauncherIcons.createBadgedIconBitmap(drawable, UserHandle.of(userId),
- Build.VERSION_CODES.O);
+ Build.VERSION_CODES.O, isInstantApp);
}
@Override
- protected Drawable getBadgedActivityIcon(ActivityInfo activityInfo, int userId) {
- return createBadgedDrawable(
- activityInfo.loadUnbadgedIcon(mContext.getPackageManager()), userId);
+ protected synchronized Drawable getBadgedActivityIcon(ActivityInfo activityInfo, int userId) {
+ BitmapInfo bitmapInfo = getBitmapInfo(
+ activityInfo.loadUnbadgedIcon(mContext.getPackageManager()),
+ userId,
+ activityInfo.applicationInfo.isInstantApp());
+ return mDrawableFactory.newIcon(bitmapInfo, activityInfo);
}
}