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
This commit is contained in:
1 parent
8239daded4
commit
25aba0aea5
5 files changed
+19
-26
No files matched your search
@@ -58,6 +58,7 @@ import android.widget.Toast;
|
||||
|
||||
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 final class Utilities {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user