diff options
Diffstat (limited to 'java/com/android/dialer/simulator/impl')
-rw-r--r-- | java/com/android/dialer/simulator/impl/SimulatorActionProvider.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java b/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java index 4acb548a6..8257d9853 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java +++ b/java/com/android/dialer/simulator/impl/SimulatorActionProvider.java @@ -21,17 +21,30 @@ import android.content.Intent; import android.os.AsyncTask; import android.provider.VoicemailContract; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.ActionProvider; import android.view.MenuItem; import android.view.SubMenu; import android.view.View; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutors; +import com.android.dialer.persistentlog.PersistentLogger; /** Implements the simulator submenu. */ final class SimulatorActionProvider extends ActionProvider { @NonNull private final Context context; + private static class ShareLogWorker implements Worker<Void, String> { + + @Nullable + @Override + public String doInBackground(Void unused) { + return PersistentLogger.dumpLogToString(); + } + } + public SimulatorActionProvider(@NonNull Context context) { super(Assert.isNotNull(context)); this.context = context; @@ -82,6 +95,25 @@ final class SimulatorActionProvider extends ActionProvider { context.sendBroadcast(intent); return true; }); + + subMenu + .add("Share persistent log") + .setOnMenuItemClickListener( + (item) -> { + DialerExecutors.createNonUiTaskBuilder(new ShareLogWorker()) + .onSuccess( + (String log) -> { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, log); + if (intent.resolveActivity(context.getPackageManager()) != null) { + context.startActivity(intent); + } + }) + .build() + .executeSerial(null); + return true; + }); } private void populateDatabase() { |