use of android.annotation.SystemApi in project platform_frameworks_base by android.
the class AudioPolicy method createAudioRecordSink.
/**
* Create an {@link AudioRecord} instance that is associated with the given {@link AudioMix}.
* Audio buffers recorded through the created instance will contain the mix of the audio
* streams that fed the given mixer.
* @param mix a non-null {@link AudioMix} instance whose routing flags was defined with
* {@link AudioMix#ROUTE_FLAG_LOOP_BACK}, previously added to this policy.
* @return a new {@link AudioRecord} instance whose data format is the one defined in the
* {@link AudioMix}, or null if this policy was not successfully registered
* with {@link AudioManager#registerAudioPolicy(AudioPolicy)}.
* @throws IllegalArgumentException
*/
@SystemApi
public AudioRecord createAudioRecordSink(AudioMix mix) throws IllegalArgumentException {
if (!policyReadyToUse()) {
Log.e(TAG, "Cannot create AudioRecord sink for AudioMix");
return null;
}
checkMixReadyToUse(mix, false);
// create an AudioFormat from the mix format compatible with recording, as the mix
// was defined for playback
AudioFormat mixFormat = new AudioFormat.Builder(mix.getFormat()).setChannelMask(AudioFormat.inChannelMaskFromOutChannelMask(mix.getFormat().getChannelMask())).build();
// create the AudioRecord, configured for loop back, using the same format as the mix
AudioRecord ar = new AudioRecord(new AudioAttributes.Builder().setInternalCapturePreset(MediaRecorder.AudioSource.REMOTE_SUBMIX).addTag(addressForTag(mix)).build(), mixFormat, AudioRecord.getMinBufferSize(mix.getFormat().getSampleRate(), // using stereo for buffer size to avoid the current poor support for masks
AudioFormat.CHANNEL_IN_STEREO, mix.getFormat().getEncoding()), AudioManager.AUDIO_SESSION_ID_GENERATE);
return ar;
}
use of android.annotation.SystemApi in project platform_frameworks_base by android.
the class AudioPolicy method createAudioTrackSource.
/**
* Create an {@link AudioTrack} instance that is associated with the given {@link AudioMix}.
* Audio buffers played through the created instance will be sent to the given mix
* to be recorded through the recording APIs.
* @param mix a non-null {@link AudioMix} instance whose routing flags was defined with
* {@link AudioMix#ROUTE_FLAG_LOOP_BACK}, previously added to this policy.
* @return a new {@link AudioTrack} instance whose data format is the one defined in the
* {@link AudioMix}, or null if this policy was not successfully registered
* with {@link AudioManager#registerAudioPolicy(AudioPolicy)}.
* @throws IllegalArgumentException
*/
@SystemApi
public AudioTrack createAudioTrackSource(AudioMix mix) throws IllegalArgumentException {
if (!policyReadyToUse()) {
Log.e(TAG, "Cannot create AudioTrack source for AudioMix");
return null;
}
checkMixReadyToUse(mix, true);
// create the AudioTrack, configured for loop back, using the same format as the mix
AudioTrack at = new AudioTrack(new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_VIRTUAL_SOURCE).addTag(addressForTag(mix)).build(), mix.getFormat(), AudioTrack.getMinBufferSize(mix.getFormat().getSampleRate(), mix.getFormat().getChannelMask(), mix.getFormat().getEncoding()), AudioTrack.MODE_STREAM, AudioManager.AUDIO_SESSION_ID_GENERATE);
return at;
}
use of android.annotation.SystemApi in project platform_frameworks_base by android.
the class AbstractAccountAuthenticator method startAddAccountSession.
/**
* Starts the add account session to authenticate user to an account of the
* specified accountType. No file I/O should be performed in this call.
* Account should be added to device only when {@link #finishSession} is
* called after this.
* <p>
* Note: when overriding this method, {@link #finishSession} should be
* overridden too.
* </p>
*
* @param response to send the result back to the AccountManager, will never
* be null
* @param accountType the type of account to authenticate with, will never
* be null
* @param authTokenType the type of auth token to retrieve after
* authenticating with the account, may be null
* @param requiredFeatures a String array of authenticator-specific features
* that the account authenticated with must support, may be null
* @param options a Bundle of authenticator-specific options, may be null
* @return a Bundle result or null if the result is to be returned via the
* response. The result will contain either:
* <ul>
* <li>{@link AccountManager#KEY_INTENT}, or
* <li>{@link AccountManager#KEY_ACCOUNT_SESSION_BUNDLE} for adding
* the account to device later, and if account is authenticated,
* optional {@link AccountManager#KEY_PASSWORD} and
* {@link AccountManager#KEY_ACCOUNT_STATUS_TOKEN} for checking the
* status of the account, or
* <li>{@link AccountManager#KEY_ERROR_CODE} and
* {@link AccountManager#KEY_ERROR_MESSAGE} to indicate an error
* </ul>
* @throws NetworkErrorException if the authenticator could not honor the
* request due to a network error
* @see #finishSession(AccountAuthenticatorResponse, String, Bundle)
* @hide
*/
@SystemApi
public Bundle startAddAccountSession(final AccountAuthenticatorResponse response, final String accountType, final String authTokenType, final String[] requiredFeatures, final Bundle options) throws NetworkErrorException {
new Thread(new Runnable() {
@Override
public void run() {
Bundle sessionBundle = new Bundle();
sessionBundle.putString(KEY_AUTH_TOKEN_TYPE, authTokenType);
sessionBundle.putStringArray(KEY_REQUIRED_FEATURES, requiredFeatures);
sessionBundle.putBundle(KEY_OPTIONS, options);
Bundle result = new Bundle();
result.putBundle(AccountManager.KEY_ACCOUNT_SESSION_BUNDLE, sessionBundle);
response.onResult(result);
}
}).start();
return null;
}
use of android.annotation.SystemApi in project platform_frameworks_base by android.
the class AbstractAccountAuthenticator method finishSession.
/**
* Finishes the session started by #startAddAccountSession or
* #startUpdateCredentials by installing the account to device with
* AccountManager, or updating the local credentials. File I/O may be
* performed in this call.
* <p>
* Note: when overriding this method, {@link #startAddAccountSession} and
* {@link #startUpdateCredentialsSession} should be overridden too.
* </p>
*
* @param response to send the result back to the AccountManager, will never
* be null
* @param accountType the type of account to authenticate with, will never
* be null
* @param sessionBundle a bundle of session data created by
* {@link #startAddAccountSession} used for adding account to
* device, or by {@link #startUpdateCredentialsSession} used for
* updating local credentials.
* @return a Bundle result or null if the result is to be returned via the
* response. The result will contain either:
* <ul>
* <li>{@link AccountManager#KEY_INTENT}, or
* <li>{@link AccountManager#KEY_ACCOUNT_NAME} and
* {@link AccountManager#KEY_ACCOUNT_TYPE} of the account that was
* added or local credentials were updated, or
* <li>{@link AccountManager#KEY_ERROR_CODE} and
* {@link AccountManager#KEY_ERROR_MESSAGE} to indicate an error
* </ul>
* @throws NetworkErrorException if the authenticator could not honor the request due to a
* network error
* @see #startAddAccountSession and #startUpdateCredentialsSession
* @hide
*/
@SystemApi
public Bundle finishSession(final AccountAuthenticatorResponse response, final String accountType, final Bundle sessionBundle) throws NetworkErrorException {
if (TextUtils.isEmpty(accountType)) {
Log.e(TAG, "Account type cannot be empty.");
Bundle result = new Bundle();
result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_BAD_ARGUMENTS);
result.putString(AccountManager.KEY_ERROR_MESSAGE, "accountType cannot be empty.");
return result;
}
if (sessionBundle == null) {
Log.e(TAG, "Session bundle cannot be null.");
Bundle result = new Bundle();
result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_BAD_ARGUMENTS);
result.putString(AccountManager.KEY_ERROR_MESSAGE, "sessionBundle cannot be null.");
return result;
}
if (!sessionBundle.containsKey(KEY_AUTH_TOKEN_TYPE)) {
// We cannot handle Session bundle not created by default startAddAccountSession(...)
// nor startUpdateCredentialsSession(...) implementation. Return error.
Bundle result = new Bundle();
result.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
result.putString(AccountManager.KEY_ERROR_MESSAGE, "Authenticator must override finishSession if startAddAccountSession" + " or startUpdateCredentialsSession is overridden.");
response.onResult(result);
return result;
}
String authTokenType = sessionBundle.getString(KEY_AUTH_TOKEN_TYPE);
Bundle options = sessionBundle.getBundle(KEY_OPTIONS);
String[] requiredFeatures = sessionBundle.getStringArray(KEY_REQUIRED_FEATURES);
Account account = sessionBundle.getParcelable(KEY_ACCOUNT);
boolean containsKeyAccount = sessionBundle.containsKey(KEY_ACCOUNT);
// Actual options passed to add account or update credentials flow.
Bundle sessionOptions = new Bundle(sessionBundle);
// Remove redundant extras in session bundle before passing it to addAccount(...) or
// updateCredentials(...).
sessionOptions.remove(KEY_AUTH_TOKEN_TYPE);
sessionOptions.remove(KEY_REQUIRED_FEATURES);
sessionOptions.remove(KEY_OPTIONS);
sessionOptions.remove(KEY_ACCOUNT);
if (options != null) {
// options may contains old system info such as
// AccountManager.KEY_ANDROID_PACKAGE_NAME required by the add account flow or update
// credentials flow, we should replace with the new values of the current call added
// to sessionBundle by AccountManager or AccountManagerService.
options.putAll(sessionOptions);
sessionOptions = options;
}
// contain KEY_ACCOUNT.
if (containsKeyAccount) {
return updateCredentials(response, account, authTokenType, options);
}
// Otherwise, session bundle was created by startAddAccountSession default implementation.
return addAccount(response, accountType, authTokenType, requiredFeatures, sessionOptions);
}
use of android.annotation.SystemApi in project platform_frameworks_base by android.
the class CarrierConfigManager method updateConfigForPhoneId.
/**
* Request the carrier config loader to update the cofig for phoneId.
* <p>
* Depending on simState, the config may be cleared or loaded from config app. This is only used
* by SubscriptionInfoUpdater.
* </p>
*
* @hide
*/
@SystemApi
public void updateConfigForPhoneId(int phoneId, String simState) {
try {
ICarrierConfigLoader loader = getICarrierConfigLoader();
if (loader == null) {
Rlog.w(TAG, "Error updating config for phoneId=" + phoneId + " ICarrierConfigLoader is null");
return;
}
loader.updateConfigForPhoneId(phoneId, simState);
} catch (RemoteException ex) {
Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString());
}
}
Aggregations