Skip to content

Commit

Permalink
Bug 838844 - Add info option to get sutagent user info;r=gbrown
Browse files Browse the repository at this point in the history
  • Loading branch information
wlach committed Feb 8, 2013
1 parent a293812 commit 748b25b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions build/mobile/sutagent/android/DoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public enum Command
MEMORY ("memory"),
POWER ("power"),
PROCESS ("process"),
SUTUSERINFO ("sutuserinfo"),
GETAPPROOT ("getapproot"),
TESTROOT ("testroot"),
ALRT ("alrt"),
Expand Down Expand Up @@ -435,6 +436,8 @@ public String processCommand(String theCmdLine, PrintWriter out, BufferedInputSt
strReturn += GetPowerInfo();
strReturn += "\n";
strReturn += GetProcessInfo();
strReturn += "\n";
strReturn += GetSutUserInfo();
}
else
{
Expand Down Expand Up @@ -481,6 +484,10 @@ public String processCommand(String theCmdLine, PrintWriter out, BufferedInputSt
strReturn += GetPowerInfo();
break;

case SUTUSERINFO:
strReturn += GetSutUserInfo();
break;

default:
break;
}
Expand Down Expand Up @@ -2607,6 +2614,28 @@ public String GetPowerInfo()
return (sRet);
}

public String GetSutUserInfo()
{
String sRet = "";
try {
// based on patch in https://bugzilla.mozilla.org/show_bug.cgi?id=811763
Context context = contextWrapper.getApplicationContext();
Object userManager = context.getSystemService("user");
if (userManager != null) {
// if userManager is non-null that means we're running on 4.2+ and so the rest of this
// should just work
Object userHandle = android.os.Process.class.getMethod("myUserHandle", (Class[])null).invoke(null);
Object userSerial = userManager.getClass().getMethod("getSerialNumberForUser", userHandle.getClass()).invoke(userManager, userHandle);
sRet += "User Serial:" + userSerial.toString();
}
} catch (Exception e) {
// Guard against any unexpected failures
e.printStackTrace();
}

return sRet;
}

// todo
public String GetDiskInfo(String sPath)
{
Expand Down

0 comments on commit 748b25b

Please sign in to comment.