Skip to content

Commit

Permalink
Fix(Inventory): prevent error with android.permission.QUERY_USERS (on…
Browse files Browse the repository at this point in the history
…ly for sys app)
  • Loading branch information
stonebuzz committed Dec 4, 2024
1 parent 4299214 commit 4a816fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
4 changes: 3 additions & 1 deletion inventory/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
plugins {
id 'com.android.library'
}

android {
compileSdk 34
Expand Down
17 changes: 1 addition & 16 deletions inventory/src/main/java/org/flyve/inventory/categories/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,7 @@ public User(Context xCtx) {
public String getUserName() {
String userName = "N/A";
try {
if (Build.VERSION.SDK_INT >= 17) {
UserManager userMgr = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (userMgr != null) {
try {
// validate permission exception
userName = userMgr.getUserName();
} catch (Exception ex) {
InventoryLog.e(InventoryLog.getMessage(context, CommonErrorType.USER_NAME, ex.getMessage()));
userName = Build.USER;
}
} else {
userName = Build.USER;
}
} else {
userName = Build.USER;
}
userName = Build.USER;
} catch (Exception ex) {
InventoryLog.e(InventoryLog.getMessage(context, CommonErrorType.USER_NAME, ex.getMessage()));
}
Expand Down

0 comments on commit 4a816fa

Please sign in to comment.