use of android.content.res.Resources.NotFoundException in project android_frameworks_base by DirtyUnicorns.
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);
}
use of android.content.res.Resources.NotFoundException in project android_frameworks_base by DirtyUnicorns.
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 android_frameworks_base by DirtyUnicorns.
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 XobotOS by xamarin.
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);
}
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 AOSPA.
the class InputManagerService method getKeyboardLayoutOverlay.
// Native callback.
private String[] getKeyboardLayoutOverlay(InputDeviceIdentifier identifier) {
if (!mSystemReady) {
return null;
}
String keyboardLayoutDescriptor = getCurrentKeyboardLayoutForInputDevice(identifier);
if (keyboardLayoutDescriptor == null) {
return null;
}
final String[] result = new String[2];
visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() {
@Override
public void visitKeyboardLayout(Resources resources, int keyboardLayoutResId, KeyboardLayout layout) {
try {
result[0] = layout.getDescriptor();
result[1] = Streams.readFully(new InputStreamReader(resources.openRawResource(keyboardLayoutResId)));
} catch (IOException ex) {
} catch (NotFoundException ex) {
}
}
});
if (result[0] == null) {
Slog.w(TAG, "Could not get keyboard layout with descriptor '" + keyboardLayoutDescriptor + "'.");
return null;
}
return result;
}
Aggregations