Search in sources :

Example 6 with END_DOCUMENT

use of org.xmlpull.v1.XmlPullParser.END_DOCUMENT in project android_frameworks_base by DirtyUnicorns.

the class PackageInstallerService method readSessionsLocked.

private void readSessionsLocked() {
    if (LOGD)
        Slog.v(TAG, "readSessionsLocked()");
    mSessions.clear();
    FileInputStream fis = null;
    try {
        fis = mSessionsFile.openRead();
        final XmlPullParser in = Xml.newPullParser();
        in.setInput(fis, StandardCharsets.UTF_8.name());
        int type;
        while ((type = in.next()) != END_DOCUMENT) {
            if (type == START_TAG) {
                final String tag = in.getName();
                if (TAG_SESSION.equals(tag)) {
                    final PackageInstallerSession session = readSessionLocked(in);
                    final long age = System.currentTimeMillis() - session.createdMillis;
                    final boolean valid;
                    if (age >= MAX_AGE_MILLIS) {
                        Slog.w(TAG, "Abandoning old session first created at " + session.createdMillis);
                        valid = false;
                    } else {
                        valid = true;
                    }
                    if (valid) {
                        mSessions.put(session.sessionId, session);
                    } else {
                        // Since this is early during boot we don't send
                        // any observer events about the session, but we
                        // keep details around for dumpsys.
                        mHistoricalSessions.put(session.sessionId, session);
                    }
                    mAllocatedSessions.put(session.sessionId, true);
                }
            }
        }
    } catch (FileNotFoundException e) {
    // Missing sessions are okay, probably first boot
    } catch (IOException | XmlPullParserException e) {
        Slog.wtf(TAG, "Failed reading install sessions", e);
    } finally {
        IoUtils.closeQuietly(fis);
    }
}
Also used : IPackageInstallerSession(android.content.pm.IPackageInstallerSession) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 7 with END_DOCUMENT

use of org.xmlpull.v1.XmlPullParser.END_DOCUMENT in project android_frameworks_base by AOSPA.

the class NotificationManagerService method readPolicyXml.

private void readPolicyXml(InputStream stream, boolean forRestore) throws XmlPullParserException, NumberFormatException, IOException {
    final XmlPullParser parser = Xml.newPullParser();
    parser.setInput(stream, StandardCharsets.UTF_8.name());
    while (parser.next() != END_DOCUMENT) {
        mZenModeHelper.readXml(parser, forRestore);
        mRankingHelper.readXml(parser, forRestore);
    }
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser)

Example 8 with END_DOCUMENT

use of org.xmlpull.v1.XmlPullParser.END_DOCUMENT in project android_frameworks_base by ResurrectionRemix.

the class MountService method readSettingsLocked.

private void readSettingsLocked() {
    mRecords.clear();
    mPrimaryStorageUuid = getDefaultPrimaryStorageUuid();
    mForceAdoptable = false;
    FileInputStream fis = null;
    try {
        fis = mSettingsFile.openRead();
        final XmlPullParser in = Xml.newPullParser();
        in.setInput(fis, StandardCharsets.UTF_8.name());
        int type;
        while ((type = in.next()) != END_DOCUMENT) {
            if (type == START_TAG) {
                final String tag = in.getName();
                if (TAG_VOLUMES.equals(tag)) {
                    final int version = readIntAttribute(in, ATTR_VERSION, VERSION_INIT);
                    final boolean primaryPhysical = SystemProperties.getBoolean(StorageManager.PROP_PRIMARY_PHYSICAL, false);
                    final boolean validAttr = (version >= VERSION_FIX_PRIMARY) || (version >= VERSION_ADD_PRIMARY && !primaryPhysical);
                    if (validAttr) {
                        mPrimaryStorageUuid = readStringAttribute(in, ATTR_PRIMARY_STORAGE_UUID);
                    }
                    mForceAdoptable = readBooleanAttribute(in, ATTR_FORCE_ADOPTABLE, false);
                } else if (TAG_VOLUME.equals(tag)) {
                    final VolumeRecord rec = readVolumeRecord(in);
                    mRecords.put(rec.fsUuid, rec);
                }
            }
        }
    } catch (FileNotFoundException e) {
    // Missing metadata is okay, probably first boot
    } catch (IOException e) {
        Slog.wtf(TAG, "Failed reading metadata", e);
    } catch (XmlPullParserException e) {
        Slog.wtf(TAG, "Failed reading metadata", e);
    } finally {
        IoUtils.closeQuietly(fis);
    }
}
Also used : VolumeRecord(android.os.storage.VolumeRecord) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 9 with END_DOCUMENT

use of org.xmlpull.v1.XmlPullParser.END_DOCUMENT in project android_frameworks_base by ResurrectionRemix.

the class PackageInstallerService method readSessionsLocked.

private void readSessionsLocked() {
    if (LOGD)
        Slog.v(TAG, "readSessionsLocked()");
    mSessions.clear();
    FileInputStream fis = null;
    try {
        fis = mSessionsFile.openRead();
        final XmlPullParser in = Xml.newPullParser();
        in.setInput(fis, StandardCharsets.UTF_8.name());
        int type;
        while ((type = in.next()) != END_DOCUMENT) {
            if (type == START_TAG) {
                final String tag = in.getName();
                if (TAG_SESSION.equals(tag)) {
                    final PackageInstallerSession session = readSessionLocked(in);
                    final long age = System.currentTimeMillis() - session.createdMillis;
                    final boolean valid;
                    if (age >= MAX_AGE_MILLIS) {
                        Slog.w(TAG, "Abandoning old session first created at " + session.createdMillis);
                        valid = false;
                    } else {
                        valid = true;
                    }
                    if (valid) {
                        mSessions.put(session.sessionId, session);
                    } else {
                        // Since this is early during boot we don't send
                        // any observer events about the session, but we
                        // keep details around for dumpsys.
                        mHistoricalSessions.put(session.sessionId, session);
                    }
                    mAllocatedSessions.put(session.sessionId, true);
                }
            }
        }
    } catch (FileNotFoundException e) {
    // Missing sessions are okay, probably first boot
    } catch (IOException | XmlPullParserException e) {
        Slog.wtf(TAG, "Failed reading install sessions", e);
    } finally {
        IoUtils.closeQuietly(fis);
    }
}
Also used : IPackageInstallerSession(android.content.pm.IPackageInstallerSession) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 10 with END_DOCUMENT

use of org.xmlpull.v1.XmlPullParser.END_DOCUMENT in project android_frameworks_base by crdroidandroid.

the class PackageInstallerService method readSessionsLocked.

private void readSessionsLocked() {
    if (LOGD)
        Slog.v(TAG, "readSessionsLocked()");
    mSessions.clear();
    FileInputStream fis = null;
    try {
        fis = mSessionsFile.openRead();
        final XmlPullParser in = Xml.newPullParser();
        in.setInput(fis, StandardCharsets.UTF_8.name());
        int type;
        while ((type = in.next()) != END_DOCUMENT) {
            if (type == START_TAG) {
                final String tag = in.getName();
                if (TAG_SESSION.equals(tag)) {
                    final PackageInstallerSession session = readSessionLocked(in);
                    final long age = System.currentTimeMillis() - session.createdMillis;
                    final boolean valid;
                    if (age >= MAX_AGE_MILLIS) {
                        Slog.w(TAG, "Abandoning old session first created at " + session.createdMillis);
                        valid = false;
                    } else {
                        valid = true;
                    }
                    if (valid) {
                        mSessions.put(session.sessionId, session);
                    } else {
                        // Since this is early during boot we don't send
                        // any observer events about the session, but we
                        // keep details around for dumpsys.
                        mHistoricalSessions.put(session.sessionId, session);
                    }
                    mAllocatedSessions.put(session.sessionId, true);
                }
            }
        }
    } catch (FileNotFoundException e) {
    // Missing sessions are okay, probably first boot
    } catch (IOException | XmlPullParserException e) {
        Slog.wtf(TAG, "Failed reading install sessions", e);
    } finally {
        IoUtils.closeQuietly(fis);
    }
}
Also used : IPackageInstallerSession(android.content.pm.IPackageInstallerSession) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Aggregations

XmlPullParser (org.xmlpull.v1.XmlPullParser)26 IOException (java.io.IOException)21 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)21 FileInputStream (java.io.FileInputStream)19 FileNotFoundException (java.io.FileNotFoundException)19 NetworkPolicy (android.net.NetworkPolicy)6 NetworkTemplate (android.net.NetworkTemplate)6 IPackageInstallerSession (android.content.pm.IPackageInstallerSession)5 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)5 VolumeRecord (android.os.storage.VolumeRecord)5 RemoteException (android.os.RemoteException)3 ProviderInfo (android.content.pm.ProviderInfo)2 Point (android.graphics.Point)2 Uri (android.net.Uri)2 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 TextView (android.widget.TextView)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1