summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/compat
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-04-06 16:18:20 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-04-07 11:38:10 -0700
commitd09c37052ef9a70d4dde53ece6619f04de5f97cb (patch)
tree2d5f9f6901d32a8424ab1a4014b72b1dec545494 /src/com/android/launcher3/compat
parentb8b070c2dfb27d9ba168c45dd5503e89035a1139 (diff)
downloadandroid_packages_apps_Trebuchet-d09c37052ef9a70d4dde53ece6619f04de5f97cb.tar.gz
android_packages_apps_Trebuchet-d09c37052ef9a70d4dde53ece6619f04de5f97cb.tar.bz2
android_packages_apps_Trebuchet-d09c37052ef9a70d4dde53ece6619f04de5f97cb.zip
Removing dependency on getApplicationInfo method added in N
This method is goiing away. We don't need this method anyway since LauncherActivityInfo already has the information Change-Id: Ic6afa1df14958b894925d730e01a2e2d2a6fb98c
Diffstat (limited to 'src/com/android/launcher3/compat')
-rw-r--r--src/com/android/launcher3/compat/LauncherActivityInfoCompat.java2
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompat.java16
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompatV16.java4
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompatVN.java57
4 files changed, 3 insertions, 76 deletions
diff --git a/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java b/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java
index aaf756eda..0bc9588aa 100644
--- a/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java
+++ b/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java
@@ -24,8 +24,6 @@ import android.graphics.drawable.Drawable;
public abstract class LauncherActivityInfoCompat {
- public static final int FLAG_SUSPENDED = 1<<30;
-
LauncherActivityInfoCompat() {
}
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java
index bc900bcb5..237a9e9fb 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompat.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java
@@ -19,9 +19,6 @@ 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.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Rect;
import android.os.Bundle;
@@ -59,9 +56,7 @@ public abstract class LauncherAppsCompat {
public static LauncherAppsCompat getInstance(Context context) {
synchronized (sInstanceLock) {
if (sInstance == null) {
- if (Utilities.isNycOrAbove()) {
- sInstance = new LauncherAppsCompatVN(context.getApplicationContext());
- } else if (Utilities.ATLEAST_LOLLIPOP) {
+ if (Utilities.ATLEAST_LOLLIPOP) {
sInstance = new LauncherAppsCompatVL(context.getApplicationContext());
} else {
sInstance = new LauncherAppsCompatV16(context.getApplicationContext());
@@ -84,13 +79,4 @@ public abstract class LauncherAppsCompat {
public abstract boolean isActivityEnabledForProfile(ComponentName component,
UserHandleCompat user);
public abstract boolean isPackageSuspendedForProfile(String packageName, UserHandleCompat user);
-
- public boolean isAppEnabled(PackageManager pm, String packageName, int flags) {
- try {
- ApplicationInfo info = pm.getApplicationInfo(packageName, flags);
- return info != null && info.enabled;
- } catch (NameNotFoundException e) {
- return false;
- }
- }
}
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
index 2d0778d30..4e2fc055e 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
@@ -27,11 +27,11 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
import android.net.Uri;
-import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import com.android.launcher3.Utilities;
+import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
@@ -114,7 +114,7 @@ public class LauncherAppsCompatV16 extends LauncherAppsCompat {
}
public boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user) {
- return isAppEnabled(mPm, packageName, 0);
+ return PackageManagerHelper.isAppEnabled(mPm, packageName);
}
public boolean isActivityEnabledForProfile(ComponentName component, UserHandleCompat user) {
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVN.java b/src/com/android/launcher3/compat/LauncherAppsCompatVN.java
deleted file mode 100644
index 0d883b6fd..000000000
--- a/src/com/android/launcher3/compat/LauncherAppsCompatVN.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2016 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.launcher3.compat;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.LauncherApps;
-import android.os.UserHandle;
-import android.util.Log;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-//TODO: Once gogole3 SDK is updated to N, add @TargetApi(Build.VERSION_CODES.N)
-public class LauncherAppsCompatVN extends LauncherAppsCompatVL {
-
- private static final String TAG = "LauncherAppsCompatVN";
-
- LauncherAppsCompatVN(Context context) {
- super(context);
- }
-
- @Override
- public boolean isPackageSuspendedForProfile(String packageName, UserHandleCompat user) {
- if (user != null && packageName != null) {
- try {
- //TODO: Replace with proper API call once google3 SDK is updated.
- Method getApplicationInfoMethod = LauncherApps.class.getMethod("getApplicationInfo",
- String.class, int.class, UserHandle.class);
-
- ApplicationInfo info = (ApplicationInfo) getApplicationInfoMethod.invoke(
- mLauncherApps, packageName, 0, user.getUser());
- if (info != null) {
- return (info.flags & LauncherActivityInfoCompat.FLAG_SUSPENDED) != 0;
- }
- } catch (NoSuchMethodError | NoSuchMethodException | IllegalAccessException
- | IllegalArgumentException | InvocationTargetException e) {
- Log.e(TAG, "Running on N without getApplicationInfo", e);
- }
- }
- return false;
- }
-}