Code optimisation + fix OOM issue

This commit is contained in:
Sylvain Berfini 2012-07-23 16:30:55 +02:00
parent f493dacee2
commit 86cc525635
28 changed files with 55 additions and 78 deletions

View file

@ -23,7 +23,7 @@
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>
<!-- Don't remove the space after android:debuggable: it prevents ndk-build to try including gdbserver and crash gcc --> <!-- Don't remove the space after android:debuggable: it prevents ndk-build to try including gdbserver and crash gcc -->
<application android:label="@string/app_name" android:debuggable ="true" android:icon="@drawable/logo_linphone_57x57"> <application android:label="@string/app_name" android:debuggable ="true" android:icon="@drawable/logo_linphone_57x57" android:largeHeap="true">
<activity android:name="org.linphone.LinphoneLauncherActivity" <activity android:name="org.linphone.LinphoneLauncherActivity"
android:label="@string/app_name" android:label="@string/app_name"
@ -54,7 +54,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" android:theme="@android:style/Theme.NoTitleBar"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:launchMode="singleTask"> android:launchMode="singleInstance">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
</intent-filter> </intent-filter>
@ -63,7 +63,7 @@
<activity android:name="org.linphone.IncomingCallActivity" <activity android:name="org.linphone.IncomingCallActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTop" android:launchMode="singleInstance"
android:screenOrientation="portrait"> android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -81,7 +81,7 @@
<activity android:name="org.linphone.InCallActivity" <activity android:name="org.linphone.InCallActivity"
android:theme="@android:style/Theme.NoTitleBar" android:theme="@android:style/Theme.NoTitleBar"
android:noHistory="true" android:noHistory="true"
android:launchMode="singleTop"> android:launchMode="singleInstance">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
</intent-filter> </intent-filter>
@ -108,7 +108,7 @@
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="org.linphone.LinphoneService" /> <service android:name="org.linphone.LinphoneService" android:stopWithTask="false"/>
<receiver android:name="org.linphone.NetworkManager"> <receiver android:name="org.linphone.NetworkManager">
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter> <intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent" >

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent" >

View file

@ -4,27 +4,27 @@
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
<TableRow android:layout_weight="1"> <TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/Digit1" android:text="1" style="@style/DialerDigit" android:background="@drawable/numpad_one" /> <org.linphone.ui.Digit android:id="@+id/Digit1" android:text="1" style="@style/DialerDigit" android:background="@drawable/numpad_one" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit2" android:text="2" style="@style/DialerDigit" android:background="@drawable/numpad_two" /> <org.linphone.ui.Digit android:id="@+id/Digit2" android:text="2" style="@style/DialerDigit" android:background="@drawable/numpad_two" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit3" android:text="3" style="@style/DialerDigit" android:background="@drawable/numpad_three" /> <org.linphone.ui.Digit android:id="@+id/Digit3" android:text="3" style="@style/DialerDigit" android:background="@drawable/numpad_three" android:soundEffectsEnabled="true" />
</TableRow> </TableRow>
<TableRow android:layout_weight="1"> <TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/Digit4" android:text="4" style="@style/DialerDigit" android:background="@drawable/numpad_four" /> <org.linphone.ui.Digit android:id="@+id/Digit4" android:text="4" style="@style/DialerDigit" android:background="@drawable/numpad_four" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit5" android:text="5" style="@style/DialerDigit" android:background="@drawable/numpad_five" /> <org.linphone.ui.Digit android:id="@+id/Digit5" android:text="5" style="@style/DialerDigit" android:background="@drawable/numpad_five" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit6" android:text="6" style="@style/DialerDigit" android:background="@drawable/numpad_six" /> <org.linphone.ui.Digit android:id="@+id/Digit6" android:text="6" style="@style/DialerDigit" android:background="@drawable/numpad_six" android:soundEffectsEnabled="true" />
</TableRow> </TableRow>
<TableRow android:layout_weight="1"> <TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/Digit7" android:text="7" style="@style/DialerDigit" android:background="@drawable/numpad_seven" /> <org.linphone.ui.Digit android:id="@+id/Digit7" android:text="7" style="@style/DialerDigit" android:background="@drawable/numpad_seven" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit8" android:text="8" style="@style/DialerDigit" android:background="@drawable/numpad_eight" /> <org.linphone.ui.Digit android:id="@+id/Digit8" android:text="8" style="@style/DialerDigit" android:background="@drawable/numpad_eight" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit9" android:text="9" style="@style/DialerDigit" android:background="@drawable/numpad_nine" /> <org.linphone.ui.Digit android:id="@+id/Digit9" android:text="9" style="@style/DialerDigit" android:background="@drawable/numpad_nine" android:soundEffectsEnabled="true" />
</TableRow> </TableRow>
<TableRow android:layout_weight="1"> <TableRow android:layout_weight="1">
<org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" android:background="@drawable/numpad_star" /> <org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" android:background="@drawable/numpad_star" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit00" android:text="0+" style="@style/DialerDigit" android:background="@drawable/numpad_zero" /> <org.linphone.ui.Digit android:id="@+id/Digit00" android:text="0+" style="@style/DialerDigit" android:background="@drawable/numpad_zero" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/DigitHash" android:text="#" style="@style/DialerDigit" android:background="@drawable/numpad_sharp" /> <org.linphone.ui.Digit android:id="@+id/DigitHash" android:text="#" style="@style/DialerDigit" android:background="@drawable/numpad_sharp" android:soundEffectsEnabled="true" />
</TableRow> </TableRow>
</TableLayout> </TableLayout>

View file

@ -41,20 +41,20 @@ import android.widget.TextView;
* @author Sylvain Berfini * @author Sylvain Berfini
*/ */
public class AudioCallFragment extends Fragment { public class AudioCallFragment extends Fragment {
private static AudioCallFragment instance;
private RelativeLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
private static final int rowHeight = 75; // Value set in active_call.xml private static final int rowHeight = 75; // Value set in active_call.xml
private static final int rowImageHeight = 100; // Value set in active_call.xml private static final int rowImageHeight = 100; // Value set in active_call.xml
private static final int rowThickRatio = 85; // Ratio dependent from the image private static final int rowThickRatio = 85; // Ratio dependent from the image
private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100); private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100);
private static final int topMarginWithImage = topMargin + rowImageHeight; private static final int topMarginWithImage = topMargin + rowImageHeight;
private RelativeLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
private InCallActivity inCallActivity;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
instance = this;
this.inflater = inflater; this.inflater = inflater;
this.container = container; this.container = container;
@ -142,14 +142,20 @@ public class AudioCallFragment extends Fragment {
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
if (InCallActivity.instance() == null) { inCallActivity = (InCallActivity) activity;
inCallActivity.bindAudioFragment(this);
}
@Override
public void onStart() {
super.onStart();
if (inCallActivity == null) {
return; return;
} }
InCallActivity.instance().bindAudioFragment(this);
// Just to be sure we have incall controls // Just to be sure we have incall controls
InCallActivity.instance().setCallControlsVisibleAndRemoveCallbacks(); inCallActivity.setCallControlsVisibleAndRemoveCallbacks();
} }
@Override @Override
@ -160,13 +166,6 @@ public class AudioCallFragment extends Fragment {
refreshCallList(getResources()); refreshCallList(getResources());
} }
/**
* @return null if not ready yet
*/
public static AudioCallFragment instance() {
return instance;
}
public void refreshCallList(Resources resources) { public void refreshCallList(Resources resources) {
if (callsList == null) { if (callsList == null) {
return; return;

View file

@ -54,7 +54,6 @@ public class InCallActivity extends FragmentActivity implements
OnClickListener { OnClickListener {
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000; private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
private static InCallActivity instance;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private Handler controlsHandler = new Handler(); private Handler controlsHandler = new Handler();
private Runnable mControls; private Runnable mControls;
@ -65,18 +64,9 @@ public class InCallActivity extends FragmentActivity implements
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled; private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled;
private LinearLayout mControlsLayout; private LinearLayout mControlsLayout;
static final boolean isInstanciated() {
return instance != null;
}
public static final InCallActivity instance() {
return instance;
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
instance = this;
setContentView(R.layout.incall); setContentView(R.layout.incall);
isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled"); isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled");
@ -107,7 +97,7 @@ public class InCallActivity extends FragmentActivity implements
switchCamera.setVisibility(View.GONE); switchCamera.setVisibility(View.GONE);
} }
callFragment.setArguments(getIntent().getExtras()); callFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commit(); getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
} }
LinphoneManager.addListener(this); LinphoneManager.addListener(this);
@ -571,11 +561,17 @@ public class InCallActivity extends FragmentActivity implements
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (LinphoneUtils.onKeyVolumeAdjust(keyCode)) return true; if (LinphoneUtils.onKeyVolumeAdjust(keyCode)) return true;
if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) return true; // if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) return true;
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
public void bindAudioFragment(AudioCallFragment fragment) { public void bindAudioFragment(AudioCallFragment fragment) {
audioCallFragment = fragment; audioCallFragment = fragment;
} }
@Override
protected void onDestroy() {
LinphoneManager.removeListener(this);
super.onDestroy();
}
} }

View file

@ -73,7 +73,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
private static final int SETTINGS_ACTIVITY = 123; private static final int SETTINGS_ACTIVITY = 123;
private static final int FIRST_LOGIN_ACTIVITY = 101; private static final int FIRST_LOGIN_ACTIVITY = 101;
private static final int callActivity = 19; private static final int callActivity = 19;
private static LinphoneActivity instance; private static LinphoneActivity instance;
private StatusFragment statusFragment; private StatusFragment statusFragment;
private TextView missedCalls, missedChats; private TextView missedCalls, missedChats;
private ImageView history, contacts, dialer, settings, chat; private ImageView history, contacts, dialer, settings, chat;

View file

@ -430,8 +430,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
} }
} }
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
return null; return null;
@ -451,19 +449,10 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
super.onDestroy(); super.onDestroy();
} }
private static final LinphoneGuiListener guiListener() { private static final LinphoneGuiListener guiListener() {
return null; return null;
} }
private static final LinphoneOnCallStateChangedListener incallListener() {
return InCallActivity.instance();
}
public void onDisplayStatus(final String message) { public void onDisplayStatus(final String message) {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
@ -488,7 +477,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
} }
} }
public void onRegistrationStateChanged(final RegistrationState state, public void onRegistrationStateChanged(final RegistrationState state,
final String message) { final String message) {
if (instance == null) { if (instance == null) {
@ -545,8 +533,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
try { try {
LinphoneManager.getLc().deferCallUpdate(call); LinphoneManager.getLc().deferCallUpdate(call);
if (incallListener() != null) // if (incallListener() != null)
incallListener().onCallStateChanged(call, state, message); // incallListener().onCallStateChanged(call, state, message);
} catch (LinphoneCoreException e) { } catch (LinphoneCoreException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -48,7 +48,6 @@ import android.widget.TextView;
* @author Sylvain Berfini * @author Sylvain Berfini
*/ */
public class StatusFragment extends Fragment { public class StatusFragment extends Fragment {
private static StatusFragment instance;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private Handler refreshHandler = new Handler(); private Handler refreshHandler = new Handler();
private TextView statusText, exit; private TextView statusText, exit;
@ -61,7 +60,6 @@ public class StatusFragment extends Fragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
instance = this;
View view = inflater.inflate(R.layout.status, container, false); View view = inflater.inflate(R.layout.status, container, false);
statusText = (TextView) view.findViewById(R.id.statusText); statusText = (TextView) view.findViewById(R.id.statusText);
@ -82,13 +80,6 @@ public class StatusFragment extends Fragment {
return view; return view;
} }
/**
* @return null if not ready yet
*/
public static StatusFragment instance() {
return instance;
}
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);

View file

@ -23,6 +23,7 @@ import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView;
import android.os.Bundle; import android.os.Bundle;
@ -42,16 +43,15 @@ import android.view.ViewGroup;
*/ */
@TargetApi(5) @TargetApi(5)
public class VideoCallFragment extends Fragment { public class VideoCallFragment extends Fragment {
private static VideoCallFragment instance;
private WakeLock mWakeLock; private WakeLock mWakeLock;
private SurfaceView mVideoView; private SurfaceView mVideoView;
private SurfaceView mCaptureView; private SurfaceView mCaptureView;
private AndroidVideoWindowImpl androidVideoWindowImpl; private AndroidVideoWindowImpl androidVideoWindowImpl;
private InCallActivity inCallActivity;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
instance = this;
View view = inflater.inflate(R.layout.video, container, false); View view = inflater.inflate(R.layout.video, container, false);
mVideoView = (SurfaceView) view.findViewById(R.id.videoSurface); mVideoView = (SurfaceView) view.findViewById(R.id.videoSurface);
@ -93,7 +93,7 @@ public class VideoCallFragment extends Fragment {
mVideoView.setOnTouchListener(new OnTouchListener() { mVideoView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
InCallActivity.instance().displayVideoCallControlsIfHidden(); inCallActivity.displayVideoCallControlsIfHidden();
return false; return false;
} }
}); });
@ -101,11 +101,10 @@ public class VideoCallFragment extends Fragment {
return view; return view;
} }
/** @Override
* @return null if not ready yet public void onAttach(Activity activity) {
*/ super.onAttach(activity);
public static VideoCallFragment instance() { inCallActivity = (InCallActivity) activity;
return instance;
} }
private void fixZOrder(SurfaceView video, SurfaceView preview) { private void fixZOrder(SurfaceView video, SurfaceView preview) {