Merge "Lazy initialization must be synchronized to avoid parallel instances cretation."
This commit is contained in:
@@ -118,6 +118,8 @@ public class CatService extends Handler implements AppInterface {
|
|||||||
private static IccRecords mIccRecords;
|
private static IccRecords mIccRecords;
|
||||||
|
|
||||||
// Service members.
|
// Service members.
|
||||||
|
// Protects singleton instance lazy initialization.
|
||||||
|
private static final Object sInstanceLock = new Object();
|
||||||
private static CatService sInstance;
|
private static CatService sInstance;
|
||||||
private CommandsInterface mCmdIf;
|
private CommandsInterface mCmdIf;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -515,6 +517,7 @@ public class CatService extends Handler implements AppInterface {
|
|||||||
*/
|
*/
|
||||||
public static CatService getInstance(CommandsInterface ci, IccRecords ir,
|
public static CatService getInstance(CommandsInterface ci, IccRecords ir,
|
||||||
Context context, IccFileHandler fh, IccCard ic) {
|
Context context, IccFileHandler fh, IccCard ic) {
|
||||||
|
synchronized (sInstanceLock) {
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
if (ci == null || ir == null || context == null || fh == null
|
if (ci == null || ir == null || context == null || fh == null
|
||||||
|| ic == null) {
|
|| ic == null) {
|
||||||
@@ -536,6 +539,7 @@ public class CatService extends Handler implements AppInterface {
|
|||||||
}
|
}
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by application to get an AppInterface object.
|
* Used by application to get an AppInterface object.
|
||||||
|
|||||||
Reference in New Issue
Block a user