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

Commit 660be00f authored by Guojing Yuan's avatar Guojing Yuan Committed by Android (Google) Code Review
Browse files

Merge "[CDM] Remove userId from SystemDataTransferRequest xml" into main

parents c0258974 200476e6
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ import java.util.concurrent.TimeoutException;
 *   <request
 *     association_id="1"
 *     data_type="1"
 *     user_id="12"
 *     is_user_consented="true"
 *   </request>
 * </requests>
@@ -86,7 +85,6 @@ public class SystemDataTransferRequestStore {

    private static final String XML_ATTR_ASSOCIATION_ID = "association_id";
    private static final String XML_ATTR_DATA_TYPE = "data_type";
    private static final String XML_ATTR_USER_ID = "user_id";
    private static final String XML_ATTR_IS_USER_CONSENTED = "is_user_consented";

    private static final int READ_FROM_DISK_TIMEOUT = 5; // in seconds
@@ -226,7 +224,7 @@ public class SystemDataTransferRequestStore {
                final TypedXmlPullParser parser = Xml.resolvePullParser(in);
                XmlUtils.beginDocument(parser, XML_TAG_REQUESTS);

                return readRequestsFromXml(parser);
                return readRequestsFromXml(userId, parser);
            } catch (XmlPullParserException | IOException e) {
                Slog.e(LOG_TAG, "Error while reading requests file", e);
                return new ArrayList<>();
@@ -235,7 +233,7 @@ public class SystemDataTransferRequestStore {
    }

    @NonNull
    private ArrayList<SystemDataTransferRequest> readRequestsFromXml(
    private ArrayList<SystemDataTransferRequest> readRequestsFromXml(int userId,
            @NonNull TypedXmlPullParser parser) throws XmlPullParserException, IOException {
        if (!isStartOfTag(parser, XML_TAG_REQUESTS)) {
            throw new XmlPullParserException("The XML doesn't have start tag: " + XML_TAG_REQUESTS);
@@ -249,14 +247,15 @@ public class SystemDataTransferRequestStore {
                break;
            }
            if (isStartOfTag(parser, XML_TAG_REQUEST)) {
                requests.add(readRequestFromXml(parser));
                requests.add(readRequestFromXml(userId, parser));
            }
        }

        return requests;
    }

    private SystemDataTransferRequest readRequestFromXml(@NonNull TypedXmlPullParser parser)
    private SystemDataTransferRequest readRequestFromXml(int userId,
            @NonNull TypedXmlPullParser parser)
            throws XmlPullParserException, IOException {
        if (!isStartOfTag(parser, XML_TAG_REQUEST)) {
            throw new XmlPullParserException("XML doesn't have start tag: " + XML_TAG_REQUEST);
@@ -264,7 +263,6 @@ public class SystemDataTransferRequestStore {

        final int associationId = readIntAttribute(parser, XML_ATTR_ASSOCIATION_ID);
        final int dataType = readIntAttribute(parser, XML_ATTR_DATA_TYPE);
        final int userId = readIntAttribute(parser, XML_ATTR_USER_ID);
        final boolean isUserConsented = readBooleanAttribute(parser, XML_ATTR_IS_USER_CONSENTED);

        switch (dataType) {
@@ -321,7 +319,6 @@ public class SystemDataTransferRequestStore {

        writeIntAttribute(serializer, XML_ATTR_ASSOCIATION_ID, request.getAssociationId());
        writeIntAttribute(serializer, XML_ATTR_DATA_TYPE, request.getDataType());
        writeIntAttribute(serializer, XML_ATTR_USER_ID, request.getUserId());
        writeBooleanAttribute(serializer, XML_ATTR_IS_USER_CONSENTED, request.isUserConsented());

        serializer.endTag(null, XML_TAG_REQUEST);