summaryrefslogtreecommitdiffstats
path: root/src-ambient/com/android/phone/common/ambient/utils/PluginUtils.java
blob: 471457bdc288afeacdb32156c8fbaca031b0ab12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.android.phone.common.ambient.utils;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.util.Log;

/**
 * Utilites for Plugins
 */
public class PluginUtils {

    private static final String TAG = PluginUtils.class.getSimpleName();

    public static Resources getPluginResources(Context context, ComponentName componentName) {
        PackageManager packageManager = context.getPackageManager();
        try {
            return packageManager.getResourcesForApplication(componentName.getPackageName());
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Plugin isn't installed: " + componentName.flattenToShortString());
            return null;
        }
    }

}