Add popup for debug logs
This commit is contained in:
parent
da6f60245c
commit
a37024d3c7
6 changed files with 88 additions and 46 deletions
|
@ -169,4 +169,15 @@
|
||||||
<string name="media_encryption_srtp">SRTP</string>
|
<string name="media_encryption_srtp">SRTP</string>
|
||||||
<string name="media_encryption_zrtp">ZRTP</string>
|
<string name="media_encryption_zrtp">ZRTP</string>
|
||||||
<string name="media_encryption_dtls">DTLS</string>
|
<string name="media_encryption_dtls">DTLS</string>
|
||||||
|
|
||||||
|
<string name="debug_popup_title">Debug</string>
|
||||||
|
<string-array name="popup_enable_log">
|
||||||
|
<item>Enable logs</item>
|
||||||
|
<item>Cancel</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="popup_send_log">
|
||||||
|
<item>Disable logs</item>
|
||||||
|
<item>Send logs</item>
|
||||||
|
<item>Cancel</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -19,11 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
|
||||||
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;
|
||||||
|
@ -41,7 +38,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
|
||||||
View exitButton = null;
|
View exitButton = null;
|
||||||
View sendLogButton = null;
|
View sendLogButton = null;
|
||||||
View resetLogButton = null;
|
View resetLogButton = null;
|
||||||
private LinphoneCoreListenerBase mListener;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -70,39 +66,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
|
||||||
exitButton.setOnClickListener(this);
|
exitButton.setOnClickListener(this);
|
||||||
exitButton.setVisibility(View.VISIBLE);
|
exitButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
if (lc != null) {
|
|
||||||
mListener = new LinphoneCoreListenerBase(){
|
|
||||||
@Override
|
|
||||||
public void uploadProgressIndication(LinphoneCore linphoneCore, int offset, int total) {
|
|
||||||
if(total > 0)
|
|
||||||
Log.d("Log upload progress: currently uploaded = " + offset + " , total = " + total + ", % = " + String.valueOf((offset * 100) / total));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uploadStateChanged(LinphoneCore linphoneCore, 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
lc.addListener(mListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,11 +104,6 @@ public class AboutFragment extends Fragment implements OnClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
if (lc != null) {
|
|
||||||
lc.removeListener(mListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -932,6 +932,22 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
startActivityForResult(intent, CALL_ACTIVITY);
|
startActivityForResult(intent, CALL_ACTIVITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendLogs(Context context, String info){
|
||||||
|
final String appName = context.getString(R.string.app_name);
|
||||||
|
|
||||||
|
Intent i = new Intent(Intent.ACTION_SEND);
|
||||||
|
i.putExtra(Intent.EXTRA_EMAIL, new String[]{ context.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a sensor to track phoneOrientation changes
|
* Register a sensor to track phoneOrientation changes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1286,14 +1286,18 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
public void uploadProgressIndication(LinphoneCore linphoneCore, int offset, int total) {
|
||||||
|
if(total > 0)
|
||||||
|
Log.d("Log upload progress: currently uploaded = " + offset + " , total = " + total + ", % = " + String.valueOf((offset * 100) / total));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadStateChanged(LinphoneCore lc,
|
public void uploadStateChanged(LinphoneCore linphoneCore, LogCollectionUploadState state, String info) {
|
||||||
LogCollectionUploadState state, String info) {
|
Log.d("Log upload state: " + state.toString() + ", info = " + info);
|
||||||
|
|
||||||
|
if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered) {
|
||||||
|
LinphoneActivity.instance().sendLogs(LinphoneService.instance().getApplicationContext(),info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1151,4 +1151,16 @@ public class LinphonePreferences {
|
||||||
public boolean isContactsMigrationDone(){
|
public boolean isContactsMigrationDone(){
|
||||||
return getConfig().getBool("app", "contacts_migration_done",false);
|
return getConfig().getBool("app", "contacts_migration_done",false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDebugPopupAddress(){
|
||||||
|
return getConfig().getString("app", "debug_popup_magic", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableDebugLogs(Boolean debugMode){
|
||||||
|
getConfig().setBool("app", "debug_logs_enabled", debugMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean isDebugLogsEnabled(){
|
||||||
|
return getConfig().getBool("app", "debug_logs_enabled", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,12 @@ import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -118,8 +121,46 @@ public class Digit extends Button implements AddressAware {
|
||||||
if (lBegin >= 0) {
|
if (lBegin >= 0) {
|
||||||
mAddress.getEditableText().insert(lBegin,String.valueOf(mKeyCode));
|
mAddress.getEditableText().insert(lBegin,String.valueOf(mKeyCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(LinphonePreferences.instance().getDebugPopupAddress() != null
|
||||||
|
&& mAddress.getText().toString().equals(LinphonePreferences.instance().getDebugPopupAddress())){
|
||||||
|
displayDebugPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayDebugPopup(){
|
||||||
|
AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext());
|
||||||
|
alertDialog.setTitle(getContext().getString(R.string.debug_popup_title));
|
||||||
|
if(LinphonePreferences.instance().isDebugLogsEnabled()) {
|
||||||
|
alertDialog.setItems(getContext().getResources().getStringArray(R.array.popup_send_log), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if(which == 0){
|
||||||
|
LinphonePreferences.instance().enableDebugLogs(false);
|
||||||
|
LinphoneCoreFactory.instance().enableLogCollection(false);
|
||||||
|
}
|
||||||
|
if(which == 1) {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.uploadLogCollection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alertDialog.setItems(getContext().getResources().getStringArray(R.array.popup_enable_log), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if(which == 0) {
|
||||||
|
LinphonePreferences.instance().enableDebugLogs(true);
|
||||||
|
LinphoneCoreFactory.instance().enableLogCollection(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
alertDialog.show();
|
||||||
|
mAddress.getEditableText().clear();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
if (!mPlayDtmf) return false;
|
if (!mPlayDtmf) return false;
|
||||||
|
|
Loading…
Reference in a new issue