Loading flags/telecom_call_flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -8,3 +8,10 @@ flag { description: "verify connection service callbacks via a transaction" bug: "309541257" } flag { name: "cache_call_audio_callbacks" namespace: "telecom" description: "cache call audio callbacks if the service is not available and execute when set" bug: "321369729" } No newline at end of file src/com/android/server/telecom/CachedAvailableEndpointsChange.java 0 → 100644 +70 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; import android.telecom.CallEndpoint; import java.util.Objects; import java.util.Set; public class CachedAvailableEndpointsChange implements CachedCallback { public static final String ID = CachedAvailableEndpointsChange.class.getSimpleName(); Set<CallEndpoint> mAvailableEndpoints; public Set<CallEndpoint> getAvailableEndpoints() { return mAvailableEndpoints; } public CachedAvailableEndpointsChange(Set<CallEndpoint> endpoints) { mAvailableEndpoints = endpoints; } @Override public void executeCallback(CallSourceService service, Call call) { service.onAvailableCallEndpointsChanged(call, mAvailableEndpoints); } @Override public String getCallbackId() { return ID; } @Override public int hashCode() { return Objects.hashCode(mAvailableEndpoints); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof CachedAvailableEndpointsChange other)) { return false; } if (mAvailableEndpoints.size() != other.mAvailableEndpoints.size()) { return false; } for (CallEndpoint e : mAvailableEndpoints) { if (!other.getAvailableEndpoints().contains(e)) { return false; } } return true; } } src/com/android/server/telecom/CachedCallback.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; /** * Any android.telecom.Call service (e.g. ConnectionService, TransactionalService) that declares * a {@link CallSourceService} should implement this interface in order to cache the callback. * The callback will be executed once the service is set. */ public interface CachedCallback { /** * This method executes the callback that was cached because the service was not available * at the time the callback was ready. * * @param service that was recently set (e.g. ConnectionService) * @param call that had a null service at the time the callback was ready. The service is now * non-null in the call and can be executed/ */ void executeCallback(CallSourceService service, Call call); /** * This method is helpful for caching the callbacks. If the callback is called multiple times * while the service is not set, ONLY the last callback should be sent to the client since the * last callback is the most relevant * * @return the callback id that is used in a map to only store the last callback value */ String getCallbackId(); } src/com/android/server/telecom/CachedCurrentEndpointChange.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; import android.telecom.CallEndpoint; import java.util.Objects; public class CachedCurrentEndpointChange implements CachedCallback { public static final String ID = CachedCurrentEndpointChange.class.getSimpleName(); CallEndpoint mCurrentCallEndpoint; public CallEndpoint getCurrentCallEndpoint() { return mCurrentCallEndpoint; } public CachedCurrentEndpointChange(CallEndpoint callEndpoint) { mCurrentCallEndpoint = callEndpoint; } @Override public void executeCallback(CallSourceService service, Call call) { service.onCallEndpointChanged(call, mCurrentCallEndpoint); } @Override public String getCallbackId() { return ID; } @Override public int hashCode() { return Objects.hashCode(mCurrentCallEndpoint); } @Override public boolean equals(Object obj){ if (obj == null) { return false; } if (!(obj instanceof CachedCurrentEndpointChange other)) { return false; } return mCurrentCallEndpoint.equals(other.mCurrentCallEndpoint); } } src/com/android/server/telecom/CachedMuteStateChange.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; public class CachedMuteStateChange implements CachedCallback { public static final String ID = CachedMuteStateChange.class.getSimpleName(); boolean mIsMuted; public boolean isMuted() { return mIsMuted; } public CachedMuteStateChange(boolean isMuted) { mIsMuted = isMuted; } @Override public void executeCallback(CallSourceService service, Call call) { service.onMuteStateChanged(call, mIsMuted); } @Override public String getCallbackId() { return ID; } @Override public int hashCode() { return Boolean.hashCode(mIsMuted); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof CachedMuteStateChange other)) { return false; } return mIsMuted == other.mIsMuted; } } Loading
flags/telecom_call_flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -8,3 +8,10 @@ flag { description: "verify connection service callbacks via a transaction" bug: "309541257" } flag { name: "cache_call_audio_callbacks" namespace: "telecom" description: "cache call audio callbacks if the service is not available and execute when set" bug: "321369729" } No newline at end of file
src/com/android/server/telecom/CachedAvailableEndpointsChange.java 0 → 100644 +70 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; import android.telecom.CallEndpoint; import java.util.Objects; import java.util.Set; public class CachedAvailableEndpointsChange implements CachedCallback { public static final String ID = CachedAvailableEndpointsChange.class.getSimpleName(); Set<CallEndpoint> mAvailableEndpoints; public Set<CallEndpoint> getAvailableEndpoints() { return mAvailableEndpoints; } public CachedAvailableEndpointsChange(Set<CallEndpoint> endpoints) { mAvailableEndpoints = endpoints; } @Override public void executeCallback(CallSourceService service, Call call) { service.onAvailableCallEndpointsChanged(call, mAvailableEndpoints); } @Override public String getCallbackId() { return ID; } @Override public int hashCode() { return Objects.hashCode(mAvailableEndpoints); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof CachedAvailableEndpointsChange other)) { return false; } if (mAvailableEndpoints.size() != other.mAvailableEndpoints.size()) { return false; } for (CallEndpoint e : mAvailableEndpoints) { if (!other.getAvailableEndpoints().contains(e)) { return false; } } return true; } }
src/com/android/server/telecom/CachedCallback.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; /** * Any android.telecom.Call service (e.g. ConnectionService, TransactionalService) that declares * a {@link CallSourceService} should implement this interface in order to cache the callback. * The callback will be executed once the service is set. */ public interface CachedCallback { /** * This method executes the callback that was cached because the service was not available * at the time the callback was ready. * * @param service that was recently set (e.g. ConnectionService) * @param call that had a null service at the time the callback was ready. The service is now * non-null in the call and can be executed/ */ void executeCallback(CallSourceService service, Call call); /** * This method is helpful for caching the callbacks. If the callback is called multiple times * while the service is not set, ONLY the last callback should be sent to the client since the * last callback is the most relevant * * @return the callback id that is used in a map to only store the last callback value */ String getCallbackId(); }
src/com/android/server/telecom/CachedCurrentEndpointChange.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; import android.telecom.CallEndpoint; import java.util.Objects; public class CachedCurrentEndpointChange implements CachedCallback { public static final String ID = CachedCurrentEndpointChange.class.getSimpleName(); CallEndpoint mCurrentCallEndpoint; public CallEndpoint getCurrentCallEndpoint() { return mCurrentCallEndpoint; } public CachedCurrentEndpointChange(CallEndpoint callEndpoint) { mCurrentCallEndpoint = callEndpoint; } @Override public void executeCallback(CallSourceService service, Call call) { service.onCallEndpointChanged(call, mCurrentCallEndpoint); } @Override public String getCallbackId() { return ID; } @Override public int hashCode() { return Objects.hashCode(mCurrentCallEndpoint); } @Override public boolean equals(Object obj){ if (obj == null) { return false; } if (!(obj instanceof CachedCurrentEndpointChange other)) { return false; } return mCurrentCallEndpoint.equals(other.mCurrentCallEndpoint); } }
src/com/android/server/telecom/CachedMuteStateChange.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.telecom; public class CachedMuteStateChange implements CachedCallback { public static final String ID = CachedMuteStateChange.class.getSimpleName(); boolean mIsMuted; public boolean isMuted() { return mIsMuted; } public CachedMuteStateChange(boolean isMuted) { mIsMuted = isMuted; } @Override public void executeCallback(CallSourceService service, Call call) { service.onMuteStateChanged(call, mIsMuted); } @Override public String getCallbackId() { return ID; } @Override public int hashCode() { return Boolean.hashCode(mIsMuted); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof CachedMuteStateChange other)) { return false; } return mIsMuted == other.mIsMuted; } }