Removing boot receiver.
> Registering the receiver at runtime, only when it is required
> Using system property sys.boot_completed to check if boot completion
> This prevents unnecessary process startup during system bootup
Change-Id: I68f99ecf2e1ffd2ca7b6d15a99a282451bf67aec
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 8fd298d..20c526b 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -58,6 +58,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Set;
@@ -709,4 +710,18 @@
public static String createDbSelectionQuery(String columnName, Iterable<?> values) {
return String.format(Locale.ENGLISH, "%s IN (%s)", columnName, TextUtils.join(", ", values));
}
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public static boolean isBootCompleted() {
+ 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);
+ } catch (Exception e) {
+ Log.d(TAG, "Unable to read system properties");
+ // Assume that boot has completed
+ return true;
+ }
+ }
}