1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.compatibility.common.deviceinfo; 17 18 import android.os.UserManager; 19 20 import com.android.compatibility.common.util.DeviceInfoStore; 21 22 import java.lang.reflect.Field; 23 import java.lang.reflect.InvocationTargetException; 24 import java.lang.reflect.Method; 25 26 /** 27 * User device info collector. 28 */ 29 public final class UserDeviceInfo extends DeviceInfo { 30 31 @Override collectDeviceInfo(DeviceInfoStore store)32 protected void collectDeviceInfo(DeviceInfoStore store) throws Exception { 33 store.addResult("max_supported_users", getMaxSupportedUsers()); 34 } 35 getMaxSupportedUsers()36 private int getMaxSupportedUsers() { 37 try { 38 Method method = UserManager.class.getMethod("getMaxSupportedUsers"); 39 return (Integer) method.invoke(null); 40 } catch (ClassCastException | 41 NoSuchMethodException | 42 InvocationTargetException | 43 IllegalAccessException e) {} 44 return -1; 45 } 46 } 47