{"record":{"id":"44d23d46dbb0715b","repo":"MuntashirAkon/AppManager","slug":"empty-ssaid-field","errorCode":null,"errorMessage":"Empty SSAID field.","messagePattern":"Empty SSAID field\\.","errorType":"validation","errorClass":"java.io.IOException","httpStatus":null,"severity":"warning","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/ssaid/ChangeSsaidDialog.java","lineNumber":97,"sourceCode":"                .setPositiveButton(R.string.apply, null)\n                .setNegativeButton(R.string.close, null)\n                .setNeutralButton(R.string.reset_to_default, null)\n                .create();\n        TextInputEditText ssaidEditText = view.findViewById(android.R.id.text1);\n        TextInputLayout ssaidInputLayout = view.findViewById(R.id.ssaid_layout);\n        AtomicReference<Button> applyButton = new AtomicReference<>();\n        AtomicReference<Button> resetButton = new AtomicReference<>();\n\n        alertDialog.setOnShowListener(dialog -> {\n            applyButton.set(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));\n            resetButton.set(alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));\n            applyButton.get().setVisibility(View.GONE);\n            applyButton.get().setOnClickListener(v -> {\n                mSsaidChangedResult = ThreadUtils.postOnBackgroundThread(() -> {\n                    try {\n                        Editable editable = ssaidEditText.getText();\n                        if (editable == null) {\n                            throw new IOException(\"Empty SSAID field.\");\n                        }\n                        mSsaid = editable.toString();\n                        if (mSsaid.length() != sizeByte * 2) {\n                            throw new IOException(\"Invalid SSAID size \" + mSsaid.length());\n                        }\n                        if (!mSsaid.matches(\"[0-9A-Fa-f]+\")) {\n                            throw new IOException(\"Invalid SSAID \" + mSsaid.length());\n                        }\n                        SsaidSettings ssaidSettings = new SsaidSettings(UserHandleHidden.getUserId(uid));\n                        boolean isSuccess = ssaidSettings.setSsaid(packageName, uid, mSsaid);\n                        if (isSuccess) {\n                            alertDialog.dismiss();\n                        }\n                        if (mSsaidChangedInterface != null) {\n                            ThreadUtils.postOnMainThread(() -> mSsaidChangedInterface.onSsaidChanged(mSsaid, isSuccess));\n                        }\n                    } catch (IOException e) {\n                        e.printStackTrace();","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/ssaid/ChangeSsaidDialog.java#L79-L115","documentation":"IOException thrown in ChangeSsaidDialog.onCreateDialog's background apply task when the SSAID EditText returns a null Editable, meaning the user submitted the dialog with no text in the SSAID field. The dialog requires a concrete value to write, so it fails fast before attempting any system call.","triggerScenarios":"Pressing the Apply button while the ssaidEditText is empty or its text could not be retrieved (editable == null); typically when the field was cleared or the dialog was manipulated before text was committed.","commonSituations":"User selects-all and deletes the field contents then hits Apply; automation/UI tests submitting the dialog without input; a view-state restore that left the EditText empty.","solutions":["Check that the EditText is non-empty before calling Editable.toString() and skip/reject the apply","Disable the Apply button while the field is empty (add a TextWatcher)","Show a validation message to the user instead of only throwing","Wrap the background task body in try-catch for IOException and surface the error via Toast/dialog"],"exampleFix":"// before\nEditable editable = ssaidEditText.getText();\nif (editable == null) {\n    throw new IOException(\"Empty SSAID field.\");\n}\n// after\nEditable editable = ssaidEditText.getText();\nif (editable == null || editable.length() == 0) {\n    Toast.makeText(getContext(), R.string.empty_ssaid, Toast.LENGTH_SHORT).show();\n    return null;\n}","handlingStrategy":"validation","validationCode":"Editable editable = ssaidEditText.getText();\nif (editable == null || editable.length() == 0) {\n    ssaidEditText.setError(context.getString(R.string.empty_ssaid));\n    return;\n}","typeGuard":"boolean hasText(EditText et) { return et.getText() != null && et.getText().length() > 0; }","tryCatchPattern":"try {\n    applySsaid();\n} catch (IOException e) {\n    Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();\n}","preventionTips":["Disable Apply until the field passes validation (TextWatcher)","Add an input filter requiring hex characters","Restore dialog state (text) properly across rotation","Test dialog submission with empty input in UI tests"],"tags":["android","ui-validation","ssaid"],"backgroundTag":"empty-required-field","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}