Search in sources :

Example 1 with NotFoundException

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;
}
Also used : InputStreamReader(java.io.InputStreamReader) SettingNotFoundException(android.provider.Settings.SettingNotFoundException) FileNotFoundException(java.io.FileNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Resources(android.content.res.Resources) IOException(java.io.IOException)

Example 2 with NotFoundException

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);
}
Also used : InputStream(java.io.InputStream) NotFoundException(android.content.res.Resources.NotFoundException) Resources(android.content.res.Resources)

Example 3 with NotFoundException

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();
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException)

Example 4 with 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);
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException)

Example 5 with NotFoundException

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;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException) File(java.io.File)

Aggregations

NotFoundException (android.content.res.Resources.NotFoundException)166 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)50 Resources (android.content.res.Resources)48 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 Drawable (android.graphics.drawable.Drawable)20 FileInputStream (java.io.FileInputStream)20 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