Search in sources :

Example 26 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class IccSmsInterfaceManager method getAllMessagesFromIccEf.

/**
 * Retrieves all messages currently stored on Icc.
 *
 * @return list of SmsRawData of all sms on Icc
 */
@UnsupportedAppUsage
public List<SmsRawData> getAllMessagesFromIccEf(String callingPackage) {
    if (DBG)
        log("getAllMessagesFromEF");
    mContext.enforceCallingOrSelfPermission(Manifest.permission.RECEIVE_SMS, "Reading messages from Icc");
    enforceAccessMessageOnICC("Reading messages from Icc");
    enforceNotOnHandlerThread("getAllMessagesFromIccEf");
    if (mAppOps.noteOp(AppOpsManager.OPSTR_READ_ICC_SMS, Binder.getCallingUid(), callingPackage) != AppOpsManager.MODE_ALLOWED) {
        return new ArrayList<SmsRawData>();
    }
    synchronized (mLock) {
        IccFileHandler fh = mPhone.getIccFileHandler();
        if (fh == null) {
            loge("Cannot load Sms records. No icc card?");
            mSms = null;
            return mSms;
        }
        Message response = mHandler.obtainMessage(EVENT_LOAD_DONE);
        fh.loadEFLinearFixedAll(IccConstants.EF_SMS, response);
        try {
            mLock.wait();
        } catch (InterruptedException e) {
            loge("interrupted while trying to load from the Icc");
        }
    }
    return mSms;
}
Also used : SmsMessage(android.telephony.SmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) Message(android.os.Message) ArrayList(java.util.ArrayList) IccFileHandler(com.android.internal.telephony.uicc.IccFileHandler) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 27 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class IccSmsInterfaceManager method copyMessageToIccEf.

/**
 * Copies a raw SMS PDU to the ICC.
 *
 * @param callingPackage the package name of the calling app.
 * @param status message status. One of these status:
 *               <code>STATUS_ON_ICC_READ</code>
 *               <code>STATUS_ON_ICC_UNREAD</code>
 *               <code>STATUS_ON_ICC_SENT</code>
 *               <code>STATUS_ON_ICC_UNSENT</code>
 * @param pdu the raw PDU to store.
 * @param smsc the SMSC for this message. Null means use default.
 * @return true for success. Otherwise false.
 */
@UnsupportedAppUsage
public boolean copyMessageToIccEf(String callingPackage, int status, byte[] pdu, byte[] smsc) {
    // NOTE smsc not used in RUIM
    if (DBG)
        log("copyMessageToIccEf: status=" + status + " ==> " + "pdu=(" + Arrays.toString(pdu) + "), smsc=(" + Arrays.toString(smsc) + ")");
    enforceReceiveAndSend("Copying message to Icc");
    enforceNotOnHandlerThread("copyMessageToIccEf");
    if (mAppOps.noteOp(AppOpsManager.OPSTR_WRITE_ICC_SMS, Binder.getCallingUid(), callingPackage) != AppOpsManager.MODE_ALLOWED) {
        return false;
    }
    synchronized (mLock) {
        mSuccess = false;
        Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
        // RIL_REQUEST_WRITE_SMS_TO_SIM vs RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM
        if (PhoneConstants.PHONE_TYPE_GSM == mPhone.getPhoneType()) {
            mPhone.mCi.writeSmsToSim(status, IccUtils.bytesToHexString(smsc), IccUtils.bytesToHexString(pdu), response);
        } else {
            mPhone.mCi.writeSmsToRuim(status, pdu, response);
        }
        try {
            mLock.wait();
        } catch (InterruptedException e) {
            loge("interrupted while trying to update by index");
        }
    }
    return mSuccess;
}
Also used : SmsMessage(android.telephony.SmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) Message(android.os.Message) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 28 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class IccSmsInterfaceManager method updateMessageOnIccEf.

/**
 * Update the specified message on the Icc.
 *
 * @param index record index of message to update
 * @param status new message status (STATUS_ON_ICC_READ,
 *                  STATUS_ON_ICC_UNREAD, STATUS_ON_ICC_SENT,
 *                  STATUS_ON_ICC_UNSENT, STATUS_ON_ICC_FREE)
 * @param pdu the raw PDU to store
 * @return success or not
 */
@UnsupportedAppUsage
public boolean updateMessageOnIccEf(String callingPackage, int index, int status, byte[] pdu) {
    if (DBG)
        log("updateMessageOnIccEf: index=" + index + " status=" + status + " ==> " + "(" + Arrays.toString(pdu) + ")");
    enforceReceiveAndSend("Updating message on Icc");
    enforceAccessMessageOnICC("Updating message on Icc");
    enforceNotOnHandlerThread("updateMessageOnIccEf");
    if (mAppOps.noteOp(AppOpsManager.OPSTR_WRITE_ICC_SMS, Binder.getCallingUid(), callingPackage) != AppOpsManager.MODE_ALLOWED) {
        return false;
    }
    synchronized (mLock) {
        mSuccess = false;
        Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
        if ((status & 0x01) == STATUS_ON_ICC_FREE) {
            // Will eventually fail if icc card is not present.
            if (PhoneConstants.PHONE_TYPE_GSM == mPhone.getPhoneType()) {
                mPhone.mCi.deleteSmsOnSim(index, response);
            } else {
                mPhone.mCi.deleteSmsOnRuim(index, response);
            }
        } else {
            // IccFilehandler can be null if ICC card is not present.
            IccFileHandler fh = mPhone.getIccFileHandler();
            if (fh == null) {
                response.recycle();
                return mSuccess;
            /* is false */
            }
            byte[] record = makeSmsRecordData(status, pdu);
            fh.updateEFLinearFixed(IccConstants.EF_SMS, index, record, null, response);
        }
        try {
            mLock.wait();
        } catch (InterruptedException e) {
            loge("interrupted while trying to update by index");
        }
    }
    return mSuccess;
}
Also used : SmsMessage(android.telephony.SmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) Message(android.os.Message) IccFileHandler(com.android.internal.telephony.uicc.IccFileHandler) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 29 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class InboundSmsHandler method handleNewSms.

@UnsupportedAppUsage
private void handleNewSms(AsyncResult ar) {
    if (ar.exception != null) {
        loge("Exception processing incoming SMS: " + ar.exception);
        return;
    }
    int result;
    try {
        SmsMessage sms = (SmsMessage) ar.result;
        mLastSmsWasInjected = false;
        result = dispatchMessage(sms.mWrappedSmsMessage);
    } catch (RuntimeException ex) {
        loge("Exception dispatching message", ex);
        result = RESULT_SMS_DISPATCH_FAILURE;
    }
    // e.g. for SMS-PP data download. Any other result, we should ack here.
    if (result != Activity.RESULT_OK) {
        boolean handled = (result == Intents.RESULT_SMS_HANDLED);
        notifyAndAcknowledgeLastIncomingSms(handled, result, null);
    }
}
Also used : SmsMessage(android.telephony.SmsMessage) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 30 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class PhoneFactory method getPhone.

@UnsupportedAppUsage
public static Phone getPhone(int phoneId) {
    Phone phone;
    String dbgInfo = "";
    synchronized (sLockProxyPhones) {
        if (!sMadeDefaults) {
            throw new IllegalStateException("Default phones haven't been made yet!");
        // CAF_MSIM FIXME need to introduce default phone id ?
        } else if (phoneId == SubscriptionManager.DEFAULT_PHONE_INDEX) {
            if (DBG) {
                dbgInfo = "phoneId == DEFAULT_PHONE_ID return sPhone";
            }
            phone = sPhone;
        } else {
            if (DBG) {
                dbgInfo = "phoneId != DEFAULT_PHONE_ID return sPhones[phoneId]";
            }
            phone = (phoneId >= 0 && phoneId < sPhones.length) ? sPhones[phoneId] : null;
        }
        if (DBG) {
            Rlog.d(LOG_TAG, "getPhone:- " + dbgInfo + " phoneId=" + phoneId + " phone=" + phone);
        }
        return phone;
    }
}
Also used : ImsPhone(com.android.internal.telephony.imsphone.ImsPhone) SipPhone(com.android.internal.telephony.sip.SipPhone) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Aggregations

UnsupportedAppUsage (android.compat.annotation.UnsupportedAppUsage)71 Message (android.os.Message)18 SmsMessage (android.telephony.SmsMessage)9 Intent (android.content.Intent)6 SipPhone (com.android.internal.telephony.sip.SipPhone)6 SmsCbMessage (android.telephony.SmsCbMessage)5 Cursor (android.database.Cursor)4 PendingIntent (android.app.PendingIntent)3 PackageManager (android.content.pm.PackageManager)3 AsyncResult (android.os.AsyncResult)3 PersistableBundle (android.os.PersistableBundle)3 CarrierConfigManager (android.telephony.CarrierConfigManager)3 SubscriptionInfo (android.telephony.SubscriptionInfo)3 SQLException (android.database.SQLException)2 SQLiteException (android.database.sqlite.SQLiteException)2 PowerManager (android.os.PowerManager)2 RadioAccessFamily (android.telephony.RadioAccessFamily)2 ImsException (com.android.ims.ImsException)2 ImsUtInterface (com.android.ims.ImsUtInterface)2 AppState (com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState)2