Merge "Allow DEFAULT_INPUT_METHOD to capture audio during RTT call" into rvc-dev am: 28fa262049
Change-Id: I2eef679ff3d4b83796a0ed60c75feeec93873318
This commit is contained in:
@@ -2266,6 +2266,11 @@ android_media_AudioSystem_setA11yServicesUids(JNIEnv *env, jobject thiz, jintArr
|
||||
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
|
||||
android_media_AudioSystem_isHapticPlaybackSupported(JNIEnv *env, jobject thiz)
|
||||
{
|
||||
@@ -2527,7 +2532,8 @@ static const JNINativeMethod gMethods[] =
|
||||
{"setUserIdDeviceAffinities", "(I[I[Ljava/lang/String;)I",
|
||||
(void *)android_media_AudioSystem_setUserIdDeviceAffinities},
|
||||
{"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[] = {
|
||||
{"native_setup",
|
||||
|
||||
@@ -1233,6 +1233,11 @@ public class AudioSystem
|
||||
* Communicate UIDs of active accessibility services to audio policy service.
|
||||
*/
|
||||
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()
|
||||
|
||||
@@ -52,6 +52,7 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Configuration;
|
||||
@@ -576,6 +577,9 @@ public class AudioService extends IAudioService.Stub
|
||||
@GuardedBy("mSettingsLock")
|
||||
private int mAssistantUid;
|
||||
|
||||
@GuardedBy("mSettingsLock")
|
||||
private int mCurrentImeUid;
|
||||
|
||||
private final Object mSupportedSystemUsagesLock = new Object();
|
||||
@GuardedBy("mSupportedSystemUsagesLock")
|
||||
private @AttributeSystemUsage int[] mSupportedSystemUsages =
|
||||
@@ -1056,6 +1060,7 @@ public class AudioService extends IAudioService.Stub
|
||||
sendEncodedSurroundMode(mContentResolver, "onAudioServerDied");
|
||||
sendEnabledSurroundFormats(mContentResolver, true);
|
||||
updateAssistantUId(true);
|
||||
updateCurrentImeUid(true);
|
||||
AudioSystem.setRttEnabled(mRttEnabled);
|
||||
}
|
||||
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() {
|
||||
final ContentResolver cr = mContentResolver;
|
||||
|
||||
@@ -1645,6 +1681,7 @@ public class AudioService extends IAudioService.Stub
|
||||
sendEncodedSurroundMode(cr, "readPersistedSettings");
|
||||
sendEnabledSurroundFormats(cr, true);
|
||||
updateAssistantUId(true);
|
||||
updateCurrentImeUid(true);
|
||||
AudioSystem.setRttEnabled(mRttEnabled);
|
||||
}
|
||||
|
||||
@@ -5843,6 +5880,8 @@ 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.DEFAULT_INPUT_METHOD), false, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -5866,6 +5905,7 @@ public class AudioService extends IAudioService.Stub
|
||||
updateEncodedSurroundOutput();
|
||||
sendEnabledSurroundFormats(mContentResolver, mSurroundModeChanged);
|
||||
updateAssistantUId(false);
|
||||
updateCurrentImeUid(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user