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

Commit bacd3777 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-e64ca0c4-2b43-4758-b238-0b8c6fabc365-for-git_oc-mr1-release-42...

release-request-e64ca0c4-2b43-4758-b238-0b8c6fabc365-for-git_oc-mr1-release-4207446 snap-temp-L19600000085022555

Change-Id: I4d5d47d85e4f8715188bc60c31412d9bcb03c062
parents 966d0cbb 92f5e2af
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class AppSmsManager {
        }
        StringBuilder fullMessageBuilder = new StringBuilder();
        for (SmsMessage message : messages) {
            if (message.getMessageBody() == null) {
            if (message == null || message.getMessageBody() == null) {
                continue;
            }
            fullMessageBuilder.append(message.getMessageBody());
+102 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 com.android.internal.telephony;

import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.UserHandle;
import android.util.Log;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * This class is used to broadcast intents that need to be rebroadcast after the device is unlocked.
 * NOTE: Currently this is used only for SIM_STATE_CHANGED so logic is hardcoded for that;
 * for example broadcasts are always sticky, only the last intent for the slotId is rebroadcast,
 * etc.
 */
public class IntentBroadcaster {
    private static final String TAG = "IntentBroadcaster";

    private Map<Integer, Intent> mRebroadcastIntents = new HashMap<>();
    private static IntentBroadcaster sIntentBroadcaster;

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals(Intent.ACTION_USER_UNLOCKED)) {
                synchronized (mRebroadcastIntents) {
                    // rebroadcast intents
                    Iterator iterator = mRebroadcastIntents.entrySet().iterator();
                    while (iterator.hasNext()) {
                        Map.Entry pair = (Map.Entry) iterator.next();
                        Intent i = (Intent) pair.getValue();
                        i.putExtra(TelephonyIntents.EXTRA_REBROADCAST_ON_UNLOCK, true);
                        iterator.remove();
                        logd("Rebroadcasting intent " + i.getAction() + " "
                                + i.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)
                                + " for slotId " + pair.getKey());
                        ActivityManager.broadcastStickyIntent(i, UserHandle.USER_ALL);
                    }
                }
            }
        }
    };

    private IntentBroadcaster(Context context) {
        context.registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
    }

    /**
     * Method to get an instance of IntentBroadcaster after creating one if needed.
     * @return IntentBroadcaster instance
     */
    public static IntentBroadcaster getInstance(Context context) {
        if (sIntentBroadcaster == null) {
            sIntentBroadcaster = new IntentBroadcaster(context);
        }
        return sIntentBroadcaster;
    }

    public static IntentBroadcaster getInstance() {
        return sIntentBroadcaster;
    }

    /**
     * Wrapper for ActivityManager.broadcastStickyIntent() that also stores intent to be rebroadcast
     * on USER_UNLOCKED
     */
    public void broadcastStickyIntent(Intent intent, int slotId) {
        logd("Broadcasting and adding intent for rebroadcast: " + intent.getAction() + " "
                + intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE)
                + " for slotId " + slotId);
        synchronized (mRebroadcastIntents) {
            ActivityManager.broadcastStickyIntent(intent, UserHandle.USER_ALL);
            mRebroadcastIntents.put(slotId, intent);
        }
    }

    private void logd(String s) {
        Log.d(TAG, s);
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public class PhoneFactory {

    static private ProxyController sProxyController;
    static private UiccController sUiccController;
    private static IntentBroadcaster sIntentBroadcaster;
    private static @Nullable EuiccController sEuiccController;

    static private CommandsInterface sCommandsInterface = null;
@@ -240,6 +241,8 @@ public class PhoneFactory {
                sProxyController = ProxyController.getInstance(context, sPhones,
                        sUiccController, sCommandsInterfaces, sPhoneSwitcher);

                sIntentBroadcaster = IntentBroadcaster.getInstance(context);

                sNotificationChannelController = new NotificationChannelController(context);

                sTelephonyNetworkFactories = new TelephonyNetworkFactory[numPhones];
+12 −3
Original line number Diff line number Diff line
@@ -336,7 +336,10 @@ public class PhoneSwitcher extends Handler {
        state.active = false;
        log("deactivate " + phoneId);
        state.lastRequested = System.currentTimeMillis();
        // Skip ALLOW_DATA for single SIM device
        if (mNumPhones > 1) {
            mCommandsInterfaces[phoneId].setDataAllowed(false, null);
        }
        mActivePhoneRegistrants[phoneId].notifyRegistrants();
    }

@@ -346,7 +349,10 @@ public class PhoneSwitcher extends Handler {
        state.active = true;
        log("activate " + phoneId);
        state.lastRequested = System.currentTimeMillis();
        // Skip ALLOW_DATA for single SIM device
        if (mNumPhones > 1) {
            mCommandsInterfaces[phoneId].setDataAllowed(true, null);
        }
        mActivePhoneRegistrants[phoneId].notifyRegistrants();
    }

@@ -361,8 +367,11 @@ public class PhoneSwitcher extends Handler {

    private void onResendDataAllowed(Message msg) {
        final int phoneId = msg.arg1;
        // Skip ALLOW_DATA for single SIM device
        if (mNumPhones > 1) {
            mCommandsInterfaces[phoneId].setDataAllowed(mPhoneStates[phoneId].active, null);
        }
    }

    private int phoneIdForRequest(NetworkRequest netRequest) {
        NetworkSpecifier specifier = netRequest.networkCapabilities.getNetworkSpecifier();
+22 −14
Original line number Diff line number Diff line
@@ -16,23 +16,24 @@

package com.android.internal.telephony;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.os.Build;
import android.os.PersistableBundle;
import android.text.TextUtils;
import android.database.Cursor;
import android.database.SQLException;
import android.os.Binder;
import android.os.Build;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.android.internal.telephony.HbpcdLookup.MccIdd;
import com.android.internal.telephony.HbpcdLookup.MccLookup;

import java.util.ArrayList;
import java.util.HashMap;


 /**
 * This class implements handle the MO SMS target address before sending.
@@ -601,15 +602,22 @@ public class SmsNumberUtils {
    }

    private static boolean needToConvert(Phone phone) {
        // Calling package may not have READ_PHONE_STATE which is required for getConfig().
        // Clear the calling identity so that it is called as self.
        final long identity = Binder.clearCallingIdentity();
        try {
            CarrierConfigManager configManager = (CarrierConfigManager)
                    phone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
            if (configManager != null) {
                PersistableBundle bundle = configManager.getConfig();
                if (bundle != null) {
                return bundle.getBoolean(
                        CarrierConfigManager.KEY_SMS_REQUIRES_DESTINATION_NUMBER_CONVERSION_BOOL);
                    return bundle.getBoolean(CarrierConfigManager
                            .KEY_SMS_REQUIRES_DESTINATION_NUMBER_CONVERSION_BOOL);
                }
            }
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
        // by default this value is false
        return false;
    }
Loading