use of android.content.res.Resources.NotFoundException in project android_frameworks_base by ParanoidAndroid.
the class InputManagerService method getKeyboardLayoutOverlay.
// Native callback.
private String[] getKeyboardLayoutOverlay(String inputDeviceDescriptor) {
if (!mSystemReady) {
return null;
}
String keyboardLayoutDescriptor = getCurrentKeyboardLayoutForInputDevice(inputDeviceDescriptor);
if (keyboardLayoutDescriptor == null) {
return null;
}
final String[] result = new String[2];
visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() {
@Override
public void visitKeyboardLayout(Resources resources, String descriptor, String label, String collection, int keyboardLayoutResId) {
try {
result[0] = descriptor;
result[1] = Streams.readFully(new InputStreamReader(resources.openRawResource(keyboardLayoutResId)));
} catch (IOException ex) {
} catch (NotFoundException ex) {
}
}
});
if (result[0] == null) {
Log.w(TAG, "Could not get keyboard layout with descriptor '" + keyboardLayoutDescriptor + "'.");
return null;
}
return result;
}
use of android.content.res.Resources.NotFoundException in project android_frameworks_base by ParanoidAndroid.
the class MountServiceTests method copyRawToFile.
private void copyRawToFile(int rawResId, File outFile) {
Resources res = mContext.getResources();
InputStream is = null;
try {
is = res.openRawResource(rawResId);
} catch (NotFoundException e) {
fail("Failed to load resource with id: " + rawResId);
}
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);
}
use of android.content.res.Resources.NotFoundException in project android_frameworks_base by ParanoidAndroid.
the class DeviceAdminInfo method loadDescription.
/**
* Load user-visible description associated with this device admin.
*
* @param pm Supply a PackageManager used to load the device admin's
* resources.
*/
public CharSequence loadDescription(PackageManager pm) throws NotFoundException {
if (mReceiver.activityInfo.descriptionRes != 0) {
String packageName = mReceiver.resolvePackageName;
ApplicationInfo applicationInfo = null;
if (packageName == null) {
packageName = mReceiver.activityInfo.packageName;
applicationInfo = mReceiver.activityInfo.applicationInfo;
}
return pm.getText(packageName, mReceiver.activityInfo.descriptionRes, applicationInfo);
}
throw new NotFoundException();
}
use of android.content.res.Resources.NotFoundException in project android_frameworks_base by ParanoidAndroid.
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 android_frameworks_base by ParanoidAndroid.
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;
}
Aggregations