mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-06-16 21:10:57 +08:00
Fix CaptureCtrl crash on Android 11/12
The CaptureCtrl is only started when the PCAPdroid control API is invoked. The crash occurred because getInsetsController was called before setContentView. Fixes #179
This commit is contained in:
parent
e7bc6ba8d1
commit
cebeb37a38
@ -922,7 +922,7 @@ public class Utils {
|
||||
return BuildType.WORKFLOW;
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
|
||||
Log.e("Utils", "Could not retrieve package version");
|
||||
Log.e("Utils", "Could not determine the build type");
|
||||
}
|
||||
return BuildType.UNKNOWN;
|
||||
}
|
||||
|
||||
@ -65,7 +65,11 @@ public class CaptureCtrl extends AppCompatActivity {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
// Important: calls must occur in the following order:
|
||||
// requestWindowFeature -> setContentView -> getInsetsController()
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.ctrl_consent);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
final WindowInsetsController insetsController = getWindow().getInsetsController();
|
||||
if (insetsController != null)
|
||||
@ -115,7 +119,6 @@ public class CaptureCtrl extends AppCompatActivity {
|
||||
}
|
||||
|
||||
// Show authorization window
|
||||
setContentView(R.layout.ctrl_consent);
|
||||
findViewById(R.id.allow_btn).setOnClickListener(v -> controlAction(intent, action, true));
|
||||
findViewById(R.id.deny_btn).setOnClickListener(v -> controlAction(intent, action, false));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user