1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.telephony;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * CellIdentity is to represent ONE unique cell in the world
24 * it contains all levels of info to identity country, carrier, etc.
25 *
26 * @hide pending API review
27 */
28public abstract class CellIdentity implements Parcelable {
29
30    // Cell is a GSM Cell {@link GsmCellIdentity}
31    public static final int CELLID_TYPE_GSM = 1;
32    // Cell is a CMDA Cell {@link CdmaCellIdentity}
33    public static final int CELLID_TYPE_CDMA = 2;
34    // Cell is a LTE Cell {@link LteCellIdentity}
35    public static final int CELLID_TYPE_LTE = 3;
36
37    private int mCellIdType;
38    private String mCellIdAttributes;
39
40    protected CellIdentity(int type, String attr) {
41        this.mCellIdType = type;
42        this.mCellIdAttributes = new String(attr);
43    }
44
45    protected CellIdentity(Parcel in) {
46        this.mCellIdType = in.readInt();
47        this.mCellIdAttributes = new String(in.readString());
48    }
49
50    protected CellIdentity(CellIdentity cid) {
51        this.mCellIdType = cid.mCellIdType;
52        this.mCellIdAttributes = new String(cid.mCellIdAttributes);
53    }
54
55    /**
56     * @return Cell Identity type as one of CELLID_TYPE_XXXX
57     */
58    public int getCellIdType() {
59        return mCellIdType;
60    }
61
62
63    /**
64     * @return Cell identity attribute pairs
65     * Comma separated âkey=valueâ pairs.
66     *   key := must must an single alpha-numeric word
67     *   value := âquoted value stringâ
68     *
69     * Current list of keys and values:
70     *   type = fixed | mobile
71     */
72    public String getCellIdAttributes() {
73        return mCellIdAttributes;
74    }
75
76
77    /** Implement the Parcelable interface {@hide} */
78    @Override
79    public int describeContents() {
80        return 0;
81    }
82
83    /** Implement the Parcelable interface {@hide} */
84    @Override
85    public void writeToParcel(Parcel dest, int flags) {
86        dest.writeInt(mCellIdType);
87        dest.writeString(mCellIdAttributes);
88    }
89}
90