diff options
| author | 2020-03-25 08:05:49 -0700 | |
|---|---|---|
| committer | 2020-03-27 10:19:09 -0700 | |
| commit | 900e1f11eb436267d9373d0b94aaa30823f8dbc0 (patch) | |
| tree | 13f18a1fe4a698b979eaf3f41c4d5fa85fdec8d3 | |
| parent | a8a6e27153cf5e695553d3c84239dded11fe7191 (diff) | |
Have Telecom service notify AudioService of RTT call state.
Add AudioManager#setRttEnabled() so that Telecom service can call it
when RTT call state has changed.
Bug: 147037345
Test: Force installed Gboard 8.3.6 and verified voice typing works in
simulated RTT call and simulated RTT upgrade call.
Change-Id: I1ea3dccdfed145e55b1b1cd516b40a33ac7984d9
| -rw-r--r-- | media/java/android/media/AudioManager.java | 14 | ||||
| -rw-r--r-- | media/java/android/media/IAudioService.aidl | 2 | ||||
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 37 |
3 files changed, 42 insertions, 11 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index ba8f7e60e268..7408987e465e 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -5987,6 +5987,20 @@ public class AudioManager { } } + /** + * Set whether or not there is an active RTT call. + * This method should be called by Telecom service. + * @hide + * TODO: make this a @SystemApi + */ + public static void setRttEnabled(boolean rttEnabled) { + try { + getService().setRttEnabled(rttEnabled); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + //--------------------------------------------------------- // Inner classes //-------------------- diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index 5f320cd052c9..453a5d8a5b7e 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -292,6 +292,8 @@ interface IAudioService { oneway void unregisterStrategyPreferredDeviceDispatcher( IStrategyPreferredDeviceDispatcher dispatcher); + oneway void setRttEnabled(in boolean rttEnabled); + // WARNING: read warning at top of file, new methods that need to be used by native // code via IAudioManager.h need to be added to the top section. } diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 94675ab7d795..8bce5043ad34 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -634,6 +634,9 @@ public class AudioService extends IAudioService.Stub } }; + @GuardedBy("mSettingsLock") + private boolean mRttEnabled = false; + /////////////////////////////////////////////////////////////////////////// // Construction /////////////////////////////////////////////////////////////////////////// @@ -1053,7 +1056,7 @@ public class AudioService extends IAudioService.Stub sendEncodedSurroundMode(mContentResolver, "onAudioServerDied"); sendEnabledSurroundFormats(mContentResolver, true); updateAssistantUId(true); - updateRttEanbled(mContentResolver); + AudioSystem.setRttEnabled(mRttEnabled); } synchronized (mAccessibilityServiceUidsLock) { AudioSystem.setA11yServicesUids(mAccessibilityServiceUids); @@ -1598,12 +1601,6 @@ public class AudioService extends IAudioService.Stub } } - private void updateRttEanbled(ContentResolver cr) { - final boolean rttEnabled = Settings.Secure.getIntForUser(cr, - Settings.Secure.RTT_CALLING_MODE, 0, UserHandle.USER_CURRENT) != 0; - AudioSystem.setRttEnabled(rttEnabled); - } - private void readPersistedSettings() { final ContentResolver cr = mContentResolver; @@ -1648,7 +1645,7 @@ public class AudioService extends IAudioService.Stub sendEncodedSurroundMode(cr, "readPersistedSettings"); sendEnabledSurroundFormats(cr, true); updateAssistantUId(true); - updateRttEanbled(cr); + AudioSystem.setRttEnabled(mRttEnabled); } mMuteAffectedStreams = System.getIntForUser(cr, @@ -3684,6 +3681,27 @@ public class AudioService extends IAudioService.Stub return mIsCallScreeningModeSupported; } + /** @see AudioManager#setRttEnabled() */ + @Override + public void setRttEnabled(boolean rttEnabled) { + if (mContext.checkCallingOrSelfPermission( + android.Manifest.permission.MODIFY_PHONE_STATE) + != PackageManager.PERMISSION_GRANTED) { + Log.w(TAG, "MODIFY_PHONE_STATE Permission Denial: setRttEnabled from pid=" + + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); + return; + } + synchronized (mSettingsLock) { + mRttEnabled = rttEnabled; + final long identity = Binder.clearCallingIdentity(); + try { + AudioSystem.setRttEnabled(rttEnabled); + } finally { + Binder.restoreCallingIdentity(identity); + } + } + } + //========================================================================================== // Sound Effects //========================================================================================== @@ -5825,8 +5843,6 @@ public class AudioService extends IAudioService.Stub mContentResolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.VOICE_INTERACTION_SERVICE), false, this); - mContentResolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.RTT_CALLING_MODE), false, this); } @Override @@ -5850,7 +5866,6 @@ public class AudioService extends IAudioService.Stub updateEncodedSurroundOutput(); sendEnabledSurroundFormats(mContentResolver, mSurroundModeChanged); updateAssistantUId(false); - updateRttEanbled(mContentResolver); } } |