Search in sources :

Example 56 with UnsupportedAppUsage

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

the class InboundSmsHandler method deleteFromRawTable.

/**
 * Helper for {@link SmsBroadcastUndelivered} to delete an old message in the raw table.
 */
@UnsupportedAppUsage
private void deleteFromRawTable(String deleteWhere, String[] deleteWhereArgs, int deleteType) {
    Uri uri = deleteType == DELETE_PERMANENTLY ? sRawUriPermanentDelete : sRawUri;
    int rows = mResolver.delete(uri, deleteWhere, deleteWhereArgs);
    if (rows == 0) {
        loge("No rows were deleted from raw table!");
    } else if (DBG) {
        log("Deleted " + rows + " rows from raw table.");
    }
}
Also used : Uri(android.net.Uri) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 57 with UnsupportedAppUsage

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

the class InboundSmsHandler method showNewMessageNotification.

@UnsupportedAppUsage
private void showNewMessageNotification() {
    // Do not show the notification on non-FBE devices.
    if (!StorageManager.isFileEncryptedNativeOrEmulated()) {
        return;
    }
    log("Show new message notification.");
    PendingIntent intent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_OPEN_SMS_APP), PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
    Notification.Builder mBuilder = new Notification.Builder(mContext).setSmallIcon(com.android.internal.R.drawable.sym_action_chat).setAutoCancel(true).setVisibility(Notification.VISIBILITY_PUBLIC).setDefaults(Notification.DEFAULT_ALL).setContentTitle(mContext.getString(R.string.new_sms_notification_title)).setContentText(mContext.getString(R.string.new_sms_notification_content)).setContentIntent(intent).setChannelId(NotificationChannelController.CHANNEL_ID_SMS);
    NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID_NEW_MESSAGE, mBuilder.build());
}
Also used : NotificationManager(android.app.NotificationManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 58 with UnsupportedAppUsage

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

the class PhoneFactory method makeDefaultPhone.

/**
 * FIXME replace this with some other way of making these
 * instances
 */
@UnsupportedAppUsage
public static void makeDefaultPhone(Context context) {
    synchronized (sLockProxyPhones) {
        if (!sMadeDefaults) {
            sContext = context;
            // create the telephony device controller.
            TelephonyDevController.create();
            TelephonyMetrics metrics = TelephonyMetrics.getInstance();
            metrics.setContext(context);
            int retryCount = 0;
            for (; ; ) {
                boolean hasException = false;
                retryCount++;
                try {
                    // use UNIX domain socket to
                    // prevent subsequent initialization
                    new LocalServerSocket("com.android.internal.telephony");
                } catch (java.io.IOException ex) {
                    hasException = true;
                }
                if (!hasException) {
                    break;
                } else if (retryCount > SOCKET_OPEN_MAX_RETRY) {
                    throw new RuntimeException("PhoneFactory probably already running");
                } else {
                    try {
                        Thread.sleep(SOCKET_OPEN_RETRY_MILLIS);
                    } catch (InterruptedException er) {
                    }
                }
            }
            // register statsd pullers.
            sMetricsCollector = new MetricsCollector(context);
            sPhoneNotifier = new DefaultPhoneNotifier(context);
            int cdmaSubscription = CdmaSubscriptionSourceManager.getDefault(context);
            Rlog.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription);
            /* In case of multi SIM mode two instances of Phone, RIL are created,
                   where as in single SIM mode only instance. isMultiSimEnabled() function checks
                   whether it is single SIM or multi SIM mode */
            int numPhones = TelephonyManager.getDefault().getActiveModemCount();
            int[] networkModes = new int[numPhones];
            sPhones = new Phone[numPhones];
            sCommandsInterfaces = new RIL[numPhones];
            sTelephonyNetworkFactories = new TelephonyNetworkFactory[numPhones];
            for (int i = 0; i < numPhones; i++) {
                // reads the system properties and makes commandsinterface
                // Get preferred network type.
                networkModes[i] = RILConstants.PREFERRED_NETWORK_MODE;
                Rlog.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkModes[i]));
                sCommandsInterfaces[i] = new RIL(context, networkModes[i], cdmaSubscription, i);
            }
            // Instantiate UiccController so that all other classes can just
            // call getInstance()
            sUiccController = UiccController.make(context);
            Rlog.i(LOG_TAG, "Creating SubscriptionController");
            TelephonyComponentFactory.getInstance().inject(SubscriptionController.class.getName()).initSubscriptionController(context);
            TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class.getName()).initMultiSimSettingController(context, SubscriptionController.getInstance());
            if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_EUICC)) {
                sEuiccController = EuiccController.init(context);
                sEuiccCardController = EuiccCardController.init(context);
            }
            for (int i = 0; i < numPhones; i++) {
                sPhones[i] = createPhone(context, i);
            }
            // FIXME: needs to be done in a more controlled manner in the future.
            if (numPhones > 0)
                sPhone = sPhones[0];
            // Ensure that we have a default SMS app. Requesting the app with
            // updateIfNeeded set to true is enough to configure a default SMS app.
            ComponentName componentName = SmsApplication.getDefaultSmsApplication(context, true);
            String packageName = "NONE";
            if (componentName != null) {
                packageName = componentName.getPackageName();
            }
            Rlog.i(LOG_TAG, "defaultSmsApplication: " + packageName);
            // Set up monitor to watch for changes to SMS packages
            SmsApplication.initSmsPackageMonitor(context);
            sMadeDefaults = true;
            Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater ");
            HandlerThread pfhandlerThread = new HandlerThread("PhoneFactoryHandlerThread");
            pfhandlerThread.start();
            sSubInfoRecordUpdater = TelephonyComponentFactory.getInstance().inject(SubscriptionInfoUpdater.class.getName()).makeSubscriptionInfoUpdater(pfhandlerThread.getLooper(), context, sCommandsInterfaces);
            // Only bring up IMS if the device supports having an IMS stack.
            if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS)) {
                // might need it when it is being opened.
                for (int i = 0; i < numPhones; i++) {
                    sPhones[i].createImsPhone();
                }
            } else {
                Rlog.i(LOG_TAG, "IMS is not supported on this device, skipping ImsResolver.");
            }
            sPhoneConfigurationManager = PhoneConfigurationManager.init(sContext);
            sCellularNetworkValidator = CellularNetworkValidator.make(sContext);
            int maxActivePhones = sPhoneConfigurationManager.getNumberOfModemsWithSimultaneousDataConnections();
            sPhoneSwitcher = TelephonyComponentFactory.getInstance().inject(PhoneSwitcher.class.getName()).makePhoneSwitcher(maxActivePhones, sContext, Looper.myLooper());
            sProxyController = ProxyController.getInstance(context);
            sIntentBroadcaster = IntentBroadcaster.getInstance(context);
            sNotificationChannelController = new NotificationChannelController(context);
            for (int i = 0; i < numPhones; i++) {
                sTelephonyNetworkFactories[i] = new TelephonyNetworkFactory(Looper.myLooper(), sPhones[i]);
            }
        }
    }
}
Also used : MetricsCollector(com.android.internal.telephony.metrics.MetricsCollector) HandlerThread(android.os.HandlerThread) LocalServerSocket(android.net.LocalServerSocket) ComponentName(android.content.ComponentName) TelephonyMetrics(com.android.internal.telephony.metrics.TelephonyMetrics) TelephonyNetworkFactory(com.android.internal.telephony.dataconnection.TelephonyNetworkFactory) NotificationChannelController(com.android.internal.telephony.util.NotificationChannelController) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 59 with UnsupportedAppUsage

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

the class ProxyController method completeRadioCapabilityTransaction.

@UnsupportedAppUsage
private void completeRadioCapabilityTransaction() {
    // Create the intent to broadcast
    Intent intent;
    logd("onFinishRadioCapabilityResponse: success=" + !mTransactionFailed);
    if (!mTransactionFailed) {
        ArrayList<RadioAccessFamily> phoneRAFList = new ArrayList<RadioAccessFamily>();
        for (int i = 0; i < mPhones.length; i++) {
            int raf = mPhones[i].getRadioAccessFamily();
            logd("radioAccessFamily[" + i + "]=" + raf);
            RadioAccessFamily phoneRC = new RadioAccessFamily(i, raf);
            phoneRAFList.add(phoneRC);
        }
        intent = new Intent(TelephonyIntents.ACTION_SET_RADIO_CAPABILITY_DONE);
        intent.putParcelableArrayListExtra(TelephonyIntents.EXTRA_RADIO_ACCESS_FAMILY, phoneRAFList);
        // make messages about the old transaction obsolete (specifically the timeout)
        mRadioCapabilitySessionId = mUniqueIdGenerator.getAndIncrement();
        // Reinitialize
        clearTransaction();
    } else {
        intent = new Intent(TelephonyIntents.ACTION_SET_RADIO_CAPABILITY_FAILED);
        // now revert.
        mTransactionFailed = false;
        RadioAccessFamily[] rafs = new RadioAccessFamily[mPhones.length];
        for (int phoneId = 0; phoneId < mPhones.length; phoneId++) {
            rafs[phoneId] = new RadioAccessFamily(phoneId, mOldRadioAccessFamily[phoneId]);
        }
        doSetRadioCapabilities(rafs);
    }
    // Broadcast that we're done
    mContext.sendBroadcast(intent, android.Manifest.permission.READ_PHONE_STATE);
}
Also used : ArrayList(java.util.ArrayList) Intent(android.content.Intent) RadioAccessFamily(android.telephony.RadioAccessFamily) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 60 with UnsupportedAppUsage

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

the class IccFileHandler method getEFLinearRecordSize.

/**
 * Get record size for a linear fixed EF
 *
 * @param fileid EF id
 * @param path Path of the EF on the card
 * @param onLoaded ((AsnyncResult)(onLoaded.obj)).result is the recordSize[]. recordSize[0] is
 *                 the single record length, recordSize[1] is the total length of the EF file
 *                 and recordSize[2] is the number of records in the EF file. So recordSize[0]
 *                 * recordSize[2] = recordSize[1].
 */
@UnsupportedAppUsage
public void getEFLinearRecordSize(int fileid, String path, Message onLoaded) {
    String efPath = (path == null) ? getEFPath(fileid) : path;
    Message response = obtainMessage(EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE, new LoadLinearFixedContext(fileid, efPath, onLoaded));
    mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath, 0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
}
Also used : Message(android.os.Message) 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