Search in sources :

Example 66 with NotFoundException

use of android.content.res.Resources.NotFoundException in project android_frameworks_base by AOSPA.

the class WallpaperInfo method loadDescription.

/**
     * Return a brief summary of this wallpaper's behavior.
     */
public CharSequence loadDescription(PackageManager pm) throws NotFoundException {
    String packageName = mService.resolvePackageName;
    ApplicationInfo applicationInfo = null;
    if (packageName == null) {
        packageName = mService.serviceInfo.packageName;
        applicationInfo = mService.serviceInfo.applicationInfo;
    }
    if (mService.serviceInfo.descriptionRes != 0) {
        return pm.getText(packageName, mService.serviceInfo.descriptionRes, applicationInfo);
    }
    if (mDescriptionResource <= 0)
        throw new NotFoundException();
    return pm.getText(packageName, mDescriptionResource, mService.serviceInfo.applicationInfo);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException)

Example 67 with NotFoundException

use of android.content.res.Resources.NotFoundException in project android_frameworks_base by AOSPA.

the class WallpaperInfo method loadContextUri.

/**
     * Returns an URI that specifies a link for further context about this wallpaper.
     *
     * @param pm An instance of {@link PackageManager} to retrieve the URI.
     * @return The URI.
     */
public Uri loadContextUri(PackageManager pm) throws NotFoundException {
    if (mContextUriResource <= 0)
        throw new NotFoundException();
    String packageName = mService.resolvePackageName;
    ApplicationInfo applicationInfo = null;
    if (packageName == null) {
        packageName = mService.serviceInfo.packageName;
        applicationInfo = mService.serviceInfo.applicationInfo;
    }
    String contextUriString = pm.getText(packageName, mContextUriResource, applicationInfo).toString();
    if (contextUriString == null) {
        return null;
    }
    return Uri.parse(contextUriString);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException)

Example 68 with NotFoundException

use of android.content.res.Resources.NotFoundException in project android_frameworks_base by AOSPA.

the class WallpaperInfo method loadContextDescription.

/**
     * Retrieves a title of the URI that specifies a link for further context about this wallpaper.
     *
     * @param pm An instance of {@link PackageManager} to retrieve the title.
     * @return The title.
     */
public CharSequence loadContextDescription(PackageManager pm) throws NotFoundException {
    if (mContextDescriptionResource <= 0)
        throw new NotFoundException();
    String packageName = mService.resolvePackageName;
    ApplicationInfo applicationInfo = null;
    if (packageName == null) {
        packageName = mService.serviceInfo.packageName;
        applicationInfo = mService.serviceInfo.applicationInfo;
    }
    return pm.getText(packageName, mContextDescriptionResource, applicationInfo).toString();
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException)

Example 69 with NotFoundException

use of android.content.res.Resources.NotFoundException in project android_frameworks_base by AOSPA.

the class StorageManagerBaseTest method createObbFile.

/**
     * Creates an OBB file (with the given name), into the app's standard files directory
     *
     * @param name The name of the OBB file we want to create/write to
     * @param rawResId The raw resource ID of the OBB file in the package
     * @return A {@link File} representing the file to write to
     */
protected File createObbFile(String name, int rawResId) {
    File outFile = null;
    try {
        final File filesDir = mContext.getFilesDir();
        outFile = new File(filesDir, name);
        copyRawToFile(rawResId, outFile);
    } catch (NotFoundException e) {
        if (outFile != null) {
            outFile.delete();
        }
    }
    return outFile;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException) File(java.io.File)

Example 70 with NotFoundException

use of android.content.res.Resources.NotFoundException in project android_frameworks_base by AOSPA.

the class AnimatorInflater method loadAnimator.

/** @hide */
public static Animator loadAnimator(Resources resources, Theme theme, int id, float pathErrorScale) throws NotFoundException {
    final ConfigurationBoundResourceCache<Animator> animatorCache = resources.getAnimatorCache();
    Animator animator = animatorCache.getInstance(id, resources, theme);
    if (animator != null) {
        if (DBG_ANIMATOR_INFLATER) {
            Log.d(TAG, "loaded animator from cache, " + resources.getResourceName(id));
        }
        return animator;
    } else if (DBG_ANIMATOR_INFLATER) {
        Log.d(TAG, "cache miss for animator " + resources.getResourceName(id));
    }
    XmlResourceParser parser = null;
    try {
        parser = resources.getAnimation(id);
        animator = createAnimatorFromXml(resources, theme, parser, pathErrorScale);
        if (animator != null) {
            animator.appendChangingConfigurations(getChangingConfigs(resources, id));
            final ConstantState<Animator> constantState = animator.createConstantState();
            if (constantState != null) {
                if (DBG_ANIMATOR_INFLATER) {
                    Log.d(TAG, "caching animator for res " + resources.getResourceName(id));
                }
                animatorCache.put(id, theme, constantState);
                // create a new animator so that cached version is never used by the user
                animator = constantState.newInstance(resources, theme);
            }
        }
        return animator;
    } catch (XmlPullParserException ex) {
        Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id));
        rnf.initCause(ex);
        throw rnf;
    } catch (IOException ex) {
        Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(id));
        rnf.initCause(ex);
        throw rnf;
    } finally {
        if (parser != null)
            parser.close();
    }
}
Also used : NotFoundException(android.content.res.Resources.NotFoundException) XmlResourceParser(android.content.res.XmlResourceParser) NotFoundException(android.content.res.Resources.NotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) Resources(android.content.res.Resources) IOException(java.io.IOException)

Aggregations

NotFoundException (android.content.res.Resources.NotFoundException)165 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)49 Resources (android.content.res.Resources)47 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)45 FileNotFoundException (java.io.FileNotFoundException)34 IOException (java.io.IOException)34 ApplicationInfo (android.content.pm.ApplicationInfo)31 File (java.io.File)30 InputStream (java.io.InputStream)28 FileInputStream (java.io.FileInputStream)20 Drawable (android.graphics.drawable.Drawable)19 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)16 Nullable (android.annotation.Nullable)15 XmlResourceParser (android.content.res.XmlResourceParser)12 SettingNotFoundException (android.provider.Settings.SettingNotFoundException)12 ArrayResourceValue (com.android.ide.common.rendering.api.ArrayResourceValue)12 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)12 NonNull (android.annotation.NonNull)10 ColorDrawable (android.graphics.drawable.ColorDrawable)10 DensityBasedResourceValue (com.android.ide.common.rendering.api.DensityBasedResourceValue)8