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

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

Snap for 5537346 from 8181a82f to qt-release

Change-Id: I59f2b500ea25619d648d829f700df5dc17406c4c
parents 328f11f4 8181a82f
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.ImsiEncryptionInfo;
@@ -65,7 +67,7 @@ import java.util.zip.GZIPInputStream;
 * This class contains logic to get Certificates and keep them current.
 * The class will be instantiated by various Phone implementations.
 */
public class CarrierKeyDownloadManager {
public class CarrierKeyDownloadManager extends Handler {
    private static final String LOG_TAG = "CarrierKeyDownloadManager";

    private static final String MCC_MNC_PREF_TAG = "CARRIER_KEY_DM_MCC_MNC";
@@ -103,6 +105,9 @@ public class CarrierKeyDownloadManager {
    private static final String JSON_TYPE_VALUE_WLAN = "WLAN";
    private static final String JSON_TYPE_VALUE_EPDG = "EPDG";

    private static final int EVENT_ALARM_OR_CONFIG_CHANGE = 0;
    private static final int EVENT_DOWNLOAD_COMPLETE = 1;


    private static final int[] CARRIER_KEY_TYPES = {TelephonyManager.KEY_TYPE_EPDG,
            TelephonyManager.KEY_TYPE_WLAN};
@@ -133,31 +138,43 @@ public class CarrierKeyDownloadManager {
            int slotId = mPhone.getPhoneId();
            if (action.equals(INTENT_KEY_RENEWAL_ALARM_PREFIX + slotId)) {
                Log.d(LOG_TAG, "Handling key renewal alarm: " + action);
                handleAlarmOrConfigChange();
                sendEmptyMessage(EVENT_ALARM_OR_CONFIG_CHANGE);
            } else if (action.equals(TelephonyIntents.ACTION_CARRIER_CERTIFICATE_DOWNLOAD)) {
                if (slotId == intent.getIntExtra(PhoneConstants.PHONE_KEY,
                        SubscriptionManager.INVALID_SIM_SLOT_INDEX)) {
                    Log.d(LOG_TAG, "Handling reset intent: " + action);
                    handleAlarmOrConfigChange();
                    sendEmptyMessage(EVENT_ALARM_OR_CONFIG_CHANGE);
                }
            } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
                if (slotId == intent.getIntExtra(PhoneConstants.PHONE_KEY,
                        SubscriptionManager.INVALID_SIM_SLOT_INDEX)) {
                    Log.d(LOG_TAG, "Carrier Config changed: " + action);
                    handleAlarmOrConfigChange();
                    sendEmptyMessage(EVENT_ALARM_OR_CONFIG_CHANGE);
                }
            } else if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
                Log.d(LOG_TAG, "Download Complete");
                long carrierKeyDownloadIdentifier =
                        intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                sendMessage(obtainMessage(EVENT_DOWNLOAD_COMPLETE,
                        intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0)));
            }
        }
    };

    @Override
    public void handleMessage (Message msg) {
        switch (msg.what) {
            case EVENT_ALARM_OR_CONFIG_CHANGE:
                handleAlarmOrConfigChange();
                break;
            case EVENT_DOWNLOAD_COMPLETE:
                long carrierKeyDownloadIdentifier = (long) msg.obj;
                String mccMnc = getMccMncSetFromPref();
                if (isValidDownload(mccMnc)) {
                    onDownloadComplete(carrierKeyDownloadIdentifier, mccMnc);
                    onPostDownloadProcessing(carrierKeyDownloadIdentifier);
                }
                break;
        }
    }
    };

    private void onPostDownloadProcessing(long carrierKeyDownloadIdentifier) {
        resetRenewalAlarm();
+3 −3
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.telephony.ims.RcsFileTransferCreationParams;
import android.telephony.ims.RcsMessageCreationParams;
import android.telephony.ims.RcsMessageQueryResult;
import android.telephony.ims.RcsMessageQueryResultParcelable;
import android.telephony.ims.RcsQueryContinuationToken;

import com.android.ims.RcsTypeIdPair;
@@ -77,7 +77,7 @@ class RcsMessageQueryHelper {
        mContentResolver = contentResolver;
    }

    RcsMessageQueryResult performMessageQuery(Bundle bundle) throws RemoteException {
    RcsMessageQueryResultParcelable performMessageQuery(Bundle bundle) throws RemoteException {
        RcsQueryContinuationToken continuationToken = null;
        List<RcsTypeIdPair> messageTypeIdPairs = new ArrayList<>();

@@ -104,7 +104,7 @@ class RcsMessageQueryHelper {
            }
        }

        return new RcsMessageQueryResult(continuationToken, messageTypeIdPairs);
        return new RcsMessageQueryResultParcelable(continuationToken, messageTypeIdPairs);
    }

    void createContentValuesForGenericMessage(ContentValues contentValues, int threadId,
+557 −395

File changed.

Preview size limit exceeded, changes collapsed.

+4 −20
Original line number Diff line number Diff line
@@ -24,37 +24,21 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
import android.telephony.ims.RcsParticipant;
import android.telephony.ims.RcsParticipantQueryResult;
import android.telephony.ims.RcsParticipantQueryResultParcelable;
import android.telephony.ims.RcsQueryContinuationToken;

import java.util.ArrayList;
import java.util.List;

class RcsParticipantQueryHelper {
    static final Uri CANONICAL_ADDRESSES_URI = Uri.parse("content://mms-sms/canonical-addresses");
    private final ContentResolver mContentResolver;

    RcsParticipantQueryHelper(ContentResolver contentResolver) {
        mContentResolver = contentResolver;
    }

    RcsParticipant getParticipantFromId(int participantId) throws RemoteException {
        RcsParticipant participant = null;
        try (Cursor cursor = mContentResolver.query(
                Uri.withAppendedPath(RCS_PARTICIPANT_URI, Integer.toString(participantId)),
                new String[]{RCS_PARTICIPANT_ID_COLUMN}, null, null)) {
            if (cursor == null || !cursor.moveToNext()) {
                throw new RemoteException("Could not find participant with id: " + participantId);
            }

            participant = new RcsParticipant(
                    cursor.getInt(cursor.getColumnIndex(RCS_PARTICIPANT_ID_COLUMN)));
        }
        return participant;
    }

    RcsParticipantQueryResult performParticipantQuery(Bundle bundle) throws RemoteException {
    RcsParticipantQueryResultParcelable performParticipantQuery(Bundle bundle)
            throws RemoteException {
        RcsQueryContinuationToken continuationToken = null;
        List<Integer> participantList = new ArrayList<>();

@@ -74,7 +58,7 @@ class RcsParticipantQueryHelper {
            }
        }

        return new RcsParticipantQueryResult(continuationToken, participantList);
        return new RcsParticipantQueryResultParcelable(continuationToken, participantList);
    }

    static Uri getUriForParticipant(int participantId) {
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.ims;

import android.Manifest;
import android.app.AppOpsManager;
import android.content.Context;
import android.os.Binder;

class RcsPermissions {
    static void checkReadPermissions(Context context, String callingPackage) {
        int pid = Binder.getCallingPid();
        int uid = Binder.getCallingUid();

        context.enforcePermission(Manifest.permission.READ_SMS, pid, uid, null);

        checkOp(context, uid, callingPackage, AppOpsManager.OP_READ_SMS);
    }

    static void checkWritePermissions(Context context, String callingPackage) {
        int uid = Binder.getCallingUid();

        checkOp(context, uid, callingPackage, AppOpsManager.OP_WRITE_SMS);
    }

    /**
     * Notes the provided op, but throws even if the op mode is {@link AppOpsManager.MODE_IGNORED}.
     * <p>
     * {@link AppOpsManager.OP_WRITE_SMS} defaults to {@link AppOpsManager.MODE_IGNORED} to avoid
     * crashing applications written before the app op was introduced. Since this is a new API,
     * consumers should be aware of the permission requirements, and we should be safe to throw a
     * {@link SecurityException} instead of providing a dummy value (which could cause unexpected
     * application behavior and possible loss of user data). {@link AppOpsManager.OP_READ_SMS} is
     * not normally in {@link AppOpsManager.MODE_IGNORED}, but we maintain the same behavior for
     * consistency with handling of write permissions.
     */
    private static void checkOp(Context context, int uid, String callingPackage, int op) {
        AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);

        int mode = appOps.noteOp(op, uid, callingPackage);

        if (mode != AppOpsManager.MODE_ALLOWED) {
            throw new SecurityException(
                    AppOpsManager.opToName(op) + " not allowed for " + callingPackage);
        }
    }
}
Loading