TrustInterfaceService: Init mNotificationManager in the constructor
Ensure that the variable is not null when removeNotificationForFeatureInternal(int) is called so to avoid the NPE: E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.NotificationManager.cancel(int)' on a null object reference This fixes LineageParts crashing when disabling Trust notifications. Change-Id: Ia0fa793378116101821a7bd424e0859869db48f5
This commit is contained in:
@@ -69,6 +69,7 @@ public class TrustInterfaceService extends LineageSystemService {
|
||||
public TrustInterfaceService(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mNotificationManager = context.getSystemService(NotificationManager.class);
|
||||
if (context.getPackageManager().hasSystemFeature(LineageContextConstants.Features.TRUST)) {
|
||||
publishBinderService(LineageContextConstants.LINEAGE_TRUST_INTERFACE, mService);
|
||||
} else {
|
||||
@@ -84,8 +85,6 @@ public class TrustInterfaceService extends LineageSystemService {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mNotificationManager = mContext.getSystemService(NotificationManager.class);
|
||||
|
||||
try {
|
||||
mUsbRestrictor = IUsbRestrict.getService();
|
||||
} catch (NoSuchElementException | RemoteException e) {
|
||||
|
||||
Reference in New Issue
Block a user