use of android.content.res.Resources.NotFoundException in project android_frameworks_base by ParanoidAndroid.
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 android_frameworks_base by ParanoidAndroid.
the class BrowserFrame method shouldInterceptRequest.
// Called by jni from the chrome network stack.
private WebResourceResponse shouldInterceptRequest(String url) {
InputStream androidResource = inputStreamForAndroidResource(url);
if (androidResource != null) {
return new WebResourceResponse(null, null, androidResource);
}
// android_res URL, as we allow those even if file access is disabled.
if (!mSettings.getAllowFileAccess() && url.startsWith("file://")) {
return new WebResourceResponse(null, null, null);
}
WebResourceResponse response = mCallbackProxy.shouldInterceptRequest(url);
if (response == null && "browser:incognito".equals(url)) {
try {
Resources res = mContext.getResources();
InputStream ins = res.openRawResource(com.android.internal.R.raw.incognito_mode_start_page);
response = new WebResourceResponse("text/html", "utf8", ins);
} catch (NotFoundException ex) {
// This shouldn't happen, but try and gracefully handle it jic
Log.w(LOGTAG, "Failed opening raw.incognito_mode_start_page", ex);
}
}
return response;
}
use of android.content.res.Resources.NotFoundException in project android_frameworks_base by ParanoidAndroid.
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);
}
use of android.content.res.Resources.NotFoundException in project android_frameworks_base by ParanoidAndroid.
the class Ringtone method playFallbackRingtone.
private boolean playFallbackRingtone() {
if (mAudioManager.getStreamVolume(mStreamType) != 0) {
int ringtoneType = RingtoneManager.getDefaultType(mUri);
if (ringtoneType != -1 && RingtoneManager.getActualDefaultRingtoneUri(mContext, ringtoneType) != null) {
// Default ringtone, try fallback ringtone.
try {
AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(com.android.internal.R.raw.fallbackring);
if (afd != null) {
mLocalPlayer = new MediaPlayer();
if (afd.getDeclaredLength() < 0) {
mLocalPlayer.setDataSource(afd.getFileDescriptor());
} else {
mLocalPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
}
mLocalPlayer.setAudioStreamType(mStreamType);
mLocalPlayer.prepare();
mLocalPlayer.start();
afd.close();
return true;
} else {
Log.e(TAG, "Could not load fallback ringtone");
}
} catch (IOException ioe) {
destroyLocalPlayer();
Log.e(TAG, "Failed to open fallback ringtone");
} catch (NotFoundException nfe) {
Log.e(TAG, "Fallback ringtone does not exist");
}
}
}
return false;
}
use of android.content.res.Resources.NotFoundException in project platform_frameworks_base by android.
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);
}
Aggregations