summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/StreamSettings.java
blob: e9daa2b7c6ff2c44abccad1db55c4bafc5037042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

package android.app;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

import java.io.IOException;

/** @hide */
public class StreamSettings implements Parcelable{

    int streamId;

    int value;

    boolean override;
    
    /** @hide */
    public static final Parcelable.Creator<StreamSettings> CREATOR = new Parcelable.Creator<StreamSettings>() {
        public StreamSettings createFromParcel(Parcel in) {
            return new StreamSettings(in);
        }

        @Override
        public StreamSettings[] newArray(int size) {
            return new StreamSettings[size];
        }
    };


    public StreamSettings(Parcel parcel){
        readFromParcel(parcel);
    }

    public StreamSettings(int streamId) {
        this.streamId = streamId;
        this.value = 0;
        this.override = false;
    }

    public StreamSettings(int streamId, int value, boolean override) {
        this.streamId = streamId;
        this.value = value;
        this.override = override;
    }

    public int getStreamId() {
        return streamId;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public void setOverride(boolean override) {
        this.override = override;
    }

    public boolean isOverride() {
        return override;
    }

    /** @hide */
    public static StreamSettings fromXml(XmlPullParser xpp, Context context)
            throws XmlPullParserException, IOException {
        int event = xpp.next();
        StreamSettings streamDescriptor = new StreamSettings(0);
        while (event != XmlPullParser.END_TAG || !xpp.getName().equals("streamDescriptor")) {
            if (event == XmlPullParser.START_TAG) {
                String name = xpp.getName();
                if (name.equals("streamId")) {
                    streamDescriptor.streamId = Integer.parseInt(xpp.nextText());
                } else if (name.equals("value")) {
                    streamDescriptor.value = Integer.parseInt(xpp.nextText());
                } else if (name.equals("override")) {
                    streamDescriptor.override = Boolean.parseBoolean(xpp.nextText());
                }
            }
            event = xpp.next();
        }
        return streamDescriptor;
    }

    /** @hide */
    public void getXmlString(StringBuilder builder) {
        builder.append("<streamDescriptor>\n");
        builder.append("<streamId>" + streamId + "</streamId>\n");
        builder.append("<value>" + value + "</value>\n");
        builder.append("<override>" + override + "</override>\n");
        builder.append("</streamDescriptor>\n");
    }

    @Override
    public int describeContents() {
        return 0;
    }

    /** @hide */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(streamId);
        dest.writeValue(override);
        dest.writeInt(value);
    }

    /** @hide */
    public void readFromParcel(Parcel in) {
        streamId = in.readInt();
        override = (Boolean)in.readValue(null);
        value = in.readInt();
    }


}