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

Commit 038b5c11 authored by Shri Borde's avatar Shri Borde
Browse files

MessagingConfigurationManager and SmsManager api changes

Bug 17243357: MessagingConfigurationManager is replaced with
SmsManager.getCarrierConfigValues

Remove the newly added SmsManager APIs taking a subId parameter. We now
create SmsManagers per requested subId.

Change-Id: Ifa95802b6f723c4986197a2b7d6fcbc43f4e0792
parent 5340687b
Loading
Loading
Loading
Loading
+0 −259
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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;

import com.android.internal.telephony.IMms;

import android.os.RemoteException;
import android.os.ServiceManager;

/**
 * This class manages messaging (SMS or MMS) related, carrier-dependent configurations.
 * Some of the values are used by the system in processing SMS or MMS messages. Others
 * are provided for the convenience of SMS applications.
 *
 * All the configurations are loaded with pre-defined values at system startup. Developers
 * can override the value of a specific configuration at runtime by passing the values through
 * corresponding MMS sending or download methods. The overridden values are only effective
 * for the specific sending or downloading request.
 */
public class MessagingConfigurationManager {
    /** Singleton object constructed during class initialization. */
    private static final MessagingConfigurationManager sInstance =
            new MessagingConfigurationManager();

    private MessagingConfigurationManager() {}

    public static MessagingConfigurationManager getDefault() {
        return sInstance;
    }

    /**
     * Get carrier-dependent messaging configuration value as a boolean
     *
     * @param name the name of the configuration value
     * @param defaultValue the default value to return if fail to find the value
     * @return the value of the configuration
     */
    public boolean getCarrierConfigBoolean(String name, boolean defaultValue) {
        return getCarrierConfigBoolean(SmsManager.getPreferredSmsSubscription(), name,
                defaultValue);
    }

    /**
     * Get carrier-dependent messaging configuration value as a boolean
     *
     * @param subId the SIM id
     * @param name the name of the configuration value
     * @param defaultValue the default value to return if fail to find the value
     * @return the value of the configuration
     */
    public boolean getCarrierConfigBoolean(long subId, String name, boolean defaultValue) {
        try {
            IMms iMms = IMms.Stub.asInterface(ServiceManager.getService("imms"));
            if (iMms != null) {
                return iMms.getCarrierConfigBoolean(subId, name, defaultValue);
            }
        } catch (RemoteException ex) {
            // ignore it
        }
        return defaultValue;
    }

    /**
     * Get carrier-dependent messaging configuration value as an int
     *
     * @param name the name of the configuration value
     * @param defaultValue the default value to return if fail to find the value
     * @return the value of the configuration
     */
    public int getCarrierConfigInt(String name, int defaultValue) {
        return getCarrierConfigInt(SmsManager.getPreferredSmsSubscription(), name, defaultValue);
    }

    /**
     * Get carrier-dependent messaging configuration value as an int
     *
     * @param subId the SIM id
     * @param name the name of the configuration value
     * @param defaultValue the default value to return if fail to find the value
     * @return the value of the configuration
     */
    public int getCarrierConfigInt(long subId, String name, int defaultValue) {
        try {
            IMms iMms = IMms.Stub.asInterface(ServiceManager.getService("imms"));
            if (iMms != null) {
                return iMms.getCarrierConfigInt(subId, name, defaultValue);
            }
        } catch (RemoteException ex) {
            // ignore it
        }
        return defaultValue;
    }

    /**
     * Get carrier-dependent messaging configuration value as a string
     *
     * @param name the name of the configuration value
     * @param defaultValue the default value to return if fail to find the value
     * @return the value of the configuration
     */
    public String getCarrierConfigString(String name, String defaultValue) {
        return getCarrierConfigString(SmsManager.getPreferredSmsSubscription(), name, defaultValue);
    }

    /**
     * Get carrier-dependent messaging configuration value as a string
     *
     * @param subId the SIM id
     * @param name the name of the configuration value
     * @param defaultValue the default value to return if fail to find the value
     * @return the value of the configuration
     */
    public String getCarrierConfigString(long subId, String name, String defaultValue) {
        try {
            IMms iMms = IMms.Stub.asInterface(ServiceManager.getService("imms"));
            if (iMms != null) {
                return iMms.getCarrierConfigString(subId, name, defaultValue);
            }
        } catch (RemoteException ex) {
            // ignore it
        }
        return defaultValue;
    }

    /**
     * Whether to append transaction id to MMS WAP Push M-Notification.ind's content location URI
     * when constructing the download URL of a new MMS (boolean type)
     */
    public static final String CONF_APPEND_TRANSACTION_ID = "enabledTransID";
    /**
     * Whether MMS is enabled for the current carrier (boolean type)
     */
    public static final String CONF_MMS_ENABLED = "enabledMMS";
    /**
     * If this is enabled, M-NotifyResp.ind should be sent to the WAP Push content location
     * instead of the default MMSC (boolean type)
     */
    public static final String CONF_NOTIFY_WAP_MMSC_ENABLED = "enabledNotifyWapMMSC";
    /**
     * Whether alias is enabled (boolean type)
     */
    public static final String CONF_ALIAS_ENABLED = "aliasEnabled";
    /**
     * Whether audio is allowed to be attached for MMS messages (boolean type)
     */
    public static final String CONF_ALLOW_ATTACH_AUDIO = "allowAttachAudio";
    /**
     * Whether multipart SMS is enabled (boolean type)
     */
    public static final String CONF_MULTIPART_SMS_ENABLED = "enableMultipartSMS";
    /**
     * Whether SMS delivery report is enabled (boolean type)
     */
    public static final String CONF_SMS_DELIVERY_REPORT_ENABLED = "enableSMSDeliveryReports";
    /**
     * Whether content-disposition field should be expected in an MMS PDU (boolean type)
     */
    public static final String CONF_SUPPORT_MMS_CONTENT_DISPOSITION =
            "supportMmsContentDisposition";
    /**
     * Whether multipart SMS should be sent as separate messages
     */
    public static final String CONF_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES =
            "sendMultipartSmsAsSeparateMessages";
    /**
     * Whether MMS read report is enabled (boolean type)
     */
    public static final String CONF_MMS_READ_REPORT_ENABLED = "enableMMSReadReports";
    /**
     * Whether MMS delivery report is enabled (boolean type)
     */
    public static final String CONF_MMS_DELIVERY_REPORT_ENABLED = "enableMMSDeliveryReports";
    /**
     * Max MMS message size in bytes (int type)
     */
    public static final String CONF_MAX_MESSAGE_SIZE = "maxMessageSize";
    /**
     * Max MMS image width (int type)
     */
    public static final String CONF_MAX_IMAGE_WIDTH = "maxImageWidth";
    /**
     * Max MMS image height (int type)
     */
    public static final String CONF_MAX_IMAGE_HEIGHT = "maxImageHeight";
    /**
     * Limit of recipients of MMS messages (int type)
     */
    public static final String CONF_RECIPIENT_LIMIT = "recipientLimit";
    /**
     * Min alias character count (int type)
     */
    public static final String CONF_ALIAS_MIN_CHARS = "aliasMinChars";
    /**
     * Max alias character count (int type)
     */
    public static final String CONF_ALIAS_MAX_CHARS = "aliasMaxChars";
    /**
     * When the number of parts of a multipart SMS reaches this threshold, it should be
     * converted into an MMS (int type)
     */
    public static final String CONF_SMS_TO_MMS_TEXT_THRESHOLD = "smsToMmsTextThreshold";
    /**
     * Some carriers require SMS to be converted into MMS when text length reaches this threshold
     * (int type)
     */
    public static final String CONF_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD =
            "smsToMmsTextLengthThreshold";
    /**
     * Max message text size (int type)
     */
    public static final String CONF_MESSAGE_TEXT_MAX_SIZE = "maxMessageTextSize";
    /**
     * Max message subject length (int type)
     */
    public static final String CONF_SUBJECT_MAX_LENGTH = "maxSubjectLength";
    /**
     * MMS HTTP socket timeout in milliseconds (int type)
     */
    public static final String CONF_HTTP_SOCKET_TIMEOUT = "httpSocketTimeout";
    /**
     * The name of the UA Prof URL HTTP header for MMS HTTP request (String type)
     */
    public static final String CONF_UA_PROF_TAG_NAME = "uaProfTagName";
    /**
     * The User-Agent header value for MMS HTTP request (String type)
     */
    public static final String CONF_USER_AGENT = "userAgent";
    /**
     * The UA Profile URL header value for MMS HTTP request (String type)
     */
    public static final String CONF_UA_PROF_URL = "uaProfUrl";
    /**
     * A list of HTTP headers to add to MMS HTTP request, separated by "|" (String type)
     */
    public static final String CONF_HTTP_PARAMS = "httpParams";
    /**
     * Email gateway number (String type)
     */
    public static final String CONF_EMAIL_GATEWAY_NUMBER = "emailGatewayNumber";
    /**
     * The suffix to append to the NAI header value for MMS HTTP request (String type)
     */
    public static final String CONF_NAI_SUFFIX = "naiSuffix";

}
+209 −441

File changed.

Preview size limit exceeded, changes collapsed.

+5 −4
Original line number Diff line number Diff line
@@ -38,12 +38,12 @@ import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SqliteWrapper;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
import android.telephony.MessagingConfigurationManager;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.Rlog;
@@ -203,7 +203,7 @@ public class WapPushOverSms implements ServiceConnection {
                // FIXME (tomtaylor) - when we've updated SubscriptionManager, change
                // SubscriptionManager.DEFAULT_SUB_ID to SubscriptionManager.getDefaultSmsSubId()
                long subId = (subIds != null) && (subIds.length > 0) ? subIds[0] :
                    SmsManager.getDefault().getPreferredSmsSubscription();
                    SmsManager.getDefaultSmsSubId();
                writeInboxMessage(subId, intentData);
            }

@@ -347,8 +347,9 @@ public class WapPushOverSms implements ServiceConnection {
                case MESSAGE_TYPE_NOTIFICATION_IND: {
                    final NotificationInd nInd = (NotificationInd) pdu;

                    if (MessagingConfigurationManager.getDefault().getCarrierConfigBoolean(subId,
                            MessagingConfigurationManager.CONF_APPEND_TRANSACTION_ID, false)) {
                    Bundle configs = SmsManager.getSmsManagerForSubId(subId).getCarrierConfigValues();
                    if (configs != null && configs.getBoolean(
                        SmsManager.MMS_CONFIG_APPEND_TRANSACTION_ID, false)) {
                        final byte [] contentLocation = nInd.getContentLocation();
                        if ('=' == contentLocation[contentLocation.length - 1]) {
                            byte [] transactionId = nInd.getTransactionId();