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

Commit 916a4a24 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "SubscriptionController store SPN brdcst in carrier" into lmp-mr1-dev

parents 4a69b13a cd9e0d22
Loading
Loading
Loading
Loading
+52 −0
Original line number Original line Diff line number Diff line
@@ -16,10 +16,12 @@


package com.android.internal.telephony;
package com.android.internal.telephony;


import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.ContentValues;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
@@ -156,6 +158,32 @@ public class SubscriptionController extends ISub.Stub {
        }
        }
    };
    };


    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (DBG) logd("onReceive " + intent);
            // TODO: Have GsmServiceStateTracker insert this data directly and deprecate
            // this broadcast.
            int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                    SubscriptionManager.INVALID_SUBSCRIPTION_ID);
            if (intent.getAction().equals(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION)) {
                if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
                    String carrierText = intent.getStringExtra(TelephonyIntents.EXTRA_PLMN);
                    if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SPN, false)) {
                        // Need to show both plmn and spn.
                        String separator = mContext.getString(
                                com.android.internal.R.string.kg_text_message_separator).toString();
                        carrierText = new StringBuilder().append(carrierText).append(separator)
                                .append(intent.getStringExtra(TelephonyIntents.EXTRA_SPN))
                                .toString();
                    }
                    setCarrierText(carrierText, subId);
                } else if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
                    setCarrierText(intent.getStringExtra(TelephonyIntents.EXTRA_PLMN), subId);
                }
            }
        }
    };


    public static SubscriptionController init(Phone phone) {
    public static SubscriptionController init(Phone phone) {
        synchronized (SubscriptionController.class) {
        synchronized (SubscriptionController.class) {
@@ -196,6 +224,8 @@ public class SubscriptionController extends ISub.Stub {
        if(ServiceManager.getService("isub") == null) {
        if(ServiceManager.getService("isub") == null) {
                ServiceManager.addService("isub", this);
                ServiceManager.addService("isub", this);
        }
        }
        mContext.registerReceiver(mReceiver,
                new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));


        if (DBG) logdl("[SubscriptionController] init by Context");
        if (DBG) logdl("[SubscriptionController] init by Context");
    }
    }
@@ -211,6 +241,8 @@ public class SubscriptionController extends ISub.Stub {
        if(ServiceManager.getService("isub") == null) {
        if(ServiceManager.getService("isub") == null) {
                ServiceManager.addService("isub", this);
                ServiceManager.addService("isub", this);
        }
        }
        mContext.registerReceiver(mReceiver,
                new IntentFilter(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION));


        if (DBG) logdl("[SubscriptionController] init by Phone");
        if (DBG) logdl("[SubscriptionController] init by Phone");
    }
    }
@@ -733,6 +765,26 @@ public class SubscriptionController extends ISub.Stub {
        return 0;
        return 0;
    }
    }


    /**
     * Set carrier text by simInfo index
     * @param text new carrier text
     * @param subId the unique SubInfoRecord index in database
     * @return the number of records updated
     */
    private int setCarrierText(String text, int subId) {
        if (DBG) logd("[setCarrierText]+ text:" + text + " subId:" + subId);
        enforceSubscriptionPermission();

        ContentValues value = new ContentValues(1);
        value.put(SubscriptionManager.CARRIER_NAME, text);

        int result = mContext.getContentResolver().update(SubscriptionManager.CONTENT_URI, value,
                SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=" + Long.toString(subId), null);
        notifySubscriptionInfoChanged();

        return result;
    }

    /**
    /**
     * Set SIM color tint by simInfo index
     * Set SIM color tint by simInfo index
     * @param tint the tint color of the SIM
     * @param tint the tint color of the SIM