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

Commit 7153c266 authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

Introduce ApiHelper

Test: build
Change-Id: I649ebb4203c4e1b066641301146830068df70007
parent f755f276
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -28,14 +28,11 @@ import com.android.widget.MediaController2Impl;
import com.android.widget.VideoView2Impl;

public class ApiFactory implements StaticProvider {
    private final Context mContext;

    public ApiFactory(Context context) {
        mContext = context;
    }

    public static Object initialize(Context context) throws ReflectiveOperationException {
        return new ApiFactory(context);
    public static Object initialize(Context appContext, Context libContext)
            throws ReflectiveOperationException {
        ApiHelper.initialize(appContext, libContext);
        return new ApiFactory();
    }

    @Override
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.media.update;

import android.content.Context;
import android.content.res.Resources;

public class ApiHelper {
    private static ApiHelper sInstance;
    private final Context mAppContext;
    private final Resources mLibResources;
    private final Resources.Theme mLibTheme;

    public static ApiHelper getInstance() {
        return sInstance;
    }

    static void initialize(Context appContext, Context libContext) {
        if (sInstance == null) {
            sInstance = new ApiHelper(appContext, libContext);
        }
    }

    private ApiHelper(Context appContext, Context libContext) {
        mAppContext = appContext;
        mLibResources = libContext.getResources();
        mLibTheme = libContext.getTheme();
    }

    public Resources getLibResources() {
        return mLibResources;
    }

    public Resources.Theme getLibTheme() {
        return mLibTheme;
    }
}