Started log collection upload

This commit is contained in:
Sylvain Berfini 2015-01-05 15:11:42 +01:00
parent 0f4de68059
commit 83b5650a0e
7 changed files with 92 additions and 36 deletions

View file

@ -50,30 +50,24 @@
<View android:layout_weight="30" android:layout_width="0dp" android:layout_height="0dp" /> <View android:layout_weight="30" android:layout_width="0dp" android:layout_height="0dp" />
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="match_parent"
android:gravity="center_horizontal" android:layout_height="wrap_content"
android:layout_height="wrap_content"> android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="30dp">
<LinearLayout android:id="@+id/send_log_layout" <Button
android:visibility="visible" android:id="@+id/send_log"
android:gravity="center" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content"> android:text="@string/menu_send_log"/>
<Button
android:id="@+id/send_log" <Button android:id="@+id/exit"
android:layout_width="wrap_content" android:gravity="center"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="@string/menu_send_log"/> android:layout_height="wrap_content"
<View android:layout_width="50dp" android:layout_height="0dp" /> android:text="@string/menu_exit"/>
</LinearLayout>
<Button android:id="@+id/exit"
android:gravity="center"
android:layout_toRightOf="@id/send_log_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu_exit"
/>
</LinearLayout> </LinearLayout>
<View android:layout_weight="30" android:layout_width="0dp" android:layout_height="0dp" />
</LinearLayout> </LinearLayout>

View file

@ -29,3 +29,4 @@ dtmf_player_amp=0.1
[misc] [misc]
max_calls=10 max_calls=10
log_collection_upload_server_url=https://www.linphone.org:444/lft.php

View file

@ -29,3 +29,4 @@ dtmf_player_amp=0.1
[misc] [misc]
max_calls=10 max_calls=10
log_collection_upload_server_url=https://www.linphone.org:444/lft.php

View file

@ -18,8 +18,12 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.mediastream.Log; import org.linphone.mediastream.Log;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -27,21 +31,18 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
/** /**
* @author Sylvain Berfini * @author Sylvain Berfini
*/ */
public class AboutFragment extends Fragment implements OnClickListener { public class AboutFragment extends Fragment implements OnClickListener, LinphoneCoreListener.LinphoneLogCollectionUploadListener {
private FragmentsAvailable about = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT; private FragmentsAvailable about = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
View exitButton = null; View exitButton = null;
View sendLogButton = null; View sendLogButton = null;
LinearLayout sendLogLayout = null;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle savedInstanceState) {
if (getArguments() != null && getArguments().getSerializable("About") != null) { if (getArguments() != null && getArguments().getSerializable("About") != null) {
about = (FragmentsAvailable) getArguments().getSerializable("About"); about = (FragmentsAvailable) getArguments().getSerializable("About");
} }
@ -57,13 +58,16 @@ public class AboutFragment extends Fragment implements OnClickListener {
sendLogButton = view.findViewById(R.id.send_log); sendLogButton = view.findViewById(R.id.send_log);
sendLogButton.setOnClickListener(this); sendLogButton.setOnClickListener(this);
sendLogLayout = (LinearLayout)view.findViewById(R.id.send_log_layout); sendLogButton.setVisibility(LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
sendLogLayout.setVisibility(getResources().getBoolean(R.bool.enable_log_collect) ? View.VISIBLE : View.GONE);
exitButton = view.findViewById(R.id.exit); exitButton = view.findViewById(R.id.exit);
exitButton.setOnClickListener(this); exitButton.setOnClickListener(this);
exitButton.setVisibility(View.VISIBLE); exitButton.setVisibility(View.VISIBLE);
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
lc.addListener(this);
}
return view; return view;
} }
@ -80,15 +84,56 @@ public class AboutFragment extends Fragment implements OnClickListener {
} }
} }
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
if (v == sendLogButton) { if (v == sendLogButton) {
LinphoneUtils.collectLogs(LinphoneActivity.instance(), getString(R.string.about_bugreport_email)); //LinphoneUtils.collectLogs(LinphoneActivity.instance(), getString(R.string.about_bugreport_email));
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
lc.uploadLogCollection();
}
} else { } else {
LinphoneActivity.instance().exit(); LinphoneActivity.instance().exit();
} }
} }
} }
@Override
public void onDestroy() {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
lc.removeListener(this);
}
super.onDestroy();
}
@Override
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
Log.d("Log upload progress: currently uploaded = " + offset + " , total = " + total + ", % = " + String.valueOf((offset * 100) / total));
}
@Override
public void uploadStateChanged(LinphoneCore lc, LogCollectionUploadState state, String info) {
Log.d("Log upload state: " + state.toString() + ", info = " + info);
if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered) {
final String appName = getString(R.string.app_name);
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_EMAIL, new String[]{ getString(R.string.about_bugreport_email) });
i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs");
i.putExtra(Intent.EXTRA_TEXT, info);
i.setType("application/zip");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Log.e(ex);
}
}
}
} }

View file

@ -46,6 +46,7 @@ import org.linphone.core.LinphoneContent;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.EcCalibratorStatus; import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCore.GlobalState; import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState; import org.linphone.core.LinphoneCore.RemoteProvisioningState;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
@ -1261,19 +1262,27 @@ public class LinphoneManager implements LinphoneListener {
@Override @Override
public void fileTransferProgressIndication(LinphoneCore lc, public void fileTransferProgressIndication(LinphoneCore lc,
LinphoneChatMessage message, LinphoneContent content, int progress) { LinphoneChatMessage message, LinphoneContent content, int progress) {
// TODO Auto-generated method stub
} }
@Override @Override
public void fileTransferRecv(LinphoneCore lc, LinphoneChatMessage message, public void fileTransferRecv(LinphoneCore lc, LinphoneChatMessage message,
LinphoneContent content, byte[] buffer, int size) { LinphoneContent content, byte[] buffer, int size) {
// TODO Auto-generated method stub
} }
@Override @Override
public int fileTransferSend(LinphoneCore lc, LinphoneChatMessage message, public int fileTransferSend(LinphoneCore lc, LinphoneChatMessage message,
LinphoneContent content, ByteBuffer buffer, int size) { LinphoneContent content, ByteBuffer buffer, int size) {
// TODO Auto-generated method stub
return 0; return 0;
} }
@Override
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
}
@Override
public void uploadStateChanged(LinphoneCore lc,
LogCollectionUploadState state, String info) {
}
} }

View file

@ -30,6 +30,7 @@ import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactoryImpl; import org.linphone.core.LinphoneCoreFactoryImpl;
import org.linphone.core.LinphoneCoreImpl;
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener; import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
import org.linphone.core.LinphoneCoreListener.LinphoneGlobalStateListener; import org.linphone.core.LinphoneCoreListener.LinphoneGlobalStateListener;
import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener; import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener;
@ -137,6 +138,11 @@ public final class LinphoneService extends Service implements LinphoneCallStateL
// In case restart after a crash. Main in LinphoneActivity // In case restart after a crash. Main in LinphoneActivity
mNotificationTitle = getString(R.string.service_name); mNotificationTitle = getString(R.string.service_name);
// Needed in order for the two next calls to succeed, libraries must have been loaded first
LinphoneCoreFactoryImpl.instance();
LinphoneCoreImpl.setLogCollectionPath(getFilesDir().getAbsolutePath());
LinphoneCoreImpl.enableLogCollection(!(getResources().getBoolean(R.bool.disable_every_log)));
// Dump some debugging information to the logs // Dump some debugging information to the logs
Log.i(START_LINPHONE_LOGS); Log.i(START_LINPHONE_LOGS);
dumpDeviceInformation(); dumpDeviceInformation();

@ -1 +1 @@
Subproject commit 9b06383c7e75ee3d6dacb564bd6598b00df16128 Subproject commit 4e5e409dc27546cb72406f49e852afd02d4cdc6c