Commit c1b4a55f authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Cleanup to remove misused CallGroup concept." into lmp-mr1-dev

parents abbd7880 9bd5ca59
This diff is collapsed.
/*
* Copyright (c) 2013 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.ims;
import java.util.ArrayList;
import com.android.ims.internal.ICallGroup;
import com.android.ims.internal.ICall;
/**
* Manages all IMS calls which are established hereafter the initial 1-to-1 call is established.
* It's for providing the dummy calls which are disconnected with the IMS network after
* merged or extended to the conference.
*
* @hide
*/
public class ImsCallGroup implements ICallGroup {
private Object mLockObj = new Object();
private ImsCall mOwner;
private ImsCall mNeutralReferrer;
private ArrayList<ICall> mReferrers = new ArrayList<ICall>();
public ImsCallGroup() {
}
@Override
public ICall getNeutralReferrer() {
synchronized(mLockObj) {
return mNeutralReferrer;
}
}
@Override
public ICall getOwner() {
synchronized(mLockObj) {
return mOwner;
}
}
@Override
public ArrayList<ICall> getReferrers() {
synchronized(mLockObj) {
return mReferrers;
}
}
@Override
public boolean hasReferrer() {
synchronized(mLockObj) {
return !mReferrers.isEmpty();
}
}
@Override
public boolean isOwner(ICall call) {
ImsCall owner;
synchronized(mLockObj) {
owner = mOwner;
}
if ((call == null) || (owner == null)) {
return false;
}
if (!(call instanceof ImsCall)) {
return false;
}
return isSameCall(owner, (ImsCall)call);
}
@Override
public boolean isReferrer(ICall call) {
if (call == null) {
return false;
}
if (!(call instanceof ImsCall)) {
return false;
}
synchronized(mLockObj) {
for (ICall c : mReferrers) {
if ((c != null) && isSameCall((ImsCall)c, (ImsCall)call)) {
return true;
}
}
}
return false;
}
@Override
public void addReferrer(ICall call) {
if (call == null) {
return;
}
if (!(call instanceof ImsCall)) {
return;
}
// If the call is already present, ignore it
if (isReferrer(call)) {
return;
}
synchronized(mLockObj) {
mReferrers.add(call);
}
}
@Override
public void removeReferrer(ICall call) {
if (call == null) {
return;
}
if (!(call instanceof ImsCall)) {
return;
}
synchronized(mLockObj) {
mReferrers.remove(call);
}
}
@Override
public void setNeutralReferrer(ICall call) {
if ((call != null) && !(call instanceof ImsCall)) {
return;
}
synchronized(mLockObj) {
mNeutralReferrer = (ImsCall)call;
}
}
@Override
public void setOwner(ICall call) {
if ((call != null) && !(call instanceof ImsCall)) {
return;
}
synchronized(mLockObj) {
mOwner = (ImsCall)call;
}
}
@Override
public ICall getReferrer(String name) {
if ((name == null) || (name.isEmpty())) {
return null;
}
ArrayList<ICall> referrers = getReferrers();
if (referrers == null) {
return null;
}
for (ICall call : referrers) {
if ((call != null) && call.checkIfRemoteUserIsSame(name)) {
return call;
}
}
return null;
}
private boolean isSameCall(ImsCall call1, ImsCall call2) {
if ((call1 == null) || (call2 == null)) {
return false;
}
return call1.equalsTo(call2);
}
}
/*
* Copyright (c) 2013 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.ims.internal;
import java.util.ArrayList;
/**
* Wrapper class which has an ICallGroup interface.
*
* @hide
*/
public class CallGroup {
private final ICallGroup mCallGroup;
public CallGroup(ICallGroup callGroup) {
mCallGroup = callGroup;
}
public ICall getNeutralReferrer() {
if (mCallGroup == null) {
return null;
}
return mCallGroup.getNeutralReferrer();
}
public ICall getOwner() {
if (mCallGroup == null) {
return null;
}
return mCallGroup.getOwner();
}
public ICall getReferrer(String name) {
if (mCallGroup == null) {
return null;
}
return mCallGroup.getReferrer(name);
}
public ArrayList<ICall> getReferrers() {
if (mCallGroup == null) {
return null;
}
return mCallGroup.getReferrers();
}
public boolean hasReferrer() {
if (mCallGroup == null) {
return false;
}
return mCallGroup.hasReferrer();
}
public boolean isOwner(ICall call) {
if (mCallGroup == null) {
return false;
}
return mCallGroup.isOwner(call);
}
public boolean isReferrer(ICall call) {
if (mCallGroup == null) {
return false;
}
return mCallGroup.isReferrer(call);
}
public void addReferrer(ICall call) {
if (mCallGroup == null) {
return;
}
mCallGroup.addReferrer(call);
}
public void removeReferrer(ICall call) {
if (mCallGroup == null) {
return;
}
mCallGroup.removeReferrer(call);
}
public void setNeutralReferrer(ICall call) {
if (mCallGroup == null) {
return;
}
mCallGroup.setNeutralReferrer(call);
}
public void setOwner(ICall call) {
if (mCallGroup == null) {
return;
}
mCallGroup.setOwner(call);
}
}
/*
* Copyright (c) 2013 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.ims.internal;
import java.util.ArrayList;
/**
* Manages CallGroup objects.
*
* @hide
*/
public class CallGroupManager {
private static CallGroupManager mCallGroupManager = new CallGroupManager();
private Object mLockObj = new Object();
private ArrayList<CallGroup> mCallGroups = new ArrayList<CallGroup>();
private CallGroupManager() {
}
public static CallGroupManager getInstance() {
return mCallGroupManager;
}
public CallGroup createCallGroup(ICallGroup callGroup) {
CallGroup cg = new CallGroup(callGroup);
synchronized(mLockObj) {
mCallGroups.add(cg);
}
return cg;
}
public void destroyCallGroup(CallGroup cg) {
if (cg == null) {
return;
}
synchronized(mLockObj) {
mCallGroups.remove(cg);
}
}
public CallGroup getCallGroupAsOwner(ICall call) {
synchronized(mLockObj) {
for (CallGroup cg : mCallGroups) {
if (cg.isOwner(call)) {
return cg;
}
}
}
return null;
}
public CallGroup getCallGroupAsReferrer(ICall call) {
synchronized(mLockObj) {
for (CallGroup cg : mCallGroups) {
if (cg.isReferrer(call)) {
return cg;
}
}
}
return null;
}
}
/*
* Copyright (c) 2013 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.ims.internal;
import java.util.ArrayList;
/**
* Provides the interface to manage all calls which are established
* hereafter the initial 1-to-1 call is established.
* It's for providing the dummy calls which are disconnected with the IMS network after
* merged or extended to the conference.
*
* @hide
*/
public interface ICallGroup {
/**
* Gets the neutral referrer call object of this group.
*
* @return the neutral referrer call object
*/
public ICall getNeutralReferrer();
/**
* Gets the owner call object of this group.
*
* @return the owner call object
*/
public ICall getOwner();
/**
* Gets the referrer call object which is equal to the specified name.
*
* @return the referrer call object
*/
public ICall getReferrer(String name);
/**
* Gets the referrer call objects of this group.
*
* @return the referrer call objects
*/
public ArrayList<ICall> getReferrers();
/**
* Checks if the call group has a referrer.
*
* @return true if the call group has a referrer; false otherwise.
*/
public boolean hasReferrer();
/**
* Checks if the specified call object is owner of this group.
*
* @param call the call object to be checked if it is an owner of this group
* @return true if the specified call object is an owner; false otherwise
*/
public boolean isOwner(ICall call);
/**
* Checks if the specified call object is a referrer of this group.
*
* @param call the call object to be checked if it is a referrer of this group
* @return true if the specified call object is a referrer; false otherwise
*/
public boolean isReferrer(ICall call);
/**
* Adds the call object to this call group.
*
* @param call the call object to be added to this group
*/
public void addReferrer(ICall call);
/**
* Removes the call object from this call group.
*
* @param call the call object to be removed from this group
*/
public void removeReferrer(ICall call);
/**
* Sets the referrer call object in the neutral state while the operation is in progress.
*
* @param call the call object to be added to this group if the operation is succeeded.
*/
public void setNeutralReferrer(ICall call);
/**
* Sets the call object as the owner of this call group.
* If the owner call object is already present, this method overwrites the existing owner
* call object.
*
* @param call the call object to be added to this group as owner
*/
public void setOwner(ICall call);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment