Search in sources :

Example 31 with UnsupportedAppUsage

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

the class InboundSmsHandler method dispatchIntent.

/**
 * Dispatch the intent with the specified permission, appOp, and result receiver, using
 * this state machine's handler thread to run the result receiver.
 *
 * @param intent the intent to broadcast
 * @param permission receivers are required to have this permission
 * @param appOp app op that is being performed when dispatching to a receiver
 * @param user user to deliver the intent to
 */
@UnsupportedAppUsage
public void dispatchIntent(Intent intent, String permission, String appOp, Bundle opts, BroadcastReceiver resultReceiver, UserHandle user, int subId) {
    intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
    final String action = intent.getAction();
    SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
    // different, specifically if the message is coming from SmsBroadcastUndelivered
    if (SubscriptionManager.isValidSubscriptionId(subId)) {
        SubscriptionManager.putSubscriptionIdExtra(intent, subId);
    }
    if (user.equals(UserHandle.ALL)) {
        // Get a list of currently started users.
        int[] users = null;
        final List<UserHandle> userHandles = mUserManager.getUserHandles(false);
        final List<UserHandle> runningUserHandles = new ArrayList();
        for (UserHandle handle : userHandles) {
            if (mUserManager.isUserRunning(handle)) {
                runningUserHandles.add(handle);
            }
        }
        if (runningUserHandles.isEmpty()) {
            users = new int[] { user.getIdentifier() };
        } else {
            users = new int[runningUserHandles.size()];
            for (int i = 0; i < runningUserHandles.size(); i++) {
                users[i] = runningUserHandles.get(i).getIdentifier();
            }
        }
        // by user policy.
        for (int i = users.length - 1; i >= 0; i--) {
            UserHandle targetUser = UserHandle.of(users[i]);
            if (users[i] != UserHandle.SYSTEM.getIdentifier()) {
                // Is the user not allowed to use SMS?
                if (hasUserRestriction(UserManager.DISALLOW_SMS, targetUser)) {
                    continue;
                }
                // Skip unknown users and managed profiles as well
                if (mUserManager.isManagedProfile(users[i])) {
                    continue;
                }
            }
            // Only pass in the resultReceiver when the user SYSTEM is processed.
            try {
                mContext.createPackageContextAsUser(mContext.getPackageName(), 0, targetUser).sendOrderedBroadcast(intent, Activity.RESULT_OK, permission, appOp, users[i] == UserHandle.SYSTEM.getIdentifier() ? resultReceiver : null, getHandler(), null, /* initialData */
                null, /* initialExtras */
                opts);
            } catch (PackageManager.NameNotFoundException ignored) {
            }
        }
    } else {
        try {
            mContext.createPackageContextAsUser(mContext.getPackageName(), 0, user).sendOrderedBroadcast(intent, Activity.RESULT_OK, permission, appOp, resultReceiver, getHandler(), null, /* initialData */
            null, /* initialExtras */
            opts);
        } catch (PackageManager.NameNotFoundException ignored) {
        }
    }
}
Also used : PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) UserHandle(android.os.UserHandle) ArrayList(java.util.ArrayList) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 32 with UnsupportedAppUsage

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

the class RIL method acquireWakeLock.

/**
 * Holds a PARTIAL_WAKE_LOCK whenever
 * a) There is outstanding RIL request sent to RIL deamon and no replied
 * b) There is a request pending to be sent out.
 *
 * There is a WAKE_LOCK_TIMEOUT to release the lock, though it shouldn't
 * happen often.
 */
@UnsupportedAppUsage
private void acquireWakeLock(RILRequest rr, int wakeLockType) {
    synchronized (rr) {
        if (rr.mWakeLockType != INVALID_WAKELOCK) {
            Rlog.d(RILJ_LOG_TAG, "Failed to aquire wakelock for " + rr.serialString());
            return;
        }
        switch(wakeLockType) {
            case FOR_WAKELOCK:
                synchronized (mWakeLock) {
                    mWakeLock.acquire();
                    mWakeLockCount++;
                    mWlSequenceNum++;
                    String clientId = rr.getWorkSourceClientId();
                    if (!mClientWakelockTracker.isClientActive(clientId)) {
                        mActiveWakelockWorkSource.add(rr.mWorkSource);
                        mWakeLock.setWorkSource(mActiveWakelockWorkSource);
                    }
                    mClientWakelockTracker.startTracking(rr.mClientId, rr.mRequest, rr.mSerial, mWakeLockCount);
                    Message msg = mRilHandler.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT);
                    msg.arg1 = mWlSequenceNum;
                    mRilHandler.sendMessageDelayed(msg, mWakeLockTimeout);
                }
                break;
            case FOR_ACK_WAKELOCK:
                synchronized (mAckWakeLock) {
                    mAckWakeLock.acquire();
                    mAckWlSequenceNum++;
                    Message msg = mRilHandler.obtainMessage(EVENT_ACK_WAKE_LOCK_TIMEOUT);
                    msg.arg1 = mAckWlSequenceNum;
                    mRilHandler.sendMessageDelayed(msg, mAckWakeLockTimeout);
                }
                break;
            default:
                // WTF
                Rlog.w(RILJ_LOG_TAG, "Acquiring Invalid Wakelock type " + wakeLockType);
                return;
        }
        rr.mWakeLockType = wakeLockType;
    }
}
Also used : Message(android.os.Message) CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) ImsSmsMessage(android.hardware.radio.V1_0.ImsSmsMessage) GsmSmsMessage(android.hardware.radio.V1_0.GsmSmsMessage) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 33 with UnsupportedAppUsage

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

the class Phone method setNetworkSelectionModeAutomatic.

/**
 * Switches network selection mode to "automatic", re-scanning and
 * re-selecting a network if appropriate.
 *
 * @param response The message to dispatch when the network selection
 * is complete.
 *
 * @see #selectNetworkManually(OperatorInfo, boolean, android.os.Message)
 */
@UnsupportedAppUsage
public void setNetworkSelectionModeAutomatic(Message response) {
    Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic, querying current mode");
    // we don't want to do this unecesarily - it acutally causes
    // the radio to repeate network selection and is costly
    // first check if we're already in automatic mode
    Message msg = obtainMessage(EVENT_CHECK_FOR_NETWORK_AUTOMATIC);
    msg.obj = response;
    mCi.getNetworkSelectionMode(msg);
}
Also used : Message(android.os.Message) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 34 with UnsupportedAppUsage

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

the class Phone method getActiveApnTypes.

/**
 * Returns an array of string identifiers for the APN types serviced by the
 * currently active subscription.
 *
 * @return The string array of APN types. Return null if no active APN types.
 */
@UnsupportedAppUsage
@NonNull
public String[] getActiveApnTypes() {
    if (mTransportManager == null || mDcTrackers == null) {
        Rlog.e(LOG_TAG, "Invalid state for Transport/DcTrackers");
        return new String[0];
    }
    Set<String> activeApnTypes = new HashSet<String>();
    for (int transportType : mTransportManager.getAvailableTransports()) {
        DcTracker dct = getDcTracker(transportType);
        // TODO: should this ever happen?
        if (dct == null)
            continue;
        activeApnTypes.addAll(Arrays.asList(dct.getActiveApnTypes()));
    }
    return activeApnTypes.toArray(new String[activeApnTypes.size()]);
}
Also used : DcTracker(com.android.internal.telephony.dataconnection.DcTracker) HashSet(java.util.HashSet) NonNull(android.annotation.NonNull) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 35 with UnsupportedAppUsage

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

the class ImsPhoneCallTracker method setVideoCallProvider.

@UnsupportedAppUsage
private void setVideoCallProvider(ImsPhoneConnection conn, ImsCall imsCall) throws RemoteException {
    IImsVideoCallProvider imsVideoCallProvider = imsCall.getCallSession().getVideoCallProvider();
    if (imsVideoCallProvider != null) {
        // TODO: Remove this when we can better formalize the format of session modify requests.
        boolean useVideoPauseWorkaround = mPhone.getContext().getResources().getBoolean(com.android.internal.R.bool.config_useVideoPauseWorkaround);
        ImsVideoCallProviderWrapper imsVideoCallProviderWrapper = new ImsVideoCallProviderWrapper(imsVideoCallProvider);
        if (useVideoPauseWorkaround) {
            imsVideoCallProviderWrapper.setUseVideoPauseWorkaround(useVideoPauseWorkaround);
        }
        conn.setVideoProvider(imsVideoCallProviderWrapper);
        imsVideoCallProviderWrapper.registerForDataUsageUpdate(this, EVENT_VT_DATA_USAGE_UPDATE, imsCall);
        imsVideoCallProviderWrapper.addImsVideoProviderCallback(conn);
    }
}
Also used : IImsVideoCallProvider(com.android.ims.internal.IImsVideoCallProvider) ImsVideoCallProviderWrapper(com.android.ims.internal.ImsVideoCallProviderWrapper) 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