-
Notifications
You must be signed in to change notification settings - Fork 64
Add Android debug bundle support with Troubleshoot UI #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
51b8c07
Pass app cache directory to Go for debug bundle temp files
pappz 92acfab
Update netbird submodule with logcat debug bundle support
pappz 401ec49
Add Troubleshoot fragment with debug bundle upload
pappz 883f174
Replace drawer menu PNG icons with Material outlined vectors
pappz 84e46de
Add error logging to EngineRunner.debugBundle
pappz 84ca392
Guard TroubleshootFragment UI callbacks against destroyed view
pappz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
app/src/main/java/io/netbird/client/ui/troubleshoot/TroubleshootFragment.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package io.netbird.client.ui.troubleshoot; | ||
|
|
||
| import android.app.Activity; | ||
| import android.content.ClipData; | ||
| import android.content.ClipboardManager; | ||
| import android.content.Context; | ||
| import android.os.Bundle; | ||
| import android.util.Log; | ||
| import android.view.LayoutInflater; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.Toast; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.fragment.app.Fragment; | ||
|
|
||
| import io.netbird.client.R; | ||
| import io.netbird.client.ServiceAccessor; | ||
| import io.netbird.client.databinding.FragmentTroubleshootBinding; | ||
| import io.netbird.client.tool.Preferences; | ||
|
|
||
| public class TroubleshootFragment extends Fragment { | ||
|
|
||
| private static final String LOGTAG = "TroubleshootFragment"; | ||
| private FragmentTroubleshootBinding binding; | ||
|
|
||
| @Override | ||
| public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
| binding = FragmentTroubleshootBinding.inflate(inflater, container, false); | ||
|
|
||
| Preferences preferences = new Preferences(inflater.getContext()); | ||
| binding.switchTraceLog.setChecked(preferences.isTraceLogEnabled()); | ||
|
|
||
| binding.switchTraceLog.setOnCheckedChangeListener((buttonView, isChecked) -> { | ||
| if (isChecked) { | ||
| preferences.enableTraceLog(); | ||
| } else { | ||
| preferences.disableTraceLog(); | ||
| } | ||
| }); | ||
|
|
||
| binding.traceLogLayout.setOnClickListener(v -> { | ||
| binding.switchTraceLog.toggle(); | ||
| }); | ||
|
|
||
| binding.anonymizeLayout.setOnClickListener(v -> { | ||
| binding.switchAnonymize.toggle(); | ||
| }); | ||
|
|
||
| binding.buttonDebugBundle.setOnClickListener(v -> { | ||
| generateDebugBundle(); | ||
| }); | ||
|
|
||
| return binding.getRoot(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onDestroyView() { | ||
| super.onDestroyView(); | ||
| binding = null; | ||
| } | ||
|
|
||
| private void generateDebugBundle() { | ||
| Activity activity = getActivity(); | ||
| if (activity == null || !(activity instanceof ServiceAccessor)) { | ||
| return; | ||
| } | ||
|
|
||
| boolean anonymize = binding.switchAnonymize.isChecked(); | ||
| binding.buttonDebugBundle.setEnabled(false); | ||
| new Thread(() -> { | ||
| try { | ||
| String key = ((ServiceAccessor) activity).debugBundle(anonymize); | ||
| activity.runOnUiThread(() -> { | ||
| if (binding == null || !isAdded()) return; | ||
| binding.buttonDebugBundle.setEnabled(true); | ||
| ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); | ||
| ClipData clip = ClipData.newPlainText("Debug bundle key", key); | ||
| clipboard.setPrimaryClip(clip); | ||
| Toast.makeText(activity, "Debug bundle key copied to clipboard", Toast.LENGTH_SHORT).show(); | ||
| }); | ||
| } catch (Exception e) { | ||
| Log.e(LOGTAG, "failed to create debug bundle", e); | ||
| activity.runOnUiThread(() -> { | ||
| if (binding == null || !isAdded()) return; | ||
| binding.buttonDebugBundle.setEnabled(true); | ||
| Toast.makeText(activity, "Failed to create debug bundle: " + e.getMessage(), Toast.LENGTH_LONG).show(); | ||
| }); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }).start(); | ||
| } | ||
| } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <!-- Material Design "info" outlined icon --> | ||
| <path | ||
| android:fillColor="#000000" | ||
| android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z" /> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <!-- Material Design "settings" outlined icon with hollow center --> | ||
| <path | ||
| android:fillColor="#000000" | ||
| android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM17.45,11.27c0.04,0.31 0.05,0.52 0.05,0.73s-0.02,0.43 -0.05,0.73l-0.14,1.13 0.89,0.7 1.08,0.84 -0.7,1.21 -1.27,-0.51 -1.04,-0.42 -0.9,0.68c-0.43,0.32 -0.84,0.56 -1.25,0.73l-1.06,0.43 -0.16,1.13 -0.2,1.35h-1.4l-0.19,-1.35 -0.16,-1.13 -1.06,-0.43c-0.43,-0.18 -0.83,-0.41 -1.23,-0.71l-0.91,-0.7 -1.06,0.43 -1.27,0.51 -0.7,-1.21 1.08,-0.84 0.89,-0.7 -0.14,-1.13c-0.03,-0.31 -0.05,-0.54 -0.05,-0.74s0.02,-0.43 0.05,-0.73l0.14,-1.13 -0.89,-0.7 -1.08,-0.84 0.7,-1.21 1.27,0.51 1.04,0.42 0.9,-0.68c0.43,-0.32 0.84,-0.56 1.25,-0.73l1.06,-0.43 0.16,-1.13 0.2,-1.35h1.39l0.19,1.35 0.16,1.13 1.06,0.43c0.43,0.18 0.83,0.41 1.23,0.71l0.91,0.7 1.06,-0.43 1.27,-0.51 0.7,1.21 -1.07,0.85 -0.89,0.7 0.14,1.13zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z" /> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <!-- Material Design "dns" outlined icon --> | ||
| <path | ||
| android:fillColor="#000000" | ||
| android:pathData="M19,15v4H5v-4h14m2,-2H3v8h18v-8zM19,3v4H5V3h14m2,-2H3v8h18V1zM7,8.5c0.83,0 1.5,-0.67 1.5,-1.5S7.83,5.5 7,5.5 5.5,6.17 5.5,7 6.17,8.5 7,8.5zM7,18.5c0.83,0 1.5,-0.67 1.5,-1.5s-0.67,-1.5 -1.5,-1.5 -1.5,0.67 -1.5,1.5 0.67,1.5 1.5,1.5z" /> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <!-- Material Design "help_outline" icon --> | ||
| <path | ||
| android:fillColor="#000000" | ||
| android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z" /> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <!-- Material Design "bug_report" outlined icon --> | ||
| <path | ||
| android:fillColor="#000000" | ||
| android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5s-0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8H4v2h2.09C6.04,10.33 6,10.66 6,11v1H4v2h2v1c0,0.34 0.04,0.67 0.09,1H4v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3H20v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1H20V8zM16,15c0,2.21 -1.79,4 -4,4s-4,-1.79 -4,-4v-4c0,-2.21 1.79,-4 4,-4s4,1.79 4,4v4zM10,14h4v2h-4v-2zM10,10h4v2h-4v-2z" /> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a local binder snapshot to avoid a check-then-use race.
mBinderis read twice; it can change between the null-check and call, especially since this path is triggered off the UI thread. Capture once, then use that reference.💡 Suggested fix
`@Override` public String debugBundle(boolean anonymize) throws Exception { - if (mBinder == null) { + VPNService.MyLocalBinder binder = mBinder; + if (binder == null) { throw new Exception("VPN service not connected"); } - return mBinder.debugBundle(anonymize); + return binder.debugBundle(anonymize); }📝 Committable suggestion
🤖 Prompt for AI Agents