Search in sources :

Example 46 with NotFoundException

use of android.content.res.Resources.NotFoundException in project platform_frameworks_base by android.

the class WallpaperInfo method loadAuthor.

/**
     * Return a string indicating the author(s) of this wallpaper.
     */
public CharSequence loadAuthor(PackageManager pm) throws NotFoundException {
    if (mAuthorResource <= 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, mAuthorResource, applicationInfo);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException)

Example 47 with NotFoundException

use of android.content.res.Resources.NotFoundException in project platform_frameworks_base by android.

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 48 with NotFoundException

use of android.content.res.Resources.NotFoundException in project platform_frameworks_base by android.

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 49 with NotFoundException

use of android.content.res.Resources.NotFoundException in project platform_frameworks_base by android.

the class WallpaperManager method openDefaultWallpaper.

/**
     * Open stream representing the default static image wallpaper.
     *
     * If the device defines no default wallpaper of the requested kind,
     * {@code null} is returned.
     *
     * @hide
     */
public static InputStream openDefaultWallpaper(Context context, @SetWallpaperFlags int which) {
    final String whichProp;
    final int defaultResId;
    if (which == FLAG_LOCK) {
        /* Factory-default lock wallpapers are not yet supported
            whichProp = PROP_LOCK_WALLPAPER;
            defaultResId = com.android.internal.R.drawable.default_lock_wallpaper;
            */
        return null;
    } else {
        whichProp = PROP_WALLPAPER;
        defaultResId = com.android.internal.R.drawable.default_wallpaper;
    }
    final String path = SystemProperties.get(whichProp);
    if (!TextUtils.isEmpty(path)) {
        final File file = new File(path);
        if (file.exists()) {
            try {
                return new FileInputStream(file);
            } catch (IOException e) {
            // Ignored, fall back to platform default below
            }
        }
    }
    try {
        return context.getResources().openRawResource(defaultResId);
    } catch (NotFoundException e) {
    // no default defined for this device; this is not a failure
    }
    return null;
}
Also used : NotFoundException(android.content.res.Resources.NotFoundException) IOException(java.io.IOException) File(java.io.File) Paint(android.graphics.Paint) FileInputStream(java.io.FileInputStream)

Example 50 with NotFoundException

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

the class PackageManagerTests method getInstallablePackage.

Uri getInstallablePackage(int fileResId, File outFile) {
    Resources res = mContext.getResources();
    InputStream is = null;
    try {
        is = res.openRawResource(fileResId);
    } catch (NotFoundException e) {
        failStr("Failed to load resource with id: " + fileResId);
    }
    FileUtils.setPermissions(outFile.getPath(), FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IRWXO, -1, -1);
    assertTrue(FileUtils.copyToFile(is, outFile));
    FileUtils.setPermissions(outFile.getPath(), FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IRWXO, -1, -1);
    return Uri.fromFile(outFile);
}
Also used : InputStream(java.io.InputStream) SettingNotFoundException(android.provider.Settings.SettingNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Resources(android.content.res.Resources)

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