From dfc8b6685bf330b203cb16b67c39bed936030306 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 30 Aug 2016 12:05:48 -0700 Subject: [PATCH] Preventing unnecessary setLayout calls in workspace Separating getSystemProperty in a separate method Change-Id: I88716e796e29ac27ef25afa41077a8f29eb65f25 --- src/com/android/launcher3/Utilities.java | 13 +++++++++---- src/com/android/launcher3/Workspace.java | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 2988fb912e..9079837b99 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -776,16 +776,21 @@ public final class Utilities { } public static boolean isBootCompleted() { + return "1".equals(getSystemProperty("sys.boot_completed", "1")); + } + + public static String getSystemProperty(String property, String defaultValue) { try { Class clazz = Class.forName("android.os.SystemProperties"); Method getter = clazz.getDeclaredMethod("get", String.class); - String value = (String) getter.invoke(null, "sys.boot_completed"); - return "1".equals(value); + String value = (String) getter.invoke(null, property); + if (!TextUtils.isEmpty(value)) { + return value; + } } catch (Exception e) { Log.d(TAG, "Unable to read system properties"); - // Assume that boot has completed - return true; } + return defaultValue; } /** diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 4c2d4bb928..88eeac677b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -624,8 +624,8 @@ public class Workspace extends PagedView ViewGroup.LayoutParams lp = qsbContainer.getLayoutParams(); if (cellHeight > 0 && lp.height != cellHeight) { lp.height = cellHeight; + qsbContainer.setLayoutParams(lp); } - qsbContainer.setLayoutParams(lp); } }