Merge "Allow DEFAULT_INPUT_METHOD to capture audio during RTT call" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
28fa262049
@@ -2266,6 +2266,11 @@ android_media_AudioSystem_setA11yServicesUids(JNIEnv *env, jobject thiz, jintArr
|
|||||||
return (jint)nativeToJavaStatus(status);
|
return (jint)nativeToJavaStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static jint android_media_AudioSystem_setCurrentImeUid(JNIEnv *env, jobject thiz, jint uid) {
|
||||||
|
status_t status = AudioSystem::setCurrentImeUid(uid);
|
||||||
|
return (jint)nativeToJavaStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
static jboolean
|
static jboolean
|
||||||
android_media_AudioSystem_isHapticPlaybackSupported(JNIEnv *env, jobject thiz)
|
android_media_AudioSystem_isHapticPlaybackSupported(JNIEnv *env, jobject thiz)
|
||||||
{
|
{
|
||||||
@@ -2527,7 +2532,8 @@ static const JNINativeMethod gMethods[] =
|
|||||||
{"setUserIdDeviceAffinities", "(I[I[Ljava/lang/String;)I",
|
{"setUserIdDeviceAffinities", "(I[I[Ljava/lang/String;)I",
|
||||||
(void *)android_media_AudioSystem_setUserIdDeviceAffinities},
|
(void *)android_media_AudioSystem_setUserIdDeviceAffinities},
|
||||||
{"removeUserIdDeviceAffinities", "(I)I",
|
{"removeUserIdDeviceAffinities", "(I)I",
|
||||||
(void *)android_media_AudioSystem_removeUserIdDeviceAffinities}};
|
(void *)android_media_AudioSystem_removeUserIdDeviceAffinities},
|
||||||
|
{"setCurrentImeUid", "(I)I", (void *)android_media_AudioSystem_setCurrentImeUid}};
|
||||||
|
|
||||||
static const JNINativeMethod gEventHandlerMethods[] = {
|
static const JNINativeMethod gEventHandlerMethods[] = {
|
||||||
{"native_setup",
|
{"native_setup",
|
||||||
|
|||||||
@@ -1233,6 +1233,11 @@ public class AudioSystem
|
|||||||
* Communicate UIDs of active accessibility services to audio policy service.
|
* Communicate UIDs of active accessibility services to audio policy service.
|
||||||
*/
|
*/
|
||||||
public static native int setA11yServicesUids(int[] uids);
|
public static native int setA11yServicesUids(int[] uids);
|
||||||
|
/**
|
||||||
|
* Communicate UID of current InputMethodService to audio policy service.
|
||||||
|
*/
|
||||||
|
public static native int setCurrentImeUid(int uid);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AudioManager#isHapticPlaybackSupported()
|
* @see AudioManager#isHapticPlaybackSupported()
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import android.content.IntentFilter;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManagerInternal;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -576,6 +577,9 @@ public class AudioService extends IAudioService.Stub
|
|||||||
@GuardedBy("mSettingsLock")
|
@GuardedBy("mSettingsLock")
|
||||||
private int mAssistantUid;
|
private int mAssistantUid;
|
||||||
|
|
||||||
|
@GuardedBy("mSettingsLock")
|
||||||
|
private int mCurrentImeUid;
|
||||||
|
|
||||||
private final Object mSupportedSystemUsagesLock = new Object();
|
private final Object mSupportedSystemUsagesLock = new Object();
|
||||||
@GuardedBy("mSupportedSystemUsagesLock")
|
@GuardedBy("mSupportedSystemUsagesLock")
|
||||||
private @AttributeSystemUsage int[] mSupportedSystemUsages =
|
private @AttributeSystemUsage int[] mSupportedSystemUsages =
|
||||||
@@ -1056,6 +1060,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
sendEncodedSurroundMode(mContentResolver, "onAudioServerDied");
|
sendEncodedSurroundMode(mContentResolver, "onAudioServerDied");
|
||||||
sendEnabledSurroundFormats(mContentResolver, true);
|
sendEnabledSurroundFormats(mContentResolver, true);
|
||||||
updateAssistantUId(true);
|
updateAssistantUId(true);
|
||||||
|
updateCurrentImeUid(true);
|
||||||
AudioSystem.setRttEnabled(mRttEnabled);
|
AudioSystem.setRttEnabled(mRttEnabled);
|
||||||
}
|
}
|
||||||
synchronized (mAccessibilityServiceUidsLock) {
|
synchronized (mAccessibilityServiceUidsLock) {
|
||||||
@@ -1601,6 +1606,37 @@ public class AudioService extends IAudioService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GuardedBy("mSettingsLock")
|
||||||
|
private void updateCurrentImeUid(boolean forceUpdate) {
|
||||||
|
String imeId = Settings.Secure.getStringForUser(
|
||||||
|
mContentResolver,
|
||||||
|
Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT);
|
||||||
|
if (TextUtils.isEmpty(imeId)) {
|
||||||
|
Log.e(TAG, "updateCurrentImeUid() could not find current IME");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ComponentName componentName = ComponentName.unflattenFromString(imeId);
|
||||||
|
if (componentName == null) {
|
||||||
|
Log.e(TAG, "updateCurrentImeUid() got invalid service name for "
|
||||||
|
+ Settings.Secure.DEFAULT_INPUT_METHOD + ": " + imeId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String packageName = componentName.getPackageName();
|
||||||
|
int currentUserId = LocalServices.getService(ActivityManagerInternal.class)
|
||||||
|
.getCurrentUserId();
|
||||||
|
int currentImeUid = LocalServices.getService(PackageManagerInternal.class)
|
||||||
|
.getPackageUidInternal(packageName, 0 /* flags */, currentUserId);
|
||||||
|
if (currentImeUid < 0) {
|
||||||
|
Log.e(TAG, "updateCurrentImeUid() could not find UID for package: " + packageName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentImeUid != mCurrentImeUid || forceUpdate) {
|
||||||
|
AudioSystem.setCurrentImeUid(currentImeUid);
|
||||||
|
mCurrentImeUid = currentImeUid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void readPersistedSettings() {
|
private void readPersistedSettings() {
|
||||||
final ContentResolver cr = mContentResolver;
|
final ContentResolver cr = mContentResolver;
|
||||||
|
|
||||||
@@ -1645,6 +1681,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
sendEncodedSurroundMode(cr, "readPersistedSettings");
|
sendEncodedSurroundMode(cr, "readPersistedSettings");
|
||||||
sendEnabledSurroundFormats(cr, true);
|
sendEnabledSurroundFormats(cr, true);
|
||||||
updateAssistantUId(true);
|
updateAssistantUId(true);
|
||||||
|
updateCurrentImeUid(true);
|
||||||
AudioSystem.setRttEnabled(mRttEnabled);
|
AudioSystem.setRttEnabled(mRttEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5843,6 +5880,8 @@ public class AudioService extends IAudioService.Stub
|
|||||||
|
|
||||||
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(
|
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||||
Settings.Secure.VOICE_INTERACTION_SERVICE), false, this);
|
Settings.Secure.VOICE_INTERACTION_SERVICE), false, this);
|
||||||
|
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||||
|
Settings.Secure.DEFAULT_INPUT_METHOD), false, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -5866,6 +5905,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
updateEncodedSurroundOutput();
|
updateEncodedSurroundOutput();
|
||||||
sendEnabledSurroundFormats(mContentResolver, mSurroundModeChanged);
|
sendEnabledSurroundFormats(mContentResolver, mSurroundModeChanged);
|
||||||
updateAssistantUId(false);
|
updateAssistantUId(false);
|
||||||
|
updateCurrentImeUid(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user