android.util.Xml.Encoding Java Examples
The following examples show how to use
android.util.Xml.Encoding.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SliceManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public byte[] getBackupPayload(int user) { if (Binder.getCallingUid() != SYSTEM_UID) { throw new SecurityException("Caller must be system"); } //TODO: http://b/22388012 if (user != UserHandle.USER_SYSTEM) { Slog.w(TAG, "getBackupPayload: cannot backup policy for user " + user); return null; } final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { XmlSerializer out = XmlPullParserFactory.newInstance().newSerializer(); out.setOutput(baos, Encoding.UTF_8.name()); mPermissions.writeBackup(out); out.flush(); return baos.toByteArray(); } catch (IOException | XmlPullParserException e) { Slog.w(TAG, "getBackupPayload: error writing payload for user " + user, e); } return null; }
Example #2
Source File: SliceManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void applyRestore(byte[] payload, int user) { if (Binder.getCallingUid() != SYSTEM_UID) { throw new SecurityException("Caller must be system"); } if (payload == null) { Slog.w(TAG, "applyRestore: no payload to restore for user " + user); return; } //TODO: http://b/22388012 if (user != UserHandle.USER_SYSTEM) { Slog.w(TAG, "applyRestore: cannot restore policy for user " + user); return; } final ByteArrayInputStream bais = new ByteArrayInputStream(payload); try { XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); parser.setInput(bais, Encoding.UTF_8.name()); mPermissions.readRestore(parser); } catch (NumberFormatException | XmlPullParserException | IOException e) { Slog.w(TAG, "applyRestore: error reading payload", e); } }
Example #3
Source File: SlicePermissionManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private ParserHolder getParser(String fileName) throws FileNotFoundException, XmlPullParserException { AtomicFile file = getFile(fileName); ParserHolder holder = new ParserHolder(); holder.input = file.openRead(); holder.parser = XmlPullParserFactory.newInstance().newPullParser(); holder.parser.setInput(holder.input, Encoding.UTF_8.name()); return holder; }
Example #4
Source File: CourseHandoutFragment.java From edx-app-android with Apache License 2.0 | 5 votes |
private void populateHandouts(HandoutModel handout) { hideErrorMessage(); StringBuilder buff = WebViewUtil.getIntialWebviewBuffer(getActivity(), logger); buff.append("<body>"); buff.append("<div class=\"header\">"); buff.append(handout.handouts_html); buff.append("</div>"); buff.append("</body>"); webView.loadDataWithBaseURL(environment.getConfig().getApiHostURL(), buff.toString(), "text/html", Encoding.UTF_8.toString(), null); }