Fix incorrect icon greying on pre-N system

The flag we check for package suspension is reused by a hidden constant
prior to N, so the flag should only be checked on N or later system.

Bug: 28390176
Change-Id: Ia28f62991cc2cd1b5d2cc27a5f11f7edca0ba02b
(cherry picked from commit 3ee9080fb4)
This commit is contained in:
Rubin Xu
2016-04-27 20:33:53 +01:00
committed by Sunny Goyal
parent c5784155bf
commit da3de6ddfe
@@ -19,6 +19,8 @@ package com.android.launcher3.util;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import com.android.launcher3.Utilities;
/**
* Utility methods using package manager
*/
@@ -57,6 +59,13 @@ public class PackageManagerHelper {
}
public static boolean isAppSuspended(ApplicationInfo info) {
return (info.flags & FLAG_SUSPENDED) != 0;
// 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
// or later.
if (Utilities.isNycOrAbove()) {
return (info.flags & FLAG_SUSPENDED) != 0;
} else {
return false;
}
}
}