|
2 | 2 | from django import forms |
3 | 3 |
|
4 | 4 |
|
| 5 | +class AndroidDeviceSelectionForm(forms.Form): |
| 6 | + """Restrict device selection to connected ADB identifiers.""" |
| 7 | + |
| 8 | + identifier = forms.ChoiceField(choices=()) |
| 9 | + |
| 10 | + def __init__(self, devices, *args, **kwargs): |
| 11 | + super().__init__(*args, **kwargs) |
| 12 | + self.fields['identifier'].choices = tuple( |
| 13 | + (device['identifier'], device['identifier']) |
| 14 | + for device in devices |
| 15 | + if device['state'] == 'device' |
| 16 | + ) |
| 17 | + |
| 18 | + |
| 19 | +class AndroidDynamicAnalysisForm(forms.Form): |
| 20 | + """Validate Android dynamic-analysis preparation options.""" |
| 21 | + |
| 22 | + device_mode = forms.ChoiceField( |
| 23 | + required=False, |
| 24 | + choices=( |
| 25 | + ('auto', 'auto'), |
| 26 | + ('rooted', 'rooted'), |
| 27 | + ('gadget', 'gadget'), |
| 28 | + ), |
| 29 | + ) |
| 30 | + install = forms.ChoiceField( |
| 31 | + required=False, |
| 32 | + choices=(('0', '0'), ('1', '1')), |
| 33 | + ) |
| 34 | + re_install = forms.ChoiceField( |
| 35 | + required=False, |
| 36 | + choices=(('0', '0'), ('1', '1')), |
| 37 | + ) |
| 38 | + uninstall_existing = forms.ChoiceField( |
| 39 | + required=False, |
| 40 | + choices=(('0', '0'), ('1', '1')), |
| 41 | + ) |
| 42 | + replace_existing_gadget = forms.ChoiceField( |
| 43 | + required=False, |
| 44 | + choices=(('0', '0'), ('1', '1')), |
| 45 | + ) |
| 46 | + |
| 47 | + |
5 | 48 | class UploadFileForm(forms.Form): |
6 | 49 | file = forms.FileField() |
0 commit comments