diff options
author | 2022-07-18 11:54:05 -0700 | |
---|---|---|
committer | 2022-07-19 16:27:07 +0000 | |
commit | 42449b783cb73223d62b41285ffb98c9c316ca9f (patch) | |
tree | 03ac82e9b6d48733cff09e27f4e07ea5c2daea22 | |
parent | 3d8c880d4c4a09a5ac33c755ccdf1a337959e262 (diff) |
[User Switcher] Improve documentation
Improve documentation for UserFileManager.
Bug: None
Test: None
Change-Id: I2b46a0f073afc4ba4784fab4e24078fc3cc15afc
-rw-r--r-- | packages/SystemUI/docs/user-file-manager.md | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/packages/SystemUI/docs/user-file-manager.md b/packages/SystemUI/docs/user-file-manager.md index 64f1694af50a..52fa2066fbe1 100644 --- a/packages/SystemUI/docs/user-file-manager.md +++ b/packages/SystemUI/docs/user-file-manager.md @@ -1,10 +1,30 @@ # UserFileManager -This class is used to generate file paths and SharedPreferences that is compatible for multiple +This class is used to generate file paths and SharedPreferences that is compatible for specific OS users in SystemUI. Due to constraints in SystemUI, we can only read/write files as the system user. Therefore, for secondary users, we want to store secondary user specific files into the system user directory. + +## Usages + +Inject UserFileManager into your class. + +### fun getFile(fileName: String, userId: Int): File +Add a file name and user id. You can retrieve the current user id from UserTracker. This will +return a java.io File object that contains the file path to write/read to. + +i.e. `fileManager.getFile("example.xml", userTracker.userId)` + +### fun getSharedPreferences(fileName: String, mode: Int, userId: Int): SharedPreferences +Add a file name, user id, and PreferencesMode. You can retrieve the current user id from +UserTracker. This returns SharedPreferences object that is tied to the specific user. Note that if +the SharedPreferences file does not exist, one will be created automatically. See +[SharedPreferences documentation](https://developer.android.com/reference/android/content/Context#getSharedPreferences(java.lang.String,%20int)) +for more details. + +i.e. `fileManager.getSharedPreferences("prefs.xml", userTracker.userId, 0)` + ## Handling User Removal This class will listen for Intent.ACTION_USER_REMOVED and remove directories that no longer |