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

Commit 893d93d2 authored by Jake Hamby's avatar Jake Hamby
Browse files

Implement CMAS service category program results.

Correctly handle CDMA Service Category Program Data requests,
and send the SCPT response to the message center. Parcel SCPD
operations as an ArrayList instead of an array (current version
will throw ClassCastException when the array is cast).

Bug: 6853691
Change-Id: I949ea68891c78306059248832e59a593ab606e11
parent aa9e2c0b
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -81,8 +81,8 @@ public class CdmaSmsCbProgramData implements Parcelable {
    /** Service category to modify. */
    private final int mCategory;

    /** Language used for service category name (ISO 639 two character code). */
    private final String mLanguage;
    /** Language used for service category name (defined in BearerData.LANGUAGE_*). */
    private final int mLanguage;

    /** Maximum number of messages to store for this service category. */
    private final int mMaxMessages;
@@ -94,7 +94,7 @@ public class CdmaSmsCbProgramData implements Parcelable {
    private final String mCategoryName;

    /** Create a new CdmaSmsCbProgramData object with the specified values. */
    public CdmaSmsCbProgramData(int operation, int category, String language, int maxMessages,
    public CdmaSmsCbProgramData(int operation, int category, int language, int maxMessages,
            int alertOption, String categoryName) {
        mOperation = operation;
        mCategory = category;
@@ -108,7 +108,7 @@ public class CdmaSmsCbProgramData implements Parcelable {
    CdmaSmsCbProgramData(Parcel in) {
        mOperation = in.readInt();
        mCategory = in.readInt();
        mLanguage = in.readString();
        mLanguage = in.readInt();
        mMaxMessages = in.readInt();
        mAlertOption = in.readInt();
        mCategoryName = in.readString();
@@ -124,7 +124,7 @@ public class CdmaSmsCbProgramData implements Parcelable {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mOperation);
        dest.writeInt(mCategory);
        dest.writeString(mLanguage);
        dest.writeInt(mLanguage);
        dest.writeInt(mMaxMessages);
        dest.writeInt(mAlertOption);
        dest.writeString(mCategoryName);
@@ -147,10 +147,10 @@ public class CdmaSmsCbProgramData implements Parcelable {
    }

    /**
     * Returns the ISO-639-1 language code for the service category name, or null if not present.
     * @return a two-digit ISO-639-1 language code, e.g. "en" for English
     * Returns the CDMA language code for this service category.
     * @return one of the language values defined in BearerData.LANGUAGE_*
     */
    public String getLanguageCode() {
    public int getLanguage() {
        return mLanguage;
    }

@@ -171,7 +171,7 @@ public class CdmaSmsCbProgramData implements Parcelable {
    }

    /**
     * Returns the service category name, in the language specified by {@link #getLanguageCode()}.
     * Returns the service category name, in the language specified by {@link #getLanguage()}.
     * @return an optional service category name
     */
    public String getCategoryName() {
+144 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.cdma;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * CDMA Service Category Program Results from SCPT teleservice SMS.
 *
 * {@hide}
 */
public class CdmaSmsCbProgramResults implements Parcelable {

    /** Program result: success. */
    public static final int RESULT_SUCCESS                  = 0;

    /** Program result: memory limit exceeded. */
    public static final int RESULT_MEMORY_LIMIT_EXCEEDED    = 1;

    /** Program result: limit exceeded. */
    public static final int RESULT_CATEGORY_LIMIT_EXCEEDED  = 2;

    /** Program result: category already opted in. */
    public static final int RESULT_CATEGORY_ALREADY_ADDED   = 3;

    /** Program result: category already opted in. */
    public static final int RESULT_CATEGORY_ALREADY_DELETED = 4;

    /** Program result: invalid MAX_MESSAGES. */
    public static final int RESULT_INVALID_MAX_MESSAGES     = 5;

    /** Program result: invalid ALERT_OPTION. */
    public static final int RESULT_INVALID_ALERT_OPTION     = 6;

    /** Program result: invalid service category name. */
    public static final int RESULT_INVALID_CATEGORY_NAME    = 7;

    /** Program result: unspecified programming failure. */
    public static final int RESULT_UNSPECIFIED_FAILURE      = 8;

    /** Service category to modify. */
    private final int mCategory;

    /** Language used for service category name (defined in BearerData.LANGUAGE_*). */
    private final int mLanguage;

    /** Result of service category programming for this category. */
    private final int mCategoryResult;

    /** Create a new CdmaSmsCbProgramResults object with the specified values. */
    public CdmaSmsCbProgramResults(int category, int language, int categoryResult) {
        mCategory = category;
        mLanguage = language;
        mCategoryResult = categoryResult;
    }

    /** Create a new CdmaSmsCbProgramResults object from a Parcel. */
    CdmaSmsCbProgramResults(Parcel in) {
        mCategory = in.readInt();
        mLanguage = in.readInt();
        mCategoryResult = in.readInt();
    }

    /**
     * Flatten this object into a Parcel.
     *
     * @param dest  The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written (ignored).
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mCategory);
        dest.writeInt(mLanguage);
        dest.writeInt(mCategoryResult);
    }

    /**
     * Returns the CDMA service category to modify.
     * @return a 16-bit CDMA service category value
     */
    public int getCategory() {
        return mCategory;
    }

    /**
     * Returns the CDMA language code for this service category.
     * @return one of the language values defined in BearerData.LANGUAGE_*
     */
    public int getLanguage() {
        return mLanguage;
    }

    /**
     * Returns the result of service programming for this category
     * @return the result of service programming for this category
     */
    public int getCategoryResult() {
        return mCategoryResult;
    }

    @Override
    public String toString() {
        return "CdmaSmsCbProgramResults{category=" + mCategory
                + ", language=" + mLanguage + ", result=" + mCategoryResult + '}';
    }

    /**
     * Describe the kinds of special objects contained in the marshalled representation.
     * @return a bitmask indicating this Parcelable contains no special objects
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /** Creator for unparcelling objects. */
    public static final Parcelable.Creator<CdmaSmsCbProgramResults>
            CREATOR = new Parcelable.Creator<CdmaSmsCbProgramResults>() {
        @Override
        public CdmaSmsCbProgramResults createFromParcel(Parcel in) {
            return new CdmaSmsCbProgramResults(in);
        }

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