diff options
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 3bef5986d..05336f2e7 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -24,15 +24,9 @@ import android.app.ActivityManager; import android.app.Person; import android.app.WallpaperManager; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.Context; -import android.content.Intent; import android.content.SharedPreferences; -import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.content.res.Resources; @@ -47,7 +41,6 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.InsetDrawable; import android.os.Build; -import android.os.Bundle; import android.os.DeadObjectException; import android.os.Handler; import android.os.Message; @@ -60,7 +53,6 @@ import android.text.TextUtils; import android.text.style.TtsSpan; import android.util.DisplayMetrics; import android.util.Log; -import android.util.Pair; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; @@ -69,7 +61,6 @@ import android.view.animation.Interpolator; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.ShortcutConfigActivityInfo; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.FolderAdaptiveIcon; import com.android.launcher3.graphics.RotationMode; import com.android.launcher3.graphics.TintedDrawableSpan; @@ -81,13 +72,10 @@ import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.views.Transposable; import com.android.launcher3.widget.PendingAddShortcutInfo; -import java.io.Closeable; -import java.io.IOException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.Locale; -import java.util.StringTokenizer; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -247,7 +235,6 @@ public final class Utilities { return scale; } - /** * Inverse of {@link #getDescendantCoordRelativeToAncestor(View, View, float[], boolean)}. */ @@ -383,53 +370,6 @@ public final class Utilities { return min + (value * (max - min)); } - public static boolean isSystemApp(Context context, Intent intent) { - PackageManager pm = context.getPackageManager(); - ComponentName cn = intent.getComponent(); - String packageName = null; - if (cn == null) { - ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); - if ((info != null) && (info.activityInfo != null)) { - packageName = info.activityInfo.packageName; - } - } else { - packageName = cn.getPackageName(); - } - if (packageName != null) { - try { - PackageInfo info = pm.getPackageInfo(packageName, 0); - return (info != null) && (info.applicationInfo != null) && - ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); - } catch (NameNotFoundException e) { - return false; - } - } else { - return false; - } - } - - /* - * Finds a system apk which had a broadcast receiver listening to a particular action. - * @param action intent action used to find the apk - * @return a pair of apk package name and the resources. - */ - static Pair<String, Resources> findSystemApk(String action, PackageManager pm) { - final Intent intent = new Intent(action); - for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) { - if (info.activityInfo != null && - (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { - final String packageName = info.activityInfo.packageName; - try { - final Resources res = pm.getResourcesForApplication(packageName); - return Pair.create(packageName, res); - } catch (NameNotFoundException e) { - Log.w(TAG, "Failed to find resources for " + packageName); - } - } - } - return null; - } - /** * Trims the string, removing all whitespace at the beginning and end of the string. * Non-breaking whitespaces are also removed. @@ -454,51 +394,10 @@ public final class Utilities { return (int) Math.ceil(fm.bottom - fm.top); } - /** - * Convenience println with multiple args. - */ - public static void println(String key, Object... args) { - StringBuilder b = new StringBuilder(); - b.append(key); - b.append(": "); - boolean isFirstArgument = true; - for (Object arg : args) { - if (isFirstArgument) { - isFirstArgument = false; - } else { - b.append(", "); - } - b.append(arg); - } - System.out.println(b.toString()); - } - public static boolean isRtl(Resources res) { return res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; } - /** - * Returns true if the intent is a valid launch intent for a launcher activity of an app. - * This is used to identify shortcuts which are different from the ones exposed by the - * applications' manifest file. - * - * @param launchIntent The intent that will be launched when the shortcut is clicked. - */ - public static boolean isLauncherAppTarget(Intent launchIntent) { - if (launchIntent != null - && Intent.ACTION_MAIN.equals(launchIntent.getAction()) - && launchIntent.getComponent() != null - && launchIntent.getCategories() != null - && launchIntent.getCategories().size() == 1 - && launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER) - && TextUtils.isEmpty(launchIntent.getDataString())) { - // An app target can either have no extra or have ItemInfo.EXTRA_PROFILE. - Bundle extras = launchIntent.getExtras(); - return extras == null || extras.keySet().isEmpty(); - } - return false; - } - public static float dpiFromPx(int size, DisplayMetrics metrics){ float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT; return (size / densityRatio); @@ -601,18 +500,6 @@ public final class Utilities { return context.getSystemService(WallpaperManager.class).isSetWallpaperAllowed(); } - public static void closeSilently(Closeable c) { - if (c != null) { - try { - c.close(); - } catch (IOException e) { - if (FeatureFlags.IS_DOGFOOD_BUILD) { - Log.d(TAG, "Error closing", e); - } - } - } - } - public static boolean isBinderSizeError(Exception e) { return e.getCause() instanceof TransactionTooLargeException || e.getCause() instanceof DeadObjectException; @@ -727,25 +614,6 @@ public final class Utilities { } } - public static int[] getIntArrayFromString(String tokenized) { - StringTokenizer tokenizer = new StringTokenizer(tokenized, ","); - int[] array = new int[tokenizer.countTokens()]; - int count = 0; - while (tokenizer.hasMoreTokens()) { - array[count] = Integer.parseInt(tokenizer.nextToken()); - count++; - } - return array; - } - - public static String getStringFromIntArray(int[] array) { - StringBuilder str = new StringBuilder(); - for (int value : array) { - str.append(value).append(","); - } - return str.toString(); - } - public static float squaredHypot(float x, float y) { return x * x + y * y; } |