LiveDisplayManager: Perform null check in getConfig()

* LiveDisplayConfig isn't instanced until boot completed, thus if
   LiveDisplayManager is instanced earlier, null is always returned.

Change-Id: I003886ffced86a5a82dec25a4cc7b542da0f2331
This commit is contained in:
dianlujitao
2019-08-07 14:51:40 +08:00
committed by Michael Bestas
parent 36a87acd92
commit 62885acaca

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod Project
* 2018 The LineageOS Project
* 2018-2019 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.
@@ -139,7 +139,7 @@ public class LiveDisplayManager {
private static final String TAG = "LiveDisplay";
private final Context mContext;
private final LiveDisplayConfig mConfig;
private LiveDisplayConfig mConfig;
private static LiveDisplayManager sInstance;
private static ILiveDisplayService sService;
@@ -162,15 +162,6 @@ public class LiveDisplayManager {
" crashed, was not started, or the interface has been called to early in" +
" SystemServer init");
}
try {
mConfig = sService.getConfig();
if (mConfig == null) {
Log.w(TAG, "Unable to get LiveDisplay configuration!");
}
} catch (RemoteException e) {
throw new RuntimeException("Unable to fetch LiveDisplay configuration!", e);
}
}
/**
@@ -215,7 +206,14 @@ public class LiveDisplayManager {
* @return the configuration
*/
public LiveDisplayConfig getConfig() {
return mConfig;
try {
if (mConfig == null) {
mConfig = checkService() ? sService.getConfig() : null;
}
return mConfig;
} catch (RemoteException e) {
return null;
}
}
/**