summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/Launcher.java3
-rw-r--r--src/com/android/launcher3/LauncherModel.java7
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompat.java2
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompatVL.java7
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompatVO.java6
-rw-r--r--src/com/android/launcher3/folder/Folder.java4
-rw-r--r--src/com/android/launcher3/notification/NotificationListener.java22
-rw-r--r--src/com/android/launcher3/popup/PopupDataProvider.java6
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutManager.java3
-rw-r--r--src/com/android/launcher3/util/PackageManagerHelper.java18
10 files changed, 61 insertions, 17 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 14b9c8290..624ea4a54 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3209,6 +3209,9 @@ public class Launcher extends BaseActivity
if (LauncherAppState.PROFILE_STARTUP) {
Trace.beginSection("Starting page bind");
}
+
+ AbstractFloatingView.closeAllOpenViews(this);
+
setWorkspaceLoading(true);
// Clear the workspace because it's going to be rebound
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 34d576d27..5fd50818d 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -26,7 +26,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.LauncherActivityInfo;
-import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Handler;
import android.os.HandlerThread;
@@ -85,7 +84,6 @@ import com.android.launcher3.util.ViewOnDrawExecutor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -1034,6 +1032,11 @@ public class LauncherModel extends BroadcastReceiver
info = new ShortcutInfo(pinnedShortcut, context);
info.iconBitmap = LauncherIcons
.createShortcutIcon(pinnedShortcut, context);
+ if (pmHelper.isAppSuspended(
+ info.getTargetComponent().getPackageName(),
+ info.user)) {
+ info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
+ }
intent = info.intent;
} else {
// Create a shortcut info in disabled mode for now.
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java
index b9142ed16..44a3686ed 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompat.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java
@@ -19,6 +19,7 @@ package com.android.launcher3.compat;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.graphics.Rect;
import android.os.Bundle;
@@ -72,6 +73,7 @@ public abstract class LauncherAppsCompat {
UserHandle user);
public abstract void startActivityForProfile(ComponentName component, UserHandle user,
Rect sourceBounds, Bundle opts);
+ public abstract ApplicationInfo getApplicationInfo(String packageName, UserHandle user);
public abstract void showAppDetailsForProfile(ComponentName component, UserHandle user);
public abstract void addOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
public abstract void removeOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
index 3cb721ccc..776f59360 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
@@ -19,6 +19,7 @@ package com.android.launcher3.compat;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
@@ -65,6 +66,12 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
}
@Override
+ public ApplicationInfo getApplicationInfo(String packageName, UserHandle user) {
+ List<LauncherActivityInfo> activityList = mLauncherApps.getActivityList(packageName, user);
+ return activityList.size() > 0 ? activityList.get(0).getApplicationInfo() : null;
+ }
+
+ @Override
public void showAppDetailsForProfile(ComponentName component, UserHandle user) {
mLauncherApps.startAppDetailsActivity(component, user, null, null);
}
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVO.java b/src/com/android/launcher3/compat/LauncherAppsCompatVO.java
index 0610726a7..377907aa9 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatVO.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatVO.java
@@ -17,6 +17,7 @@
package com.android.launcher3.compat;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.os.UserHandle;
@@ -34,6 +35,11 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {
}
@Override
+ public ApplicationInfo getApplicationInfo(String packageName, UserHandle user) {
+ return mLauncherApps.getApplicationInfo(packageName, 0, user);
+ }
+
+ @Override
public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList() {
List<ShortcutConfigActivityInfo> result = new ArrayList<>();
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 3d28f2291..4ad13d0ce 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -535,7 +535,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
}
mIsOpen = true;
- mFolderIcon.growAndFadeOut();
mContent.completePendingPageChanges();
if (!mDragInProgress) {
@@ -552,6 +551,8 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
prepareReveal();
centerAboutIcon();
+ mFolderIcon.growAndFadeOut();
+
AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
int height = getFolderHeight();
@@ -1088,6 +1089,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
int folderPivotY = height / 2 + (centeredTop - top);
setPivotX(folderPivotX);
setPivotY(folderPivotY);
+
mFolderIconPivotX = (int) (mFolderIcon.getMeasuredWidth() *
(1.0f * folderPivotX / width));
mFolderIconPivotY = (int) (mFolderIcon.getMeasuredHeight() *
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java
index 5c16176f5..a627d238e 100644
--- a/src/com/android/launcher3/notification/NotificationListener.java
+++ b/src/com/android/launcher3/notification/NotificationListener.java
@@ -40,7 +40,7 @@ import java.util.Set;
* A {@link NotificationListenerService} that sends updates to its
* {@link NotificationsChangedListener} when notifications are posted or canceled,
* as well and when this service first connects. An instance of NotificationListener,
- * and its methods for getting notifications, can be obtained via {@link #getInstance()}.
+ * and its methods for getting notifications, can be obtained via {@link #getInstanceIfConnected()}.
*/
public class NotificationListener extends NotificationListenerService {
@@ -50,6 +50,7 @@ public class NotificationListener extends NotificationListenerService {
private static NotificationListener sNotificationListenerInstance = null;
private static NotificationsChangedListener sNotificationsChangedListener;
+ private static boolean sIsConnected;
private final Handler mWorkerHandler;
private final Handler mUiHandler;
@@ -65,8 +66,9 @@ public class NotificationListener extends NotificationListenerService {
mUiHandler.obtainMessage(message.what, message.obj).sendToTarget();
break;
case MSG_NOTIFICATION_FULL_REFRESH:
- final List<StatusBarNotification> activeNotifications
- = filterNotifications(getActiveNotifications());
+ final List<StatusBarNotification> activeNotifications = sIsConnected
+ ? filterNotifications(getActiveNotifications())
+ : new ArrayList<StatusBarNotification>();
mUiHandler.obtainMessage(message.what, activeNotifications).sendToTarget();
break;
}
@@ -107,10 +109,11 @@ public class NotificationListener extends NotificationListenerService {
super();
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper(), mWorkerCallback);
mUiHandler = new Handler(Looper.getMainLooper(), mUiCallback);
+ sNotificationListenerInstance = this;
}
- public static @Nullable NotificationListener getInstance() {
- return sNotificationListenerInstance;
+ public static @Nullable NotificationListener getInstanceIfConnected() {
+ return sIsConnected ? sNotificationListenerInstance : null;
}
public static void setNotificationsChangedListener(NotificationsChangedListener listener) {
@@ -119,9 +122,8 @@ public class NotificationListener extends NotificationListenerService {
}
sNotificationsChangedListener = listener;
- NotificationListener notificationListener = getInstance();
- if (notificationListener != null) {
- notificationListener.onNotificationFullRefresh();
+ if (sNotificationListenerInstance != null) {
+ sNotificationListenerInstance.onNotificationFullRefresh();
}
}
@@ -132,7 +134,7 @@ public class NotificationListener extends NotificationListenerService {
@Override
public void onListenerConnected() {
super.onListenerConnected();
- sNotificationListenerInstance = this;
+ sIsConnected = true;
onNotificationFullRefresh();
}
@@ -143,7 +145,7 @@ public class NotificationListener extends NotificationListenerService {
@Override
public void onListenerDisconnected() {
super.onListenerDisconnected();
- sNotificationListenerInstance = null;
+ sIsConnected = false;
}
@Override
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index e314b646b..ee2930f19 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -172,7 +172,7 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
private boolean updateBadgeIcon(BadgeInfo badgeInfo) {
boolean hadNotificationToShow = badgeInfo.hasNotificationToShow();
NotificationInfo notificationInfo = null;
- NotificationListener notificationListener = NotificationListener.getInstance();
+ NotificationListener notificationListener = NotificationListener.getInstanceIfConnected();
if (notificationListener != null && badgeInfo.getNotificationKeys().size() == 1) {
StatusBarNotification[] activeNotifications = notificationListener
.getActiveNotifications(new String[] {badgeInfo.getNotificationKeys().get(0)});
@@ -222,13 +222,13 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
/** This makes a potentially expensive binder call and should be run on a background thread. */
public List<StatusBarNotification> getStatusBarNotificationsForKeys(String[] notificationKeys) {
- NotificationListener notificationListener = NotificationListener.getInstance();
+ NotificationListener notificationListener = NotificationListener.getInstanceIfConnected();
return notificationListener == null ? Collections.EMPTY_LIST
: notificationListener.getNotificationsForKeys(notificationKeys);
}
public void cancelNotification(String notificationKey) {
- NotificationListener notificationListener = NotificationListener.getInstance();
+ NotificationListener notificationListener = NotificationListener.getInstanceIfConnected();
if (notificationListener == null) {
return;
}
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
index 941391362..df7f6954d 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
@@ -65,7 +65,8 @@ public class DeepShortcutManager {
}
public static boolean supportsShortcuts(ItemInfo info) {
- return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
+ return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
+ && !info.isDisabled();
}
public boolean wasLastCallSuccess() {
diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java
index e89fc0ca0..bfa932b6d 100644
--- a/src/com/android/launcher3/util/PackageManagerHelper.java
+++ b/src/com/android/launcher3/util/PackageManagerHelper.java
@@ -71,6 +71,10 @@ public class PackageManagerHelper {
}
}
+ /**
+ * Returns whether a package is suspended for the current user as per
+ * {@link android.app.admin.DevicePolicyManager#isPackageSuspended}.
+ */
public boolean isAppSuspended(String packageName) {
try {
ApplicationInfo info = mPm.getApplicationInfo(packageName, 0);
@@ -80,6 +84,16 @@ public class PackageManagerHelper {
}
}
+ /**
+ * Returns whether the target app is suspended for a given user as per
+ * {@link android.app.admin.DevicePolicyManager#isPackageSuspended}.
+ */
+ public boolean isAppSuspended(String packageName, UserHandle user) {
+ ApplicationInfo info =
+ LauncherAppsCompat.getInstance(mContext).getApplicationInfo(packageName, user);
+ return info != null && isAppSuspended(info);
+ }
+
public boolean isSafeMode() {
return mPm.isSafeMode();
}
@@ -91,6 +105,10 @@ public class PackageManagerHelper {
AppInfo.makeLaunchIntent(mContext, activities.get(0), user);
}
+ /**
+ * Returns whether an application is suspended as per
+ * {@link android.app.admin.DevicePolicyManager#isPackageSuspended}.
+ */
public static boolean isAppSuspended(ApplicationInfo info) {
// The value of FLAG_SUSPENDED was reused by a hidden constant
// ApplicationInfo.FLAG_PRIVILEGED prior to N, so only check for suspended flag on N