...
 
Commits (1)
......@@ -96,7 +96,7 @@ public class LinphoneManager implements SensorEventListener {
private final SensorManager mSensorManager;
private final Sensor mProximity;
private final MediaScanner mMediaScanner;
private Timer mTimer;
private Timer mTimer, mAutoAnswerTimer;
private final Handler mHandler = new Handler();
private final LinphonePreferences mPrefs;
......@@ -109,6 +109,7 @@ public class LinphoneManager implements SensorEventListener {
private boolean mCallGsmON;
private boolean mProximitySensingEnabled;
private boolean mHasLastCallSasBeenRejected;
private Runnable mIterateRunnable;
public LinphoneManager(Context c) {
mExited = false;
......@@ -231,8 +232,8 @@ public class LinphoneManager implements SensorEventListener {
}
}
};
mTimer = new Timer("Auto answer");
mTimer.schedule(lTask, mPrefs.getAutoAnswerTime());
mAutoAnswerTimer = new Timer("Auto answer");
mAutoAnswerTimer.schedule(lTask, mPrefs.getAutoAnswerTime());
} else if (state == State.End || state == State.Error) {
if (mCore.getCallsNb() == 0) {
// Disabling proximity sensor
......@@ -423,6 +424,9 @@ public class LinphoneManager implements SensorEventListener {
mAudioManager.destroy();
try {
if (mAutoAnswerTimer != null) {
mAutoAnswerTimer.cancel();
}
mTimer.cancel();
destroyCore();
} catch (RuntimeException e) {
......@@ -449,19 +453,20 @@ public class LinphoneManager implements SensorEventListener {
}
mCore.start();
mIterateRunnable =
new Runnable() {
@Override
public void run() {
if (mCore != null) {
mCore.iterate();
}
}
};
TimerTask lTask =
new TimerTask() {
@Override
public void run() {
LinphoneUtils.dispatchOnUIThread(
new Runnable() {
@Override
public void run() {
if (mCore != null) {
mCore.iterate();
}
}
});
LinphoneUtils.dispatchOnUIThread(mIterateRunnable);
}
};
/*use schedule instead of scheduleAtFixedRate to avoid iterate from being call in burst after cpu wake up*/
......
......@@ -36,6 +36,8 @@ import java.util.Collection;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.call.CallActivity;
import org.linphone.call.CallIncomingActivity;
import org.linphone.call.CallOutgoingActivity;
import org.linphone.contacts.ContactsActivity;
import org.linphone.contacts.ContactsManager;
import org.linphone.core.Call;
......@@ -184,7 +186,33 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(DialerActivity.this, CallActivity.class));
boolean incoming = false;
boolean outgoing = false;
Call[] calls = LinphoneManager.getCore().getCalls();
for (Call call : calls) {
Call.State state = call.getState();
switch (state) {
case IncomingEarlyMedia:
case IncomingReceived:
incoming = true;
break;
case OutgoingEarlyMedia:
case OutgoingInit:
case OutgoingProgress:
case OutgoingRinging:
outgoing = true;
break;
}
}
if (incoming) {
startActivity(new Intent(DialerActivity.this, CallIncomingActivity.class));
} else if (outgoing) {
startActivity(new Intent(DialerActivity.this, CallOutgoingActivity.class));
} else {
startActivity(new Intent(DialerActivity.this, CallActivity.class));
}
}
});
......
......@@ -34,7 +34,7 @@ import org.linphone.settings.LinphonePreferences;
/** Creates LinphoneService and wait until Core is ready to start main Activity */
public class LinphoneLauncherActivity extends Activity {
private Handler mHandler;
private final Handler mHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -47,8 +47,6 @@ public class LinphoneLauncherActivity extends Activity {
if (!getResources().getBoolean(R.bool.use_full_screen_image_splashscreen)) {
setContentView(R.layout.launch_screen);
} // Otherwise use drawable/launch_screen layer list up until first activity starts
mHandler = new Handler();
}
@Override
......
......@@ -84,7 +84,7 @@ public class CallActivity extends LinphoneGenericActivity
private static final int WRITE_EXTERNAL_STORAGE_FOR_RECORDING = 2;
private static final int CAMERA_TO_ACCEPT_UPDATE = 3;
private Handler mHandler = new Handler();
private final Handler mHandler = new Handler();
private Runnable mHideControlsRunnable =
new Runnable() {
@Override
......@@ -485,6 +485,7 @@ public class CallActivity extends LinphoneGenericActivity
core.setNativeVideoWindowId(null);
core.setNativePreviewWindowId(null);
}
if (mZoomHelper != null) {
mZoomHelper.destroy();
}
......
......@@ -58,7 +58,6 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
private Call mCall;
private CoreListenerStub mListener;
private boolean mAlreadyAcceptedOrDeniedCall;
private TextureView mVideoDisplay;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -74,7 +73,6 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
mName = findViewById(R.id.contact_name);
mNumber = findViewById(R.id.contact_number);
mVideoDisplay = findViewById(R.id.videoSurface);
CallIncomingAnswerButton mAccept = findViewById(R.id.answer_button);
CallIncomingDeclineButton mDecline = findViewById(R.id.decline_button);
......@@ -125,10 +123,13 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
public void onCallStateChanged(
Core core, Call call, State state, String message) {
if (call == mCall && State.End == state) {
mCall = null;
finish();
} else if (state == State.Connected) {
startActivity(
new Intent(CallIncomingActivity.this, CallActivity.class));
mCall = null;
finish();
}
}
};
......@@ -169,7 +170,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
if (LinphonePreferences.instance().acceptIncomingEarlyMedia()) {
if (mCall.getCurrentParams().videoEnabled()) {
findViewById(R.id.avatar_layout).setVisibility(View.GONE);
mCall.getCore().setNativeVideoWindowId(mVideoDisplay);
mCall.getCore().setNativeVideoWindowId(findViewById(R.id.videoSurface));
}
}
}
......@@ -186,6 +187,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
if (core != null) {
core.removeListener(mListener);
}
mCall = null;
super.onPause();
}
......@@ -194,6 +196,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
if (LinphoneService.isReady()
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
mCall.terminate();
mCall = null;
finish();
}
return super.onKeyDown(keyCode, event);
......@@ -218,6 +221,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
mAlreadyAcceptedOrDeniedCall = true;
mCall.terminate();
mCall = null;
finish();
}
......
......@@ -48,7 +48,7 @@ public class CallManager {
private BandwidthManager mBandwidthManager;
public CallManager(Context context) {
mContext = context;
mContext = context.getApplicationContext();
mBandwidthManager = new BandwidthManager();
}
......
......@@ -137,9 +137,12 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
} else if (state == State.Connected) {
startActivity(
new Intent(CallOutgoingActivity.this, CallActivity.class));
mCall = null;
finish();
}
if (LinphoneManager.getCore().getCallsNb() == 0) {
mCall = null;
finish();
}
}
......@@ -200,6 +203,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
if (core != null) {
core.removeListener(mListener);
}
mCall = null;
super.onPause();
}
......@@ -231,6 +235,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
if (LinphoneService.isReady()
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
mCall.terminate();
mCall = null;
finish();
}
return super.onKeyDown(keyCode, event);
......@@ -238,6 +243,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
private void decline() {
mCall.terminate();
mCall = null;
finish();
}
......
......@@ -24,8 +24,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import org.linphone.R;
import org.linphone.contacts.ContactsManager;
import org.linphone.contacts.LinphoneContact;
......@@ -34,19 +34,20 @@ import org.linphone.utils.LinphoneUtils;
import org.linphone.views.ContactAvatar;
public class CallStatsAdapter extends BaseExpandableListAdapter {
private final Context mContext;
private List<Call> mCalls;
private WeakReference<Context> mContext;
private ArrayList<Call> mCalls;
public CallStatsAdapter(Context mContext) {
this.mContext = mContext;
public CallStatsAdapter(Context context) {
mContext = new WeakReference<>(context);
mCalls = new ArrayList<>();
}
public void updateListItems(List<Call> listCall) {
if (listCall != null) {
mCalls = listCall;
notifyDataSetChanged();
public void updateListItems(Call[] calls) {
mCalls = new ArrayList<>();
for (Call call : calls) {
mCalls.add(call);
}
notifyDataSetChanged();
}
@Override
......@@ -67,12 +68,12 @@ public class CallStatsAdapter extends BaseExpandableListAdapter {
}
} else {
// opening the statistics view
LayoutInflater inflater = LayoutInflater.from(mContext);
LayoutInflater inflater = LayoutInflater.from(mContext.get());
view = inflater.inflate(R.layout.call_stats_child, viewGroup, false);
}
// filling the view
holder = new CallStatsChildViewHolder(view, mContext);
holder = new CallStatsChildViewHolder(view, mContext.get());
view.setTag(holder);
holder.setCall(mCalls.get(groupPosition));
......@@ -90,7 +91,7 @@ public class CallStatsAdapter extends BaseExpandableListAdapter {
holder = (CallStatsViewHolder) possibleHolder;
}
} else {
LayoutInflater inflater = LayoutInflater.from(mContext);
LayoutInflater inflater = LayoutInflater.from(mContext.get());
view = inflater.inflate(R.layout.call_stats_group, viewGroup, false);
}
if (holder == null) {
......
......@@ -78,7 +78,7 @@ public class CallStatsChildViewHolder {
private View mAudioLayout;
public CallStatsChildViewHolder(View view, Context context) {
mContext = context;
mContext = context.getApplicationContext();
mEncoderTexts = new HashMap<>();
mDecoderTexts = new HashMap<>();
......@@ -121,6 +121,9 @@ public class CallStatsChildViewHolder {
org.linphone.core.tools.Log.i(
"[Call Stats] Call is terminated, stopping mCountDownTimer in charge of stats refreshing.");
mTimer.cancel();
mTimer.purge();
mContext = null;
mCall = null;
}
}
}
......
......@@ -29,7 +29,6 @@ import android.widget.ExpandableListView;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import androidx.drawerlayout.widget.DrawerLayout;
import java.util.Arrays;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.core.Call;
......@@ -57,8 +56,7 @@ public class CallStatsFragment extends Fragment {
public void onCallStateChanged(
Core lc, Call call, Call.State cstate, String message) {
if (cstate == Call.State.End || cstate == Call.State.Error) {
mAdapter.updateListItems(
Arrays.asList(LinphoneManager.getCore().getCalls()));
mAdapter.updateListItems(LinphoneManager.getCore().getCalls());
}
}
};
......@@ -68,7 +66,6 @@ public class CallStatsFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
Core core = LinphoneManager.getCore();
if (mAdapter == null) {
mAdapter = new CallStatsAdapter(getActivity());
......@@ -78,18 +75,21 @@ public class CallStatsFragment extends Fragment {
mExpandableList.expandGroup(0);
}
Core core = LinphoneManager.getCore();
// Sends calls from the list to the adapter
if (core != null && core.getCallsNb() >= 1) {
mAdapter.updateListItems(Arrays.asList(core.getCalls()));
mAdapter.updateListItems(core.getCalls());
}
core.addListener(mListener);
}
@Override
public void onPause() {
super.onPause();
LinphoneManager.getCore().removeListener(mListener);
mAdapter = null;
super.onPause();
}
public void setDrawer(DrawerLayout drawer, RelativeLayout content) {
......
......@@ -33,16 +33,14 @@ import org.linphone.utils.LinphoneUtils;
public class VideoZoomHelper extends GestureDetector.SimpleOnGestureListener
implements CompatibilityScaleGestureListener {
private View mVideoView;
private Context mContext;
private GestureDetector mGestureDetector;
private float mZoomFactor = 1.f;
private float mZoomCenterX, mZoomCenterY;
private CompatibilityScaleGestureDetector mScaleDetector;
public VideoZoomHelper(Context context, View videoView) {
mContext = context;
mGestureDetector = new GestureDetector(mContext, this);
mScaleDetector = new CompatibilityScaleGestureDetector(mContext);
mGestureDetector = new GestureDetector(context, this);
mScaleDetector = new CompatibilityScaleGestureDetector(context);
mScaleDetector.setOnScaleListener(this);
mVideoView = videoView;
......@@ -146,8 +144,6 @@ public class VideoZoomHelper extends GestureDetector.SimpleOnGestureListener
}
public void destroy() {
mContext = null;
if (mVideoView != null) {
mVideoView.setOnTouchListener(null);
mVideoView = null;
......
......@@ -87,7 +87,7 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
public ChatMessageViewHolder(
Context context, View view, ChatMessageViewHolderClickListener listener) {
this(view);
mContext = context;
mContext = context.getApplicationContext();
mListener = listener;
view.setOnClickListener(this);
}
......
......@@ -37,7 +37,7 @@ import org.linphone.utils.LinphoneUtils;
import org.linphone.views.ContactAvatar;
class DevicesAdapter extends BaseExpandableListAdapter {
private final Context mContext;
private Context mContext;
private List<Participant> mParticipants;
public DevicesAdapter(Context context) {
......@@ -50,6 +50,11 @@ class DevicesAdapter extends BaseExpandableListAdapter {
notifyDataSetChanged();
}
public void clear() {
mParticipants.clear();
mContext = null;
}
@Override
public View getGroupView(
int groupPosition, boolean isExpanded, View view, ViewGroup viewGroup) {
......
......@@ -141,6 +141,16 @@ public class DevicesFragment extends Fragment {
}
}
@Override
public void onPause() {
if (mAdapter != null) {
mAdapter.clear();
mAdapter = null;
}
super.onPause();
}
private void initChatRoom() {
Core core = LinphoneManager.getCore();
mRoom = core.getChatRoom(mRoomAddr, mLocalSipAddr);
......
......@@ -57,7 +57,7 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
private Context mContext;
public AsyncContactsLoader(Context context) {
mContext = context;
mContext = context.getApplicationContext();
}
@Override
......
......@@ -69,7 +69,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
public ContactsManager(Context context, Handler handler) {
super(handler);
mContext = context;
mContext = context.getApplicationContext();
mContactsUpdatedListeners = new ArrayList<>();
mContacts = new ArrayList<>();
mSipContacts = new ArrayList<>();
......
......@@ -81,8 +81,8 @@ public class LinphonePreferences {
sInstance = null;
}
public void setContext(Context c) {
mContext = c;
public void setContext(Context context) {
mContext = context.getApplicationContext();
mBasePath = mContext.getFilesDir().getAbsolutePath();
try {
copyAssetsFromPackage();
......
......@@ -75,7 +75,7 @@ public class AndroidAudioManager {
private CoreListenerStub mListener;
public AndroidAudioManager(Context context) {
mContext = context;
mContext = context.getApplicationContext();
mAudioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
mEchoTesterIsRunning = false;
......
......@@ -38,7 +38,7 @@ public class LinphoneShortcutManager {
private Set<String> mCategories;
public LinphoneShortcutManager(Context context) {
mContext = context;
mContext = context.getApplicationContext();
mCategories = new ArraySet<>();
mCategories.add(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION);
}
......
......@@ -72,12 +72,6 @@
</RelativeLayout>
<TextureView
android:id="@+id/videoSurface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<LinearLayout
android:id="@+id/menu"
android:layout_width="match_parent"
......