示例#1
0
 public void runListUsers() {
   try {
     List<UserInfo> users = mUm.getUsers(false);
     if (users == null) {
       System.err.println("Error: couldn't get users");
     } else {
       System.out.println("Users:");
       for (int i = 0; i < users.size(); i++) {
         System.out.println("\t" + users.get(i).toString());
       }
     }
   } catch (RemoteException e) {
     System.err.println(e.toString());
     System.err.println(PM_NOT_RUNNING_ERR);
   }
 }
示例#2
0
 public void runCreateUser() {
   String name;
   String arg = nextArg();
   if (arg == null) {
     System.err.println("Error: no user name specified.");
     return;
   }
   name = arg;
   try {
     final UserInfo info = mUm.createUser(name, 0);
     if (info != null) {
       System.out.println("Success: created user id " + info.id);
     } else {
       System.err.println("Error: couldn't create User.");
     }
   } catch (RemoteException e) {
     System.err.println(e.toString());
     System.err.println(PM_NOT_RUNNING_ERR);
   }
 }
示例#3
0
 public void runRemoveUser() {
   int userId;
   String arg = nextArg();
   if (arg == null) {
     System.err.println("Error: no user id specified.");
     return;
   }
   try {
     userId = Integer.parseInt(arg);
   } catch (NumberFormatException e) {
     System.err.println("Error: user id '" + arg + "' is not a number.");
     return;
   }
   try {
     if (mUm.removeUser(userId)) {
       System.out.println("Success: removed user");
     } else {
       System.err.println("Error: couldn't remove user id " + userId);
     }
   } catch (RemoteException e) {
     System.err.println(e.toString());
     System.err.println(PM_NOT_RUNNING_ERR);
   }
 }