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);
}
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);
}
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();
}
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;
}
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);
}
Aggregations