Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56c4c442 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick Committed by Android Code Review
Browse files

Merge "Lazy initialization must be synchronized to avoid parallel instances cretation."

parents b98c8fca 17eb45ff
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -118,6 +118,8 @@ public class CatService extends Handler implements AppInterface {
    private static IccRecords mIccRecords;

    // Service members.
    // Protects singleton instance lazy initialization.
    private static final Object sInstanceLock = new Object();
    private static CatService sInstance;
    private CommandsInterface mCmdIf;
    private Context mContext;
@@ -515,6 +517,7 @@ public class CatService extends Handler implements AppInterface {
     */
    public static CatService getInstance(CommandsInterface ci, IccRecords ir,
            Context context, IccFileHandler fh, IccCard ic) {
        synchronized (sInstanceLock) {
            if (sInstance == null) {
                if (ci == null || ir == null || context == null || fh == null
                        || ic == null) {
@@ -536,6 +539,7 @@ public class CatService extends Handler implements AppInterface {
            }
            return sInstance;
        }
    }

    /**
     * Used by application to get an AppInterface object.