diff options
author | LuK1337 <priv.luk@gmail.com> | 2018-08-25 20:11:18 +0200 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2018-08-25 20:58:11 +0200 |
commit | dee32583568b2b9fbd085fd4479d5e62ece72c47 (patch) | |
tree | f627a8554c07cecfdb7f5198b03d7c3a7644171b /sdk/src | |
parent | 3cc3d4d2ade405db7a079ce0926243eca3f423ba (diff) | |
download | lineage-sdk-dee32583568b2b9fbd085fd4479d5e62ece72c47.tar.gz lineage-sdk-dee32583568b2b9fbd085fd4479d5e62ece72c47.tar.bz2 lineage-sdk-dee32583568b2b9fbd085fd4479d5e62ece72c47.zip |
LineageNotificationLights: Don't create KeyguardManager in constructor
* Apparently creating it so early can cause serious breakages
that make StorageManagerService and UsbDeviceManager end up
getting null pointer when trying to get KeyguardManager with
ctx.getSystemService(KeyguardManager.class).
* Moving ctx.getSystemService(KeyguardManager.class) out of
constructor to isKeyguardLocked() solves these issues.
* Also move to getSystemService(Class<T>) while at it.
Change-Id: Ib3f65ba2e726149089ab1fb12030321e0ecdeab1
Diffstat (limited to 'sdk/src')
-rw-r--r-- | sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java b/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java index 73377543..75a325fb 100644 --- a/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java +++ b/sdk/src/java/org/lineageos/internal/notification/LineageNotificationLights.java @@ -1,6 +1,6 @@ /** * Copyright (C) 2015 The CyanogenMod Project - * Copyright (C) 2017 The LineageOS Project + * Copyright (C) 2017-2018 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,9 +77,6 @@ public final class LineageNotificationLights { private int mZenMode; - // For checking lockscreen status - private KeyguardManager mKeyguardManager; - private final SettingsObserver mSettingsObserver; private final Context mContext; @@ -122,9 +119,6 @@ public final class LineageNotificationLights { mPackageNameMappings.put(map[0], map[1]); } - mKeyguardManager = - (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); - mSettingsObserver = new SettingsObserver(new Handler()); mSettingsObserver.observe(); } @@ -138,7 +132,8 @@ public final class LineageNotificationLights { // when lights should / should not be cleared. // TODO: put this somewhere else public boolean isKeyguardLocked() { - return mKeyguardManager != null && mKeyguardManager.isKeyguardLocked(); + KeyguardManager keyguardManager = mContext.getSystemService(KeyguardManager.class); + return keyguardManager != null && keyguardManager.isKeyguardLocked(); } private void parseNotificationPulseCustomValuesString(String customLedValuesString) { |