use of java.io.FileNotFoundException in project platform_frameworks_base by android.
the class FontFamily_Delegate method setFontLocation.
public static synchronized void setFontLocation(String fontLocation) {
sFontLocation = fontLocation;
// init list of bundled fonts.
File allFonts = new File(fontLocation, FN_ALL_FONTS_LIST);
// Current number of fonts is 103. Use the next round number to leave scope for more fonts
// in the future.
Set<String> allFontsList = new HashSet<String>(128);
Scanner scanner = null;
try {
scanner = new Scanner(allFonts);
while (scanner.hasNext()) {
String name = scanner.next();
// Skip font configuration files.
if (!name.endsWith(".xml")) {
allFontsList.add(name);
}
}
} catch (FileNotFoundException e) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to load the list of fonts. Try re-installing the SDK Platform from the SDK Manager.", e, null);
} finally {
if (scanner != null) {
scanner.close();
}
}
SDK_FONTS = Collections.unmodifiableSet(allFontsList);
for (FontFamily_Delegate fontFamily : sPostInitDelegate) {
fontFamily.init();
}
sPostInitDelegate.clear();
}
use of java.io.FileNotFoundException in project platform_packages_apps_launcher by android.
the class Launcher method readConfiguration.
private static void readConfiguration(Context context, LocaleConfiguration configuration) {
DataInputStream in = null;
try {
in = new DataInputStream(context.openFileInput(PREFERENCES));
configuration.locale = in.readUTF();
configuration.mcc = in.readInt();
configuration.mnc = in.readInt();
} catch (FileNotFoundException e) {
// Ignore
} catch (IOException e) {
// Ignore
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
// Ignore
}
}
}
}
use of java.io.FileNotFoundException in project platform_packages_apps_launcher by android.
the class Launcher method writeConfiguration.
private static void writeConfiguration(Context context, LocaleConfiguration configuration) {
DataOutputStream out = null;
try {
out = new DataOutputStream(context.openFileOutput(PREFERENCES, MODE_PRIVATE));
out.writeUTF(configuration.locale);
out.writeInt(configuration.mcc);
out.writeInt(configuration.mnc);
out.flush();
} catch (FileNotFoundException e) {
// Ignore
} catch (IOException e) {
//noinspection ResultOfMethodCallIgnored
context.getFileStreamPath(PREFERENCES).delete();
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// Ignore
}
}
}
}
use of java.io.FileNotFoundException in project platform_frameworks_base by android.
the class ActivityManagerService method openContentUri.
public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException {
enforceNotIsolatedCaller("openContentUri");
final int userId = UserHandle.getCallingUserId();
String name = uri.getAuthority();
ContentProviderHolder cph = getContentProviderExternalUnchecked(name, null, userId);
ParcelFileDescriptor pfd = null;
if (cph != null) {
// We record the binder invoker's uid in thread-local storage before
// going to the content provider to open the file. Later, in the code
// that handles all permissions checks, we look for this uid and use
// that rather than the Activity Manager's own uid. The effect is that
// we do the check against the caller's permissions even though it looks
// to the content provider like the Activity Manager itself is making
// the request.
Binder token = new Binder();
sCallerIdentity.set(new Identity(token, Binder.getCallingPid(), Binder.getCallingUid()));
try {
pfd = cph.provider.openFile(null, uri, "r", null, token);
} catch (FileNotFoundException e) {
// do nothing; pfd will be returned null
} finally {
// Ensure that whatever happens, we clean up the identity state
sCallerIdentity.remove();
// Ensure we're done with the provider.
removeContentProviderExternalUnchecked(name, null, userId);
}
} else {
Slog.d(TAG, "Failed to get provider for authority '" + name + "'");
}
return pfd;
}
use of java.io.FileNotFoundException in project platform_frameworks_base by android.
the class PersistentDataStore method load.
private void load() {
clearState();
final InputStream is;
try {
is = mAtomicFile.openRead();
} catch (FileNotFoundException ex) {
return;
}
XmlPullParser parser;
try {
parser = Xml.newPullParser();
parser.setInput(new BufferedInputStream(is), StandardCharsets.UTF_8.name());
loadFromXml(parser);
} catch (IOException ex) {
Slog.w(InputManagerService.TAG, "Failed to load input manager persistent store data.", ex);
clearState();
} catch (XmlPullParserException ex) {
Slog.w(InputManagerService.TAG, "Failed to load input manager persistent store data.", ex);
clearState();
} finally {
IoUtils.closeQuietly(is);
}
}
Aggregations