Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ca78d61 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Catch IOException when failed to parse new fields."

parents dca59bf4 746b82aa
Loading
Loading
Loading
Loading
+27 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.usage.UsageEvents;
import android.app.usage.UsageStats;
import android.content.res.Configuration;
import android.util.ArrayMap;
import android.util.Log;

import com.android.internal.util.XmlUtils;

@@ -89,11 +90,23 @@ final class UsageStatsXmlV1 {
        // Apply the offset to the beginTime to find the absolute time.
        stats.mLastTimeUsed = statsOut.beginTime + XmlUtils.readLongAttribute(
                parser, LAST_TIME_ACTIVE_ATTR);

        try {
            stats.mLastTimeForegroundServiceUsed = statsOut.beginTime + XmlUtils.readLongAttribute(
                    parser, LAST_TIME_SERVICE_USED_ATTR);
        } catch (IOException e) {
            Log.e(TAG, "Failed to parse mLastTimeForegroundServiceUsed", e);
        }

        stats.mTotalTimeInForeground = XmlUtils.readLongAttribute(parser, TOTAL_TIME_ACTIVE_ATTR);

        try {
            stats.mTotalTimeForegroundServiceUsed = XmlUtils.readLongAttribute(parser,
                TOTAL_TIME_SERVICE_USED_ATTR);
        } catch (IOException e) {
            Log.e(TAG, "Failed to parse mTotalTimeForegroundServiceUsed", e);
        }

        stats.mLastEvent = XmlUtils.readIntAttribute(parser, LAST_EVENT_ATTR);
        stats.mAppLaunchCount = XmlUtils.readIntAttribute(parser, APP_LAUNCH_COUNT_ATTR,
                0);
@@ -350,8 +363,17 @@ final class UsageStatsXmlV1 {
        }

        statsOut.endTime = statsOut.beginTime + XmlUtils.readLongAttribute(parser, END_TIME_ATTR);
        try {
            statsOut.majorVersion = XmlUtils.readIntAttribute(parser, MAJOR_VERSION_ATTR);
        } catch (IOException e) {
            Log.e(TAG, "Failed to parse majorVersion", e);
        }

        try {
            statsOut.minorVersion = XmlUtils.readIntAttribute(parser, MINOR_VERSION_ATTR);
        } catch (IOException e) {
            Log.e(TAG, "Failed to parse minorVersion", e);
        }

        int eventCode;
        int outerDepth = parser.getDepth();