{"record":{"id":"dd884c9a62b16598","repo":"MuntashirAkon/AppManager","slug":"mode-mode-is-not-supported","errorCode":null,"errorMessage":"Mode ${mode} is not supported.","messagePattern":"Mode (.+?) is not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/compat/StorageManagerCompat.java","lineNumber":145,"sourceCode":"                    }\n                } catch (IOException | ErrnoException e) {\n                    Log.e(TAG, \"Failed to write file.\", e);\n                    try {\n                        pipe[0].closeWithError(e.getMessage());\n                    } catch (IOException exc) {\n                        Log.e(TAG, \"Can't even close PFD with error.\", exc);\n                    }\n                } finally {\n                    callback.onRelease();\n                }\n            });\n            return pipe[1];\n        } else {\n            // Should never happen.\n            pipe[0].close();\n            pipe[1].close();\n            Log.e(TAG, \"Mode \" + mode + \" is not supported.\");\n            throw new UnsupportedOperationException(\"Mode \" + mode + \" is not supported.\");\n        }\n    }\n\n    public static abstract class ProxyFileDescriptorCallbackCompat {\n        private final Handler mHandler;\n\n        public ProxyFileDescriptorCallbackCompat(@NonNull Handler callbackHandler) {\n            mHandler = callbackHandler;\n        }\n\n        /**\n         * Returns size of bytes provided by the file descriptor.\n         *\n         * @return Size of bytes.\n         * @throws ErrnoException Containing E constants in OsConstants.\n         */\n        public long onGetSize() throws ErrnoException {\n            throw new ErrnoException(\"onGetSize\", OsConstants.EBADF);","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/compat/StorageManagerCompat.java#L127-L163","documentation":"Thrown by StorageManagerCompat.openProxyFileDescriptor when an unsupported mode value is passed to createProxyFileDescriptor. Only MODE_READ_ONLY and MODE_WRITE_ONLY are handled; anything else (e.g. MODE_READ_WRITE) closes both pipe ends and throws UnsupportedOperationException.","triggerScenarios":"Calling openProxyFileDescriptor with a mode from ParcelFileDescriptor constants other than MODE_READ_ONLY or MODE_WRITE_ONLY — typically MODE_READ_WRITE or MODE_CREATE|MODE_TRUNCATE combinations.","commonSituations":"Opening a DocumentFile with Intent flags that map to read-write; passing MODE_READ_WRITE because the caller wants both read and write through one proxy; refactoring code that previously used openFileDescriptor defaults.","solutions":["Pass ParcelFileDescriptor.MODE_READ_ONLY or MODE_WRITE_ONLY explicitly","If read-write is needed, open two proxy descriptors (one per direction)","Audit calling code for flags like MODE_CREATE|MODE_TRUNCATE being ORed into the mode argument"],"exampleFix":"// before\nParcelFileDescriptor pfd = StorageManagerCompat.openProxyFileDescriptor(\n        ParcelFileDescriptor.MODE_READ_WRITE, callback, handler);\n// after\nParcelFileDescriptor pfd = StorageManagerCompat.openProxyFileDescriptor(\n        ParcelFileDescriptor.MODE_READ_ONLY, callback, handler);","handlingStrategy":"type-guard","validationCode":"boolean isSupported(int mode) {\n    return mode == ParcelFileDescriptor.MODE_READ_ONLY\n        || mode == ParcelFileDescriptor.MODE_WRITE_ONLY;\n}","typeGuard":"static boolean isSupportedProxyMode(int mode) {\n    int m = mode & (ParcelFileDescriptor.MODE_READ_ONLY | ParcelFileDescriptor.MODE_WRITE_ONLY);\n    return m == ParcelFileDescriptor.MODE_READ_ONLY || m == ParcelFileDescriptor.MODE_WRITE_ONLY;\n}","tryCatchPattern":"int mode = ParcelFileDescriptor.MODE_READ_WRITE;\nif (!isSupportedProxyMode(mode)) {\n    mode = ParcelFileDescriptor.MODE_READ_ONLY; // safe default\n}\ntry {\n    pfd = StorageManagerCompat.openProxyFileDescriptor(mode, callback, handler);\n} catch (UnsupportedOperationException e) {\n    Log.e(TAG, \"Unsupported mode requested\", e);\n}","preventionTips":["Never pass MODE_READ_WRITE to this API","Mask out CREATE/TRUNCATE flag bits","Open two descriptors for bidirectional IO","Add assertions in calling code"],"tags":["android","storage","unsupported-mode"],"backgroundTag":"unsupported-operation","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}