1258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani/* 2258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Copyright (C) 2012 The Android Open Source Project 3258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 4258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Licensed under the Apache License, Version 2.0 (the "License"); 5258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * you may not use this file except in compliance with the License. 6258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * You may obtain a copy of the License at 7258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 8258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * http://www.apache.org/licenses/LICENSE-2.0 9258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 10258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Unless required by applicable law or agreed to in writing, software 11258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * distributed under the License is distributed on an "AS IS" BASIS, 12258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * See the License for the specific language governing permissions and 14258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * limitations under the License. 15258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 168a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey 17258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasanipackage android.os; 18258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 19b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chenimport android.Manifest; 2002cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolovimport android.accounts.AccountManager; 21e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Banimport android.annotation.IntDef; 227cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chenimport android.annotation.Nullable; 23b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chenimport android.annotation.RequiresPermission; 240e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasaniimport android.annotation.SystemApi; 258588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkeyimport android.annotation.UserIdInt; 2637ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasaniimport android.app.Activity; 27409297da182267465adbc21cfb75a23e8d678117Dianne Hackbornimport android.app.ActivityManager; 28a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackbornimport android.app.ActivityManagerNative; 29cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolovimport android.app.admin.DevicePolicyManager; 30068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onukiimport android.content.ComponentName; 31258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasaniimport android.content.Context; 3212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasaniimport android.content.Intent; 33f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franzimport android.content.IntentSender; 34258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasaniimport android.content.pm.UserInfo; 3527bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkeyimport android.content.res.Resources; 366794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthallimport android.graphics.Bitmap; 371bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roosimport android.graphics.BitmapFactory; 384f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport android.graphics.Rect; 394f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport android.graphics.drawable.Drawable; 401e9c21871e81642669079cd290ef47818a3165bdAmith Yamasaniimport android.provider.Settings; 41523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolovimport android.telephony.TelephonyManager; 421c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monkimport android.view.WindowManager.LayoutParams; 43258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 446794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthallimport com.android.internal.R; 456794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 461bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roosimport java.io.IOException; 47e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Banimport java.lang.annotation.Retention; 48e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Banimport java.lang.annotation.RetentionPolicy; 494f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport java.util.ArrayList; 50258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasaniimport java.util.List; 51258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 52258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani/** 530696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * Manages users and user details on a multi-user system. There are two major categories of 540696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * users: fully customizable users with their own login, and managed profiles that share a workspace 550696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * with a related user. 560696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * <p> 570696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * Users are different from accounts, which are managed by 580696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * {@link AccountManager}. Each user can have their own set of accounts. 590696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * <p> 600696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * See {@link DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE} for more on managed profiles. 61258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 62258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasanipublic class UserManager { 63258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 64258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani private static String TAG = "UserManager"; 65258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani private final IUserManager mService; 66258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani private final Context mContext; 67258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 68e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 69e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @hide 70e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * No user restriction. 71e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban */ 72e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @SystemApi 73e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban public static final int RESTRICTION_NOT_SET = 0x0; 74e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban 75e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban /** 76e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @hide 77e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * User restriction set by system/user. 78e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban */ 79e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @SystemApi 80e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban public static final int RESTRICTION_SOURCE_SYSTEM = 0x1; 81e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban 82e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban /** 83e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @hide 84e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * User restriction set by a device owner. 85e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban */ 86e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @SystemApi 87e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban public static final int RESTRICTION_SOURCE_DEVICE_OWNER = 0x2; 88e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban 89e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban /** 90e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @hide 91e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * User restriction set by a profile owner. 92e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban */ 93e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @SystemApi 94e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban public static final int RESTRICTION_SOURCE_PROFILE_OWNER = 0x4; 95e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban 96e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban /** @hide */ 97e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @Retention(RetentionPolicy.SOURCE) 98e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @IntDef(flag=true, value={RESTRICTION_NOT_SET, RESTRICTION_SOURCE_SYSTEM, 99e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban RESTRICTION_SOURCE_DEVICE_OWNER, RESTRICTION_SOURCE_PROFILE_OWNER}) 100e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @SystemApi 101e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban public @interface UserRestrictionSource {} 102e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban 103e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban /** 10453019287fd4fed9837363cff4de87100d85c2b81Fyodor Kupolov * Specifies if a user is disallowed from adding and removing accounts, unless they are 10553019287fd4fed9837363cff4de87100d85c2b81Fyodor Kupolov * {@link android.accounts.AccountManager#addAccountExplicitly programmatically} added by 10653019287fd4fed9837363cff4de87100d85c2b81Fyodor Kupolov * Authenticator. 10771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 10826af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 109b6c0ce4ac915cd5ab9a308cb0a4861c4e2cd7dfbBenjamin Franz * <p>From {@link android.os.Build.VERSION_CODES#N} a profile or device owner app can still 110b6c0ce4ac915cd5ab9a308cb0a4861c4e2cd7dfbBenjamin Franz * use {@link android.accounts.AccountManager} APIs to add or remove accounts when account 111b6c0ce4ac915cd5ab9a308cb0a4861c4e2cd7dfbBenjamin Franz * management is disallowed. 112b6c0ce4ac915cd5ab9a308cb0a4861c4e2cd7dfbBenjamin Franz * 1130ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 1140ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 115068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 116068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 117e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 118e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 11971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts"; 120e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 121e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 12226af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from changing Wi-Fi 1232cb384f42569f36e19ecee60da259d69048fdd85Julia Reynolds * access points. The default value is <code>false</code>. 1240ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>This restriction has no effect in a managed profile. 12526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 1260ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 1270ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 128068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 129068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 130e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 131e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 13271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_CONFIG_WIFI = "no_config_wifi"; 133e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 134e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 13526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from installing applications. 13671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 13726af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 1380ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 1390ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 140068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 141068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 142e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 143e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 14471e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_INSTALL_APPS = "no_install_apps"; 145e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 146e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 14726af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from uninstalling applications. 14871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 14926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 1500ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 1510ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 152068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 153068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 154e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 155e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 15671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps"; 157e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 15871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 159150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * Specifies if a user is disallowed from turning on location sharing. 16071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 1610ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>In a managed profile, location sharing always reflects the primary user's setting, but 162150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * can be overridden and forced off by setting this restriction to true in the managed profile. 16326af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 1640ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 1650ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 166068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 167068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 1686794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall * @see #getUserRestrictions() 1696794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall */ 17071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_SHARE_LOCATION = "no_share_location"; 1716794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 172a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 17326af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from enabling the 174a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * "Unknown Sources" setting, that allows installation of apps from unknown sources. 175a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * The default value is <code>false</code>. 17626af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 1770ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 1780ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 179068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 180068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 181a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #getUserRestrictions() 182a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 183a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public static final String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources"; 184a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 185a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 18626af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from configuring bluetooth. 1871c4c442e4540b16aed7acc345aea26ab101efbf8Nicolas Prevot * This does <em>not</em> restrict the user from turning bluetooth on or off. 188a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * The default value is <code>false</code>. 1890ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>This restriction has no effect in a managed profile. 19026af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 1910ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 1920ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 193068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 194068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 195a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #getUserRestrictions() 196a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 197a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public static final String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; 198a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 199a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 20026af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from transferring files over 201c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * USB. This can only be set by device owners and profile owners on the primary user. 202c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * The default value is <code>false</code>. 20326af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 2040ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 2050ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 206068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 207068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 208a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #getUserRestrictions() 209a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 210a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public static final String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer"; 211a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 212b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier /** 21326af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from configuring user 214b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * credentials. The default value is <code>false</code>. 21526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 2160ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 2170ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 218068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 219068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 220b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * @see #getUserRestrictions() 221b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier */ 222b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier public static final String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials"; 223b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier 224b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier /** 225150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * When set on the primary user this specifies if the user can remove other users. 226150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * When set on a secondary user, this specifies if the user can remove itself. 227150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * This restriction has no effect on managed profiles. 228150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * The default value is <code>false</code>. 22926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 2300ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 2310ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 232068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 233068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 234b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * @see #getUserRestrictions() 235b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier */ 236b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier public static final String DISALLOW_REMOVE_USER = "no_remove_user"; 237b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier 238d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 23926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from enabling or 240d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * accessing debugging features. The default value is <code>false</code>. 24126af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 2420ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 2430ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 244068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 245068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 246d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 247d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 248d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_DEBUGGING_FEATURES = "no_debugging_features"; 249d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 250d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 25126af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from configuring VPN. 252d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * The default value is <code>false</code>. 253298f98fa234f353267ddc9c75d58e8cc542c25f1Nicolas Prevot * This restriction has an effect in a managed profile only from 2540e3de6cacaffcfeda4d6353be61e2f1f9ed80705Dianne Hackborn * {@link android.os.Build.VERSION_CODES#M} 25526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 2560ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 2570ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 258068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 259068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 260d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 261d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 262d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_VPN = "no_config_vpn"; 263d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 264d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 26526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from configuring Tethering 266c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * & portable hotspots. This can only be set by device owners and profile owners on the 267c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * primary user. The default value is <code>false</code>. 26826af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 2690ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 2700ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 271068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 272068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 273d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 274d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 275d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_TETHERING = "no_config_tethering"; 276d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 277d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 278e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott * Specifies if a user is disallowed from resetting network settings 279e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott * from Settings. This can only be set by device owners and profile owners on the primary user. 280e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott * The default value is <code>false</code>. 2810ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>This restriction has no effect on secondary users and managed profiles since only the 282e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott * primary user can reset the network settings of the device. 283e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott * 2840ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 2850ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 286068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 287068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 288e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott * @see #getUserRestrictions() 289e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott */ 290e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott public static final String DISALLOW_NETWORK_RESET = "no_network_reset"; 291e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott 292e3e314df4d52881225326d426a76e3e7f1bc40d3Stuart Scott /** 29326af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from factory resetting 294c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * from Settings. This can only be set by device owners and profile owners on the primary user. 295c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * The default value is <code>false</code>. 2960ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>This restriction has no effect on secondary users and managed profiles since only the 297150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * primary user can factory reset the device. 29826af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 2990ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 3000ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 301068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 302068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 303d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 304d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 305d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_FACTORY_RESET = "no_factory_reset"; 306d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 307d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 30826af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from adding new users and 309c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * profiles. This can only be set by device owners and profile owners on the primary user. 310c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * The default value is <code>false</code>. 3110ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>This restriction has no effect on secondary users and managed profiles since only the 312150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * primary user can add other users. 31326af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 3140ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 3150ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 316068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 317068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 318d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 319d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 320d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_ADD_USER = "no_add_user"; 321d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 322d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 32326af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from disabling application 324d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * verification. The default value is <code>false</code>. 32526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 3260ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 3270ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 328068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 329068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 330d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 331d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 332d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String ENSURE_VERIFY_APPS = "ensure_verify_apps"; 333d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 334d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 33526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from configuring cell 336c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * broadcasts. This can only be set by device owners and profile owners on the primary user. 337c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * The default value is <code>false</code>. 3380ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>This restriction has no effect on secondary users and managed profiles since only the 339150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * primary user can configure cell broadcasts. 34026af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 3410ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 3420ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 343068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 344068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 345d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 346d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 347d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; 348d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 349d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 35026af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from configuring mobile 351c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * networks. This can only be set by device owners and profile owners on the primary user. 352c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * The default value is <code>false</code>. 3530ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>This restriction has no effect on secondary users and managed profiles since only the 354150514bd03312ab0a890cc040019cfbc73eb077cAmith Yamasani * primary user can configure mobile networks. 35526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 3560ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 3570ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 358068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 359068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 360d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 361d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 362d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_MOBILE_NETWORKS = "no_config_mobile_networks"; 363d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 364d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 36526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from modifying 366c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * applications in Settings or launchers. The following actions will not be allowed when this 367c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * restriction is enabled: 368c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>uninstalling apps</li> 369c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>disabling apps</li> 370c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>clearing app caches</li> 371c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>clearing app data</li> 372c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>force stopping apps</li> 373c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>clearing app defaults</li> 374c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <p> 375c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * The default value is <code>false</code>. 37626af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 3770ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 3780ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 379068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 380068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 381d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 382d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 38336fbc8d6453da438a8ab83352ff1bcfcba5f25b5Julia Reynolds public static final String DISALLOW_APPS_CONTROL = "no_control_apps"; 384d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 385394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier /** 38626af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from mounting 387c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * physical external media. This can only be set by device owners and profile owners on the 388c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * primary user. The default value is <code>false</code>. 38926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 3900ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 3910ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 392068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 393068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 394394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #getUserRestrictions() 395394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier */ 396394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier public static final String DISALLOW_MOUNT_PHYSICAL_MEDIA = "no_physical_media"; 397394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier 398394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier /** 39926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from adjusting microphone 400c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * volume. If set, the microphone will be muted. This can only be set by device owners 401c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * and profile owners on the primary user. The default value is <code>false</code>. 40226af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 4030ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 4040ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 405068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 406068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 407394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #getUserRestrictions() 408394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier */ 409394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier public static final String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone"; 410394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier 411394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier /** 41226af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if a user is disallowed from adjusting the master 413c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * volume. If set, the master volume will be muted. This can only be set by device owners 414c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * and profile owners on the primary user. The default value is <code>false</code>. 41526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 4160ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 4170ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 418068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 419068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 420394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #getUserRestrictions() 421394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier */ 422394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier public static final String DISALLOW_ADJUST_VOLUME = "no_adjust_volume"; 423394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier 4249f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani /** 42526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies that the user is not allowed to make outgoing 426390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * phone calls. Emergency calls are still permitted. 427390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * The default value is <code>false</code>. 428eb83ab52b28766adf1743db76484515bc9b9e08aTony Mak * <p>This restriction has no effect on managed profiles. 42926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 4300ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 4310ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 432068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 433068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 434390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * @see #getUserRestrictions() 435390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani */ 436390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani public static final String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls"; 437390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani 438390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani /** 43926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies that the user is not allowed to send or receive 440c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * SMS messages. The default value is <code>false</code>. 44126af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 4420ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 4430ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 444068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 445068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 4469f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani * @see #getUserRestrictions() 4479f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani */ 448390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani public static final String DISALLOW_SMS = "no_sms"; 4499f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani 4501c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk /** 4512cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey * Specifies if the user is not allowed to have fun. In some cases, the 4522cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey * device owner may wish to prevent the user from experiencing amusement or 4532cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey * joy while using the device. The default value is <code>false</code>. 4542cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey * 4550ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 4560ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 457068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 458068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 4592cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey * @see #getUserRestrictions() 4602cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey */ 4612cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey public static final String DISALLOW_FUN = "no_fun"; 4622cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey 4632cc03e5606ad7cd473283898400506d5ac2237baJeff Sharkey /** 46426af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies that windows besides app windows should not be 4651c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * created. This will block the creation of the following types of windows. 4661c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_TOAST}</li> 4671c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_PHONE}</li> 4681c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_PRIORITY_PHONE}</li> 4691c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_SYSTEM_ALERT}</li> 4701c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_SYSTEM_ERROR}</li> 4711c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_SYSTEM_OVERLAY}</li> 4721c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * 473c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * <p>This can only be set by device owners and profile owners on the primary user. 474c34dc7cdeb5cae8ca4c731838aafe90ed4c9a2b8Amith Yamasani * The default value is <code>false</code>. 47526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 4760ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 4770ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 478068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 479068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 4801c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * @see #getUserRestrictions() 4811c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk */ 4821c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk public static final String DISALLOW_CREATE_WINDOWS = "no_create_windows"; 4831c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk 484f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot /** 48526af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if what is copied in the clipboard of this profile can 486f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * be pasted in related profiles. Does not restrict if the clipboard of related profiles can be 487f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * pasted in this profile. 488f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * The default value is <code>false</code>. 48926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 4900ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 4910ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 492068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 493068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 494f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * @see #getUserRestrictions() 495f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot */ 496f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot public static final String DISALLOW_CROSS_PROFILE_COPY_PASTE = "no_cross_profile_copy_paste"; 497f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot 49826af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani /** 49926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * Specifies if the user is not allowed to use NFC to beam out data from apps. 50026af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * The default value is <code>false</code>. 50126af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * 5020ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 5030ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 504068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 505068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 50626af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani * @see #getUserRestrictions() 50726af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani */ 50826af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani public static final String DISALLOW_OUTGOING_BEAM = "no_outgoing_beam"; 50926af829fd70609cf073b56e54e1f78faf83a5e8bAmith Yamasani 51053d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse /** 511f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * Hidden user restriction to disallow access to wallpaper manager APIs. This restriction 512f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * generally means that wallpapers are not supported for the particular user. This user 513f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * restriction is always set for managed profiles, because such profiles don't have wallpapers. 514f3ece36535d4999cf2bfd2175a33da6c3cdf298eBenjamin Franz * @hide 515f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * @see #DISALLOW_SET_WALLPAPER 516068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 517068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 518f3ece36535d4999cf2bfd2175a33da6c3cdf298eBenjamin Franz * @see #getUserRestrictions() 519f3ece36535d4999cf2bfd2175a33da6c3cdf298eBenjamin Franz */ 520f3ece36535d4999cf2bfd2175a33da6c3cdf298eBenjamin Franz public static final String DISALLOW_WALLPAPER = "no_wallpaper"; 521f3ece36535d4999cf2bfd2175a33da6c3cdf298eBenjamin Franz 522f3ece36535d4999cf2bfd2175a33da6c3cdf298eBenjamin Franz /** 523f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * User restriction to disallow setting a wallpaper. Profile owner and device owner 524f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * are able to set wallpaper regardless of this restriction. 525f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * The default value is <code>false</code>. 526f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * 527f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * <p>Key for user restrictions. 528f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * <p>Type: Boolean 529f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 530f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 531f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi * @see #getUserRestrictions() 532f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi */ 533f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi public static final String DISALLOW_SET_WALLPAPER = "no_set_wallpaper"; 534f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi 535f2519814cc7136773a115b770d20cf4c92945952Oleksandr Peletskyi /** 536bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz * Specifies if the user is not allowed to reboot the device into safe boot mode. 537bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz * This can only be set by device owners and profile owners on the primary user. 538bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz * The default value is <code>false</code>. 539bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz * 5400ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 5410ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 542068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 543068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 544bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz * @see #getUserRestrictions() 545bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz */ 546bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz public static final String DISALLOW_SAFE_BOOT = "no_safe_boot"; 547bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz 548bff46bac807ae8a9ebdc22c449a8d4f78711b4d2Benjamin Franz /** 549b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov * Specifies if a user is not allowed to record audio. This restriction is always enabled for 550b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov * background users. The default value is <code>false</code>. 551b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov * 552068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 553068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 554b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov * @see #getUserRestrictions() 555b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov * @hide 556b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov */ 557b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov public static final String DISALLOW_RECORD_AUDIO = "no_record_audio"; 558b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov 559b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov /** 5609cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * Specifies if a user is not allowed to run in the background and should be stopped during 5619cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * user switch. The default value is <code>false</code>. 5629cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * 5639cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * <p>This restriction can be set by device owners and profile owners. 5649cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * 5659cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 5669cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 5679cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * @see #getUserRestrictions() 5689cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov * @hide 5699cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov */ 5709cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov public static final String DISALLOW_RUN_IN_BACKGROUND = "no_run_in_background"; 5719cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov 5729cbfc9e212151e84910a22387365644916dde446Fyodor Kupolov /** 573759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki * Specifies if a user is not allowed to use the camera. 574759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki * 575759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 576759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 577759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki * @see #getUserRestrictions() 578759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki * @hide 579759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki */ 580759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki public static final String DISALLOW_CAMERA = "no_camera"; 581759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki 582759a763f5f03fda86b96d238faedb870fbee24ecMakoto Onuki /** 583dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra * Specifies if a user is not allowed to use cellular data when roaming. This can only be set by 584dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra * device owners. The default value is <code>false</code>. 585dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra * 586dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 587dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 588dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra * @see #getUserRestrictions() 589dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra */ 590dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra public static final String DISALLOW_DATA_ROAMING = "no_data_roaming"; 591dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra 592dea471ef548f09e04e178c5ec2d71a4b79bdb8f8Mahaver Chopra /** 5937f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * Specifies if a user is not allowed to change their icon. Device owner and profile owner 5947f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * can set this restriction. When it is set by device owner, only the target user will be 5957f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * affected. The default value is <code>false</code>. 5967f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * 5977f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * <p>Key for user restrictions. 5987f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * <p>Type: Boolean 5997f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 6007f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 6017f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi * @see #getUserRestrictions() 6027f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi */ 6037f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi public static final String DISALLOW_SET_USER_ICON = "no_set_user_icon"; 6047f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi 6057f1f1dfc8713fbecbab60cfbe14ab4d97d27deeeOleksandr Peletskyi /** 606f0029c1ddb2875583e62c6a3f96d288e21f2efe2Nicolas Prevot * Allows apps in the parent profile to handle web links from the managed profile. 607f0029c1ddb2875583e62c6a3f96d288e21f2efe2Nicolas Prevot * 6089edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * This user restriction has an effect only in a managed profile. 6099edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * If set: 6109edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * Intent filters of activities in the parent profile with action 6119edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * {@link android.content.Intent#ACTION_VIEW}, 6129edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * category {@link android.content.Intent#CATEGORY_BROWSABLE}, scheme http or https, and which 6139edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * define a host can handle intents from the managed profile. 6149edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * The default value is <code>false</code>. 6159edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * 6160ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for user restrictions. 6170ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 618068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#addUserRestriction(ComponentName, String) 619068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) 6209edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot * @see #getUserRestrictions() 6219edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot */ 622f0029c1ddb2875583e62c6a3f96d288e21f2efe2Nicolas Prevot public static final String ALLOW_PARENT_PROFILE_APP_LINKING 623f0029c1ddb2875583e62c6a3f96d288e21f2efe2Nicolas Prevot = "allow_parent_profile_app_linking"; 6249edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot 6259edbda18df025527e18614cf0c45d538a27af30fNicolas Prevot /** 62653d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * Application restriction key that is used to indicate the pending arrival 62753d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * of real restrictions for the app. 62853d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * 62953d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * <p> 63053d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * Applications that support restrictions should check for the presence of this key. 63153d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * A <code>true</code> value indicates that restrictions may be applied in the near 63253d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * future but are not available yet. It is the responsibility of any 63353d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * management application that sets this flag to update it when the final 63453d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * restrictions are enforced. 63553d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse * 6360ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Key for application restrictions. 6370ffbfea423e37f924d1e6d5a1023b848218f5623Fyodor Kupolov * <p>Type: Boolean 638b14ed95647ff7c38869550606396d5b784eeece1Nicolas Prevot * @see android.app.admin.DevicePolicyManager#setApplicationRestrictions( 639b14ed95647ff7c38869550606396d5b784eeece1Nicolas Prevot * android.content.ComponentName, String, Bundle) 640b14ed95647ff7c38869550606396d5b784eeece1Nicolas Prevot * @see android.app.admin.DevicePolicyManager#getApplicationRestrictions( 641b14ed95647ff7c38869550606396d5b784eeece1Nicolas Prevot * android.content.ComponentName, String) 64253d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse */ 64353d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse public static final String KEY_RESTRICTIONS_PENDING = "restrictions_pending"; 64453d63dcd04da3c1d5187b29f6530c2dcac9d516cSander Alewijnse 64512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani private static final String ACTION_CREATE_USER = "android.os.action.CREATE_USER"; 64612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 64712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 64812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Extra containing a name for the user being created. Optional parameter passed to 64912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * ACTION_CREATE_USER activity. 65012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 65112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 65212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public static final String EXTRA_USER_NAME = "android.os.extra.USER_NAME"; 65312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 65412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 65512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Extra containing account name for the user being created. Optional parameter passed to 65612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * ACTION_CREATE_USER activity. 65712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 65812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 65912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public static final String EXTRA_USER_ACCOUNT_NAME = "android.os.extra.USER_ACCOUNT_NAME"; 66012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 66112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 66212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Extra containing account type for the user being created. Optional parameter passed to 66312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * ACTION_CREATE_USER activity. 66412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 66512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 66612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public static final String EXTRA_USER_ACCOUNT_TYPE = "android.os.extra.USER_ACCOUNT_TYPE"; 66712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 66812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 66912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Extra containing account-specific data for the user being created. Optional parameter passed 67012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * to ACTION_CREATE_USER activity. 67112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 67212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 67312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public static final String EXTRA_USER_ACCOUNT_OPTIONS 67412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani = "android.os.extra.USER_ACCOUNT_OPTIONS"; 67512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 676655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** @hide */ 677655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani public static final int PIN_VERIFICATION_FAILED_INCORRECT = -3; 678655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** @hide */ 679655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani public static final int PIN_VERIFICATION_FAILED_NOT_SET = -2; 680655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** @hide */ 681655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani public static final int PIN_VERIFICATION_SUCCESS = -1; 682655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani 68337ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani /** 68437ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * Error result indicating that this user is not allowed to add other users on this device. 68537ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * This is a result code returned from the activity created by the intent 68637ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * {@link #createUserCreationIntent(String, String, String, PersistableBundle)}. 68737ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani */ 68837ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani public static final int USER_CREATION_FAILED_NOT_PERMITTED = Activity.RESULT_FIRST_USER; 68937ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani 69037ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani /** 69137ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * Error result indicating that no more users can be created on this device. 69237ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * This is a result code returned from the activity created by the intent 69337ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * {@link #createUserCreationIntent(String, String, String, PersistableBundle)}. 69437ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani */ 69537ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani public static final int USER_CREATION_FAILED_NO_MORE_USERS = Activity.RESULT_FIRST_USER + 1; 69637ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani 6977e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani /** @hide */ 698c0688301de5feea94c8456b3b9b42c41d0045f03Amith Yamasani public static UserManager get(Context context) { 699c0688301de5feea94c8456b3b9b42c41d0045f03Amith Yamasani return (UserManager) context.getSystemService(Context.USER_SERVICE); 70027db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani } 701a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 702258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** @hide */ 703258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public UserManager(Context context, IUserManager service) { 704258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani mService = service; 705258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani mContext = context; 706258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 707258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 708258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 7090696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * Returns whether this device supports multiple users with their own login and customizable 7100696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * space. 7110696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * @return whether the device supports multiple users. 712258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 7134673e7ea8d1f869910a9c0f9c211d4d27ad50b41Jeff Sharkey public static boolean supportsMultipleUsers() { 7141a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy return getMaxSupportedUsers() > 1 7151a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy && SystemProperties.getBoolean("fw.show_multiuserui", 7161a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy Resources.getSystem().getBoolean(R.bool.config_enableMultiUserUI)); 717258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 718258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 7196794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall /** 7207cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen * @hide 7217cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen * @return Whether the device is running with split system user. It means the system user and 7227cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen * primary user are two separate users. Previously system user and primary user are combined as 7237cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen * a single owner user. see @link {android.os.UserHandle#USER_OWNER} 7247cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen */ 7257cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen public static boolean isSplitSystemUser() { 7267cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen return SystemProperties.getBoolean("ro.fw.system_user_split", false); 7277cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen } 7287cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen 7297cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen /** 730523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov * Returns whether switching users is currently allowed. 731523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov * <p>For instance switching users is not allowed if the current user is in a phone call, 732523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov * or system user hasn't been unlocked yet 733523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov * @hide 734523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov */ 735523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov public boolean canSwitchUsers() { 736523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov boolean allowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt( 737523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov mContext.getContentResolver(), 738523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED, 0) != 0; 739523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov boolean isSystemUserUnlocked = isUserUnlocked(UserHandle.SYSTEM); 740523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov boolean inCall = TelephonyManager.getDefault().getCallState() 741523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov != TelephonyManager.CALL_STATE_IDLE; 742523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov return (allowUserSwitchingWhenSystemUserLocked || isSystemUserUnlocked) && !inCall; 743523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov } 744523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov 745523c404612c634f6901205fee4f4cae594f62982Fyodor Kupolov /** 7465760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani * Returns the user handle for the user that this process is running under. 747be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * 7485760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani * @return the user handle of this process. 749258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 7506794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall */ 7518588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public @UserIdInt int getUserHandle() { 75279af1dd54c16cde063152922b42c96d72ae9eca8Dianne Hackborn return UserHandle.myUserId(); 753258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 754258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 755258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 7568832c18d8b63367929c2d394c9c508f56003d400Dianne Hackborn * Returns the user name of the user making this call. This call is only 7578832c18d8b63367929c2d394c9c508f56003d400Dianne Hackborn * available to applications on the system image; it requires the 7588832c18d8b63367929c2d394c9c508f56003d400Dianne Hackborn * MANAGE_USERS permission. 759258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the user name 760258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 761258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public String getUserName() { 762258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 763258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return mService.getUserInfo(getUserHandle()).name; 764258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 765f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 766258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 767258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 768258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 76967a101aa3006aa2011a9d9edaacb2fa6f6f31140Dianne Hackborn /** 770e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill * Used to determine whether the user making this call is subject to 771e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill * teleportations. 77267a101aa3006aa2011a9d9edaacb2fa6f6f31140Dianne Hackborn * 773955d8d69ea6caabce1461dc25b339b9bf9dc61a6Dianne Hackborn * <p>As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method can 77467a101aa3006aa2011a9d9edaacb2fa6f6f31140Dianne Hackborn * now automatically identify goats using advanced goat recognition technology.</p> 77567a101aa3006aa2011a9d9edaacb2fa6f6f31140Dianne Hackborn * 77667a101aa3006aa2011a9d9edaacb2fa6f6f31140Dianne Hackborn * @return Returns true if the user making this call is a goat. 777e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill */ 778e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill public boolean isUserAGoat() { 779988ae30ff7729ac0e9a44ee665c7e00f1961e7cdAdam Powell return mContext.getPackageManager() 780988ae30ff7729ac0e9a44ee665c7e00f1961e7cdAdam Powell .isPackageAvailable("com.coffeestainstudios.goatsimulator"); 781e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill } 782df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 783df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani /** 78470f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * Used to check if this process is running under the primary user. The primary user 78570f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * is the first human user on a device. 78670f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * 78770f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * @return whether this process is running under the primary user. 78870f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * @hide 78970f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen */ 79070f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen public boolean isPrimaryUser() { 79170f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen UserInfo user = getUserInfo(UserHandle.myUserId()); 79270f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen return user != null ? user.isPrimary() : false; 79370f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen } 79470f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen 79570f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen /** 7965760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani * Used to check if this process is running under the system user. The system user 7975760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani * is the initial user that is implicitly created on first boot and hosts most of the 7985760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani * system services. 7995760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani * 8005760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani * @return whether this process is running under the system user. 8015760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani */ 8025760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani public boolean isSystemUser() { 80370f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen return UserHandle.myUserId() == UserHandle.USER_SYSTEM; 8045760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani } 8052b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen 8065760e1786bcc2feac9d1c2c784520aa4d6cf8cb8Amith Yamasani /** 807462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani * @hide 808462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani * Returns whether the caller is running as an admin user. There can be more than one admin 809462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani * user. 810462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani */ 811462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani public boolean isAdminUser() { 8122b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen return isUserAdmin(UserHandle.myUserId()); 8132b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen } 8142b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen 8152b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen /** 8162b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen * @hide 8172b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen * Returns whether the provided user is an admin user. There can be more than one admin 8182b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen * user. 8192b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen */ 8208588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean isUserAdmin(@UserIdInt int userId) { 8212b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen UserInfo user = getUserInfo(userId); 8222b45f8a6ce623012b2fc6237acd1bdc6ebe2c85cXiaohui Chen return user != null && user.isAdmin(); 823462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani } 824462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani 825462ac3a2aa5e1c974d056dc7221805e2b8ac7823Amith Yamasani /** 826e1375908a5f05e5c926e95049970c4505e4dfad9Amith Yamasani * Used to check if the user making this call is linked to another user. Linked users may have 82746bc4ebb87232b39d7b02ac0135c8ccf2c33f233Amith Yamasani * a reduced number of available apps, app restrictions and account restrictions. 828e1375908a5f05e5c926e95049970c4505e4dfad9Amith Yamasani * @return whether the user making this call is a linked user 8292555dafce87e60fae28d71913730abf73e40fcd7Amith Yamasani * @hide 830df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */ 831e1375908a5f05e5c926e95049970c4505e4dfad9Amith Yamasani public boolean isLinkedUser() { 832df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani try { 83371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani return mService.isRestricted(); 834df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } catch (RemoteException re) { 835f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 836df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 837df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 838df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 839258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 8401c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov * Checks if specified user can have restricted profile. 8411c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov * @hide 8421c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov */ 8438588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean canHaveRestrictedProfile(@UserIdInt int userId) { 8441c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov try { 8451c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov return mService.canHaveRestrictedProfile(userId); 8461c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov } catch (RemoteException re) { 847f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 8481c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov } 8491c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov } 8501c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov 8511c36315a36962321dfe870b07e28b04a1d6777e9Fyodor Kupolov /** 8521e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * Checks if the calling app is running as a guest user. 8531e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @return whether the caller is a guest user. 8541e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @hide 8551e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani */ 8561e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani public boolean isGuestUser() { 8571e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani UserInfo user = getUserInfo(UserHandle.myUserId()); 8581e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani return user != null ? user.isGuest() : false; 8591e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani } 8601e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani 8611e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani /** 8620e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani * Checks if the calling app is running in a managed profile. 8630e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 8640e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani * 8650e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani * @return whether the caller is in a managed profile. 8660e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani * @hide 8670e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani */ 8680e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani @SystemApi 8690e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani public boolean isManagedProfile() { 8708673b2899e775014336efff44ea88dcac2b25bddTony Mak try { 8718673b2899e775014336efff44ea88dcac2b25bddTony Mak return mService.isManagedProfile(UserHandle.myUserId()); 8728673b2899e775014336efff44ea88dcac2b25bddTony Mak } catch (RemoteException re) { 8738673b2899e775014336efff44ea88dcac2b25bddTony Mak throw re.rethrowFromSystemServer(); 8748673b2899e775014336efff44ea88dcac2b25bddTony Mak } 8758673b2899e775014336efff44ea88dcac2b25bddTony Mak } 8768673b2899e775014336efff44ea88dcac2b25bddTony Mak 8778673b2899e775014336efff44ea88dcac2b25bddTony Mak /** 8788673b2899e775014336efff44ea88dcac2b25bddTony Mak * Checks if the specified user is a managed profile. 8798673b2899e775014336efff44ea88dcac2b25bddTony Mak * Requires {@link android.Manifest.permission#MANAGE_USERS} permission, otherwise the caller 8808673b2899e775014336efff44ea88dcac2b25bddTony Mak * must be in the same profile group of specified user. 8818673b2899e775014336efff44ea88dcac2b25bddTony Mak * 8828673b2899e775014336efff44ea88dcac2b25bddTony Mak * @return whether the specified user is a managed profile. 8838673b2899e775014336efff44ea88dcac2b25bddTony Mak * @hide 8848673b2899e775014336efff44ea88dcac2b25bddTony Mak */ 8858673b2899e775014336efff44ea88dcac2b25bddTony Mak @SystemApi 8868673b2899e775014336efff44ea88dcac2b25bddTony Mak public boolean isManagedProfile(@UserIdInt int userId) { 8878673b2899e775014336efff44ea88dcac2b25bddTony Mak try { 8888673b2899e775014336efff44ea88dcac2b25bddTony Mak return mService.isManagedProfile(userId); 8898673b2899e775014336efff44ea88dcac2b25bddTony Mak } catch (RemoteException re) { 8908673b2899e775014336efff44ea88dcac2b25bddTony Mak throw re.rethrowFromSystemServer(); 8918673b2899e775014336efff44ea88dcac2b25bddTony Mak } 8920e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani } 8930e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani 8940e8d7d63ba439cc0604af7055679dae3d30fdc48Amith Yamasani /** 895c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova * Checks if the calling app is running as an ephemeral user. 896c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova * 897c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova * @return whether the caller is an ephemeral user. 898c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova * @hide 899c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova */ 900c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova public boolean isEphemeralUser() { 901c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova return isUserEphemeral(UserHandle.myUserId()); 902c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova } 903c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova 904c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova /** 905c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova * Returns whether the specified user is ephemeral. 906c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova * @hide 907c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova */ 9088588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean isUserEphemeral(@UserIdInt int userId) { 909c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova final UserInfo user = getUserInfo(userId); 910c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova return user != null && user.isEphemeral(); 911c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova } 912c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova 913c4dd021322d38ea32ac49930e904b6d08ce6490cLenka Trochtova /** 914a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * Return whether the given user is actively running. This means that 915a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * the user is in the "started" state, not "stopped" -- it is currently 916a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * allowed to run code through scheduled alarms, receiving broadcasts, 917a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * etc. A started user may be either the current foreground user or a 918a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * background user; the result here does not distinguish between the two. 919a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * @param user The user to retrieve the running state for. 920a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn */ 921a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn public boolean isUserRunning(UserHandle user) { 9220e62384ccbd00e9f78851929ca88b919679ee32eJeff Sharkey return isUserRunning(user.getIdentifier()); 9230e62384ccbd00e9f78851929ca88b919679ee32eJeff Sharkey } 9240e62384ccbd00e9f78851929ca88b919679ee32eJeff Sharkey 9250e62384ccbd00e9f78851929ca88b919679ee32eJeff Sharkey /** {@hide} */ 9260e62384ccbd00e9f78851929ca88b919679ee32eJeff Sharkey public boolean isUserRunning(int userId) { 927ac06a4907bff7d5ee0612dbb85180222e1455791Fyodor Kupolov // TODO Switch to using UMS internal isUserRunning 928a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn try { 9290e62384ccbd00e9f78851929ca88b919679ee32eJeff Sharkey return ActivityManagerNative.getDefault().isUserRunning(userId, 0); 93027b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 931f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 932a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 933a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 934a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn 935a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn /** 936a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * Return whether the given user is actively running <em>or</em> stopping. 937a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * This is like {@link #isUserRunning(UserHandle)}, but will also return 938a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * true if the user had been running but is in the process of being stopped 939a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * (but is not yet fully stopped, and still running some code). 940a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * @param user The user to retrieve the running state for. 941a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn */ 942a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn public boolean isUserRunningOrStopping(UserHandle user) { 943a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn try { 944e17ac1569793c333bb4dce86607a342e7c982ae7Jeff Sharkey // TODO: reconcile stopped vs stopping? 945a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn return ActivityManagerNative.getDefault().isUserRunning( 946e17ac1569793c333bb4dce86607a342e7c982ae7Jeff Sharkey user.getIdentifier(), ActivityManager.FLAG_OR_STOPPED); 94727b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 948f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 949a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 950a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 951a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn 9528a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey /** @removed */ 953b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey @Deprecated 954e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey public boolean isUserRunningAndLocked() { 955e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey return isUserRunningAndLocked(Process.myUserHandle()); 956e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey } 957e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey 9588a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey /** @removed */ 959b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey @Deprecated 9609d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey public boolean isUserRunningAndLocked(UserHandle user) { 9619d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey try { 9629d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey return ActivityManagerNative.getDefault().isUserRunning( 9639d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey user.getIdentifier(), ActivityManager.FLAG_AND_LOCKED); 96427b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 965f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 9669d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey } 9679d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey } 9689d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey 9698a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey /** @removed */ 970b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey @Deprecated 971e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey public boolean isUserRunningAndUnlocked() { 972e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey return isUserRunningAndUnlocked(Process.myUserHandle()); 973e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey } 974e13529a4adb60e5a18c2e36ce6c5bf8f2d1db78fJeff Sharkey 9758a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey /** @removed */ 976b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey @Deprecated 9779d8a1048bb666c68402dce031bebfa07c92a42dbJeff Sharkey public boolean isUserRunningAndUnlocked(UserHandle user) { 9780825ab284c01402d030a24471ac5a6491d79d28bJeff Sharkey try { 9790825ab284c01402d030a24471ac5a6491d79d28bJeff Sharkey return ActivityManagerNative.getDefault().isUserRunning( 9800825ab284c01402d030a24471ac5a6491d79d28bJeff Sharkey user.getIdentifier(), ActivityManager.FLAG_AND_UNLOCKED); 98127b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 982f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 9830825ab284c01402d030a24471ac5a6491d79d28bJeff Sharkey } 9840825ab284c01402d030a24471ac5a6491d79d28bJeff Sharkey } 9850825ab284c01402d030a24471ac5a6491d79d28bJeff Sharkey 9860825ab284c01402d030a24471ac5a6491d79d28bJeff Sharkey /** 987cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * Return whether the calling user is running in an "unlocked" state. 988cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * <p> 989cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * On devices with direct boot, a user is unlocked only after they've 990cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * entered their credentials (such as a lock pattern or PIN). On devices 991cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * without direct boot, a user is unlocked as soon as it starts. 992cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * <p> 993cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * When a user is locked, only device-protected data storage is available. 994cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * When a user is unlocked, both device-protected and credential-protected 995cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * private app data storage is available. 9968a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey * 9978a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey * @see Intent#ACTION_USER_UNLOCKED 9988a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey * @see Context#createDeviceProtectedStorageContext() 999b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey */ 1000b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey public boolean isUserUnlocked() { 1001b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey return isUserUnlocked(Process.myUserHandle()); 1002b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey } 1003b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey 1004b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey /** 1005cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * Return whether the given user is running in an "unlocked" state. 1006cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * <p> 1007cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * On devices with direct boot, a user is unlocked only after they've 1008cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * entered their credentials (such as a lock pattern or PIN). On devices 1009cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * without direct boot, a user is unlocked as soon as it starts. 1010cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * <p> 1011cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * When a user is locked, only device-protected data storage is available. 1012cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * When a user is unlocked, both device-protected and credential-protected 1013cf3f0a11a83e7a798e0586a78efdafc82a7f3d08Jeff Sharkey * private app data storage is available. 1014b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey * 1015b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey * @param user to retrieve the unlocked state for. 10168a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey * @see Intent#ACTION_USER_UNLOCKED 10178a372a0a280127743ce9a7ce4b6198c7a02d2a4fJeff Sharkey * @see Context#createDeviceProtectedStorageContext() 1018b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey */ 1019b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey public boolean isUserUnlocked(UserHandle user) { 10200999c0d6e9c83873d9595ee764b6388dbc49dcb8Jeff Sharkey return isUserUnlocked(user.getIdentifier()); 10210999c0d6e9c83873d9595ee764b6388dbc49dcb8Jeff Sharkey } 10220999c0d6e9c83873d9595ee764b6388dbc49dcb8Jeff Sharkey 10230999c0d6e9c83873d9595ee764b6388dbc49dcb8Jeff Sharkey /** {@hide} */ 10248588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean isUserUnlocked(@UserIdInt int userId) { 1025ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey try { 1026ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey return ActivityManagerNative.getDefault().isUserRunning(userId, 1027ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey ActivityManager.FLAG_AND_UNLOCKED); 1028ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey } catch (RemoteException re) { 1029ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey throw re.rethrowFromSystemServer(); 1030ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey } 1031ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey } 1032ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey 1033ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey /** {@hide} */ 1034ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey public boolean isUserUnlockingOrUnlocked(UserHandle user) { 1035ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey return isUserUnlockingOrUnlocked(user.getIdentifier()); 1036ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey } 1037ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey 1038ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey /** {@hide} */ 1039ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey public boolean isUserUnlockingOrUnlocked(@UserIdInt int userId) { 10406c915ead38db0a2a6393c40d4fbac959399439c5Fyodor Kupolov // TODO Switch to using UMS internal isUserUnlockingOrUnlocked 1041ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey try { 1042ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey return ActivityManagerNative.getDefault().isUserRunning(userId, 1043ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey ActivityManager.FLAG_AND_UNLOCKING_OR_UNLOCKED); 1044ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey } catch (RemoteException re) { 1045ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey throw re.rethrowFromSystemServer(); 1046ce18c8167766f92856f94a8e88e19de4698960e6Jeff Sharkey } 1047b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey } 1048b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey 1049b642387b43417e2f342a1bc16e4f639b5d6c4b97Jeff Sharkey /** 1050258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Returns the UserInfo object describing a specific user. 10518673b2899e775014336efff44ea88dcac2b25bddTony Mak * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1052258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the user handle of the user whose information is being requested. 1053258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the UserInfo object for a specific user. 1054258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1055b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn */ 10568588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public UserInfo getUserInfo(@UserIdInt int userHandle) { 1057258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1058258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return mService.getUserInfo(userHandle); 1059258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1060f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1061258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1062258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1063258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 106471e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 1065e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @hide 1066e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * 1067e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * Returns who set a user restriction on a user. 1068e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1069e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @param restrictionKey the string key representing the restriction 1070e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @param userHandle the UserHandle of the user for whom to retrieve the restrictions. 1071e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * @return The source of user restriction. Any combination of {@link #RESTRICTION_NOT_SET}, 1072e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * {@link #RESTRICTION_SOURCE_SYSTEM}, {@link #RESTRICTION_SOURCE_DEVICE_OWNER} 1073e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban * and {@link #RESTRICTION_SOURCE_PROFILE_OWNER} 1074e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban */ 1075e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @SystemApi 1076e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban @UserRestrictionSource 1077e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban public int getUserRestrictionSource(String restrictionKey, UserHandle userHandle) { 1078e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban try { 1079e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban return mService.getUserRestrictionSource(restrictionKey, userHandle.getIdentifier()); 1080e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban } catch (RemoteException re) { 1081e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban throw re.rethrowFromSystemServer(); 1082e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban } 1083e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban } 1084e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban 1085e783460274047ab38e3b9c4294339ff130fe566cZoltan Szatmary-Ban /** 108671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Returns the user-wide restrictions imposed on this user. 108771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @return a Bundle containing all the restrictions. 108871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 1089e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public Bundle getUserRestrictions() { 1090e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani return getUserRestrictions(Process.myUserHandle()); 1091e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 1092e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 109371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 109471e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Returns the user-wide restrictions imposed on the user specified by <code>userHandle</code>. 109571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param userHandle the UserHandle of the user for whom to retrieve the restrictions. 109671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @return a Bundle containing all the restrictions. 109771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 1098e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public Bundle getUserRestrictions(UserHandle userHandle) { 1099e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani try { 1100e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani return mService.getUserRestrictions(userHandle.getIdentifier()); 1101e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } catch (RemoteException re) { 1102f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1103e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 1104e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 1105e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 11063bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban /** 11073bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban * @hide 11083bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban * Returns whether the given user has been disallowed from performing certain actions 11093bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban * or setting certain settings through UserManager. This method disregards restrictions 11103bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban * set by device policy. 11113bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban * @param restrictionKey the string key representing the restriction 11123bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban * @param userHandle the UserHandle of the user for whom to retrieve the restrictions. 11133bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban */ 11143bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban public boolean hasBaseUserRestriction(String restrictionKey, UserHandle userHandle) { 11153bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban try { 11163bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban return mService.hasBaseUserRestriction(restrictionKey, userHandle.getIdentifier()); 11173bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban } catch (RemoteException re) { 1118f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 11193bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban } 11203bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban } 11213bbceddb94d627495c0022d6e3f92a5cb16aebeaZoltan Szatmary-Ban 112271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 1123a3c1250a2fc36e7315b377b1babe9d03ae41721aMakoto Onuki * This will no longer work. Device owners and profile owners should use 1124a3c1250a2fc36e7315b377b1babe9d03ae41721aMakoto Onuki * {@link DevicePolicyManager#addUserRestriction(ComponentName, String)} instead. 112571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 1126a3c1250a2fc36e7315b377b1babe9d03ae41721aMakoto Onuki // System apps should use UserManager.setUserRestriction() instead. 11273d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 1128e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public void setUserRestrictions(Bundle restrictions) { 1129068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki throw new UnsupportedOperationException("This method is no longer supported"); 1130e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 1131e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 113271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 1133a3c1250a2fc36e7315b377b1babe9d03ae41721aMakoto Onuki * This will no longer work. Device owners and profile owners should use 1134a3c1250a2fc36e7315b377b1babe9d03ae41721aMakoto Onuki * {@link DevicePolicyManager#addUserRestriction(ComponentName, String)} instead. 113571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 1136a3c1250a2fc36e7315b377b1babe9d03ae41721aMakoto Onuki // System apps should use UserManager.setUserRestriction() instead. 11373d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 1138e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public void setUserRestrictions(Bundle restrictions, UserHandle userHandle) { 1139068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki throw new UnsupportedOperationException("This method is no longer supported"); 1140e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 1141e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 114271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 114371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Sets the value of a specific restriction. 1144be46532c9fbebf3ab6498c1b78013a33f620cd31Amith Yamasani * Requires the MANAGE_USERS permission. 114571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param key the key of the restriction 114671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param value the value for the restriction 11473d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * @deprecated use {@link android.app.admin.DevicePolicyManager#addUserRestriction( 11483d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} or 11493d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * {@link android.app.admin.DevicePolicyManager#clearUserRestriction( 11503d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} instead. 115171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 11523d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 115371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public void setUserRestriction(String key, boolean value) { 1154068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki setUserRestriction(key, value, Process.myUserHandle()); 115571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani } 115671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani 115771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 115871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @hide 115971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Sets the value of a specific restriction on a specific user. 1160be46532c9fbebf3ab6498c1b78013a33f620cd31Amith Yamasani * Requires the MANAGE_USERS permission. 116171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param key the key of the restriction 116271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param value the value for the restriction 116371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param userHandle the user whose restriction is to be changed. 11643d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * @deprecated use {@link android.app.admin.DevicePolicyManager#addUserRestriction( 11653d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} or 11663d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * {@link android.app.admin.DevicePolicyManager#clearUserRestriction( 11673d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} instead. 116871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 11693d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 11706794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall public void setUserRestriction(String key, boolean value, UserHandle userHandle) { 1171b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov try { 1172b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov mService.setUserRestriction(key, value, userHandle.getIdentifier()); 1173b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov } catch (RemoteException re) { 1174f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1175b501330a1b6ef14ff512a5727f7a01bc423d6fbbFyodor Kupolov } 11766794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall } 11776794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 1178258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 1179a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Returns whether the current user has been disallowed from performing certain actions 1180a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * or setting certain settings. 11812b2cf72f10f13d9314a1c53386188ed48e12d47cJulia Reynolds * 11822b2cf72f10f13d9314a1c53386188ed48e12d47cJulia Reynolds * @param restrictionKey The string key representing the restriction. 11832b2cf72f10f13d9314a1c53386188ed48e12d47cJulia Reynolds * @return {@code true} if the current user has the given restriction, {@code false} otherwise. 1184a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 1185a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public boolean hasUserRestriction(String restrictionKey) { 1186b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie return hasUserRestriction(restrictionKey, Process.myUserHandle()); 1187b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie } 1188b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie 1189b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie /** 1190b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * @hide 1191b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * Returns whether the given user has been disallowed from performing certain actions 1192b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * or setting certain settings. 1193b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * @param restrictionKey the string key representing the restriction 1194b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * @param userHandle the UserHandle of the user for whom to retrieve the restrictions. 1195b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie */ 1196b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie public boolean hasUserRestriction(String restrictionKey, UserHandle userHandle) { 11978cd28b57ed732656d002d97879e15c5695b54fffAmith Yamasani try { 11988cd28b57ed732656d002d97879e15c5695b54fffAmith Yamasani return mService.hasUserRestriction(restrictionKey, 11998cd28b57ed732656d002d97879e15c5695b54fffAmith Yamasani userHandle.getIdentifier()); 12008cd28b57ed732656d002d97879e15c5695b54fffAmith Yamasani } catch (RemoteException re) { 1201f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 12028cd28b57ed732656d002d97879e15c5695b54fffAmith Yamasani } 1203a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall } 1204a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 1205a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 120633f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * Return the serial number for a user. This is a device-unique 1207b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * number assigned to that user; if the user is deleted and then a new 1208b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * user created, the new users will not be given the same serial number. 120933f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @param user The user whose serial number is to be retrieved. 1210b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * @return The serial number of the given user; returns -1 if the 1211b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * given UserHandle does not exist. 121233f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @see #getUserForSerialNumber(long) 121333f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn */ 121433f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn public long getSerialNumberForUser(UserHandle user) { 121533f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn return getUserSerialNumber(user.getIdentifier()); 121633f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn } 121733f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn 121833f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn /** 121933f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * Return the user associated with a serial number previously 122033f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * returned by {@link #getSerialNumberForUser(UserHandle)}. 122133f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @param serialNumber The serial number of the user that is being 122233f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * retrieved. 122333f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @return Return the user associated with the serial number, or null 122433f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * if there is not one. 122533f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @see #getSerialNumberForUser(UserHandle) 122633f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn */ 122733f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn public UserHandle getUserForSerialNumber(long serialNumber) { 1228ef24909d84db9d5aefb825ee1556089fcdcc1678Fyodor Kupolov int ident = getUserHandle((int) serialNumber); 122933f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn return ident >= 0 ? new UserHandle(ident) : null; 123033f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn } 123133f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn 123233f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn /** 1233cfe64c8afa9f30d8874c72440c3992e79fdb60c9Xiaohui Chen * Creates a user with the specified name and options. For non-admin users, default user 1234cfe64c8afa9f30d8874c72440c3992e79fdb60c9Xiaohui Chen * restrictions are going to be applied. 12351952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1236258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 1237258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param name the user's name 1238258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param flags flags that identify the type of user and other properties. 1239258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @see UserInfo 1240258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 1241258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the UserInfo object for the created user, or null if the user could not be created. 1242258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1243258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 1244258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public UserInfo createUser(String name, int flags) { 1245cfe64c8afa9f30d8874c72440c3992e79fdb60c9Xiaohui Chen UserInfo user = null; 1246258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1247cfe64c8afa9f30d8874c72440c3992e79fdb60c9Xiaohui Chen user = mService.createUser(name, flags); 1248e9c440638e27a123a82feb5e4677ce1242785288phweiss // TODO: Keep this in sync with 1249e9c440638e27a123a82feb5e4677ce1242785288phweiss // UserManagerService.LocalService.createUserEvenWhenDisallowed 1250cfe64c8afa9f30d8874c72440c3992e79fdb60c9Xiaohui Chen if (user != null && !user.isAdmin()) { 1251068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki mService.setUserRestriction(DISALLOW_SMS, true, user.id); 1252068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki mService.setUserRestriction(DISALLOW_OUTGOING_CALLS, true, user.id); 1253cfe64c8afa9f30d8874c72440c3992e79fdb60c9Xiaohui Chen } 1254258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1255f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1256258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1257cfe64c8afa9f30d8874c72440c3992e79fdb60c9Xiaohui Chen return user; 1258258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1259258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1260258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 12611e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * Creates a guest user and configures it. 12621e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @param context an application context 12631e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @param name the name to set for the user 12641e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @hide 12651e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani */ 12661e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani public UserInfo createGuest(Context context, String name) { 1267068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki UserInfo guest = null; 1268068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki try { 1269068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki guest = mService.createUser(name, UserInfo.FLAG_GUEST); 1270068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki if (guest != null) { 1271068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki Settings.Secure.putStringForUser(context.getContentResolver(), 1272068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki Settings.Secure.SKIP_FIRST_USE_HINTS, "1", guest.id); 1273bf3a9465483976dcd5692b619b47132c2b95f73eAmith Yamasani } 1274068c54a5be697c3df4657dcda33cd17c4b547710Makoto Onuki } catch (RemoteException re) { 1275f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 12761e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani } 12771e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani return guest; 12781e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani } 12791e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani 1280aa6634eaca707f7cbf5f5a1d75b90d8d775d254bAmith Yamasani /** 12812a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * Creates a user with the specified name and options as a profile of another user. 1282a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1283a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * 1284a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @param name the user's name 1285a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @param flags flags that identify the type of user and other properties. 1286a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @see UserInfo 12872a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @param userHandle new user will be a profile of this use. 1288a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * 1289a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @return the UserInfo object for the created user, or null if the user could not be created. 1290a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @hide 1291a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy */ 12928588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle) { 1293a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy try { 12942a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy return mService.createProfileForUser(name, flags, userHandle); 1295a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } catch (RemoteException re) { 1296f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1297a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 1298a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 1299a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy 1300a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy /** 130102cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov * Creates a restricted profile with the specified name. This method also sets necessary 130202cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov * restrictions and adds shared accounts. 130306a484adb93c6c969321147b07112684383305f6Fyodor Kupolov * 130406a484adb93c6c969321147b07112684383305f6Fyodor Kupolov * @param name profile's name 130506a484adb93c6c969321147b07112684383305f6Fyodor Kupolov * @return UserInfo object for the created user, or null if the user could not be created. 130606a484adb93c6c969321147b07112684383305f6Fyodor Kupolov * @hide 130706a484adb93c6c969321147b07112684383305f6Fyodor Kupolov */ 130806a484adb93c6c969321147b07112684383305f6Fyodor Kupolov public UserInfo createRestrictedProfile(String name) { 130906a484adb93c6c969321147b07112684383305f6Fyodor Kupolov try { 131002cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov UserHandle parentUserHandle = Process.myUserHandle(); 131102cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov UserInfo user = mService.createRestrictedProfile(name, 131202cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov parentUserHandle.getIdentifier()); 131302cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov if (user != null) { 131402cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov AccountManager.get(mContext).addSharedAccountsFromParentUser(parentUserHandle, 131502cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov UserHandle.of(user.id)); 131606a484adb93c6c969321147b07112684383305f6Fyodor Kupolov } 131702cb6e773b323a0d54b21f43460a23f668b7727cFyodor Kupolov return user; 131827b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 1319f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 132006a484adb93c6c969321147b07112684383305f6Fyodor Kupolov } 132106a484adb93c6c969321147b07112684383305f6Fyodor Kupolov } 132206a484adb93c6c969321147b07112684383305f6Fyodor Kupolov 132306a484adb93c6c969321147b07112684383305f6Fyodor Kupolov /** 13240696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * Returns an intent to create a user for the provided name and account name. The name 13250696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * and account name will be used when the setup process for the new user is started. 13260696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * <p> 132712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * The intent should be launched using startActivityForResult and the return result will 132837ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * indicate if the user consented to adding a new user and if the operation succeeded. Any 132937ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * errors in creating the user will be returned in the result code. If the user cancels the 133037ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * request, the return result will be {@link Activity#RESULT_CANCELED}. On success, the 133137ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * result code will be {@link Activity#RESULT_OK}. 13320696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * <p> 13330696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * Use {@link #supportsMultipleUsers()} to first check if the device supports this operation 13340696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * at all. 13350696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * <p> 133612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * The new user is created but not initialized. After switching into the user for the first 133712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * time, the preferred user name and account information are used by the setup process for that 133812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * user. 133912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * 134012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param userName Optional name to assign to the user. 13410696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * @param accountName Optional account name that will be used by the setup wizard to initialize 134212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * the user. 134312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param accountType Optional account type for the account to be created. This is required 134412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * if the account name is specified. 134512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param accountOptions Optional bundle of data to be passed in during account creation in the 134612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * new user via {@link AccountManager#addAccount(String, String, String[], 134712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Bundle, android.app.Activity, android.accounts.AccountManagerCallback, 134812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Handler)}. 13490696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * @return An Intent that can be launched from an Activity. 135037ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * @see #USER_CREATION_FAILED_NOT_PERMITTED 135137ed8d1ce0ffa1e570e868a357b6cb6d509c4e91Amith Yamasani * @see #USER_CREATION_FAILED_NO_MORE_USERS 13520696434c623dced9fe9ed3873f59b64334f240e7Amith Yamasani * @see #supportsMultipleUsers 135312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 135412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public static Intent createUserCreationIntent(@Nullable String userName, 135512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani @Nullable String accountName, 135612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani @Nullable String accountType, @Nullable PersistableBundle accountOptions) { 135712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani Intent intent = new Intent(ACTION_CREATE_USER); 135812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani if (userName != null) { 135912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani intent.putExtra(EXTRA_USER_NAME, userName); 136012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 136112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani if (accountName != null && accountType == null) { 136212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani throw new IllegalArgumentException("accountType must be specified if accountName is " 136312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani + "specified"); 136412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 136512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani if (accountName != null) { 136612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani intent.putExtra(EXTRA_USER_ACCOUNT_NAME, accountName); 136712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 136812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani if (accountType != null) { 136912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani intent.putExtra(EXTRA_USER_ACCOUNT_TYPE, accountType); 137012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 137112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani if (accountOptions != null) { 137212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani intent.putExtra(EXTRA_USER_ACCOUNT_OPTIONS, accountOptions); 137312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 137412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani return intent; 137512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 137612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 137712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 137812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 137912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * 138012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Returns the preferred account name for user creation. Requires MANAGE_USERS permission. 138112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 138212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani @SystemApi 138312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public String getSeedAccountName() { 138412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani try { 138512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani return mService.getSeedAccountName(); 138612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } catch (RemoteException re) { 1387f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 138812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 138912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 139012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 139112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 139212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 139312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * 139412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Returns the preferred account type for user creation. Requires MANAGE_USERS permission. 139512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 139612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani @SystemApi 139712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public String getSeedAccountType() { 139812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani try { 139912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani return mService.getSeedAccountType(); 140012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } catch (RemoteException re) { 1401f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 140212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 140312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 140412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 140512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 140612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 140712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * 140812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Returns the preferred account's options bundle for user creation. Requires MANAGE_USERS 140912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * permission. 141012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @return Any options set by the requestor that created the user. 141112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 141212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani @SystemApi 141312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public PersistableBundle getSeedAccountOptions() { 141412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani try { 141512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani return mService.getSeedAccountOptions(); 141612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } catch (RemoteException re) { 1417f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 141812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 141912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 142012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 142112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 142212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 142312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * 142412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Called by a system activity to set the seed account information of a user created 142512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * through the user creation intent. 142612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param userId 142712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param accountName 142812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param accountType 142912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param accountOptions 143012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @see #createUserCreationIntent(String, String, String, PersistableBundle) 143112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 143212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public void setSeedAccountData(int userId, String accountName, String accountType, 143312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani PersistableBundle accountOptions) { 143412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani try { 143512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani mService.setSeedAccountData(userId, accountName, accountType, accountOptions, 143612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /* persist= */ true); 143712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } catch (RemoteException re) { 1438f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 143912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 144012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 144112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 144212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 144312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 144412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Clears the seed information used to create this user. Requires MANAGE_USERS permission. 144512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 144612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani @SystemApi 144712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public void clearSeedAccountData() { 144812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani try { 144912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani mService.clearSeedAccountData(); 145012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } catch (RemoteException re) { 1451f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 145212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 145312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 145412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 145512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 14561df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani * @hide 14571df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani * Marks the guest user for deletion to allow a new guest to be created before deleting 14581df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani * the current user who is a guest. 14591df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani * @param userHandle 14601df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani * @return 14611df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani */ 14628588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean markGuestForDeletion(@UserIdInt int userHandle) { 14631df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani try { 14641df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani return mService.markGuestForDeletion(userHandle); 14651df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani } catch (RemoteException re) { 1466f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 14671df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani } 14681df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani } 14691df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani 14701df1473008c24487701c5bc15f39ed9f9697f421Amith Yamasani /** 1471df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * Sets the user as enabled, if such an user exists. 14721ddda4793c26fd249590fd3549cf060ecb7c157bLenka Trochtova * 14731ddda4793c26fd249590fd3549cf060ecb7c157bLenka Trochtova * <p>Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 14741ddda4793c26fd249590fd3549cf060ecb7c157bLenka Trochtova * 14751ddda4793c26fd249590fd3549cf060ecb7c157bLenka Trochtova * <p>Note that the default is true, it's only that managed profiles might not be enabled. 14761ddda4793c26fd249590fd3549cf060ecb7c157bLenka Trochtova * Also ephemeral users can be disabled to indicate that their removal is in progress and they 14771ddda4793c26fd249590fd3549cf060ecb7c157bLenka Trochtova * shouldn't be re-entered. Therefore ephemeral users should not be re-enabled once disabled. 1478df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * 1479df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * @param userHandle the id of the profile to enable 1480df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * @hide 1481df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina */ 14828588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public void setUserEnabled(@UserIdInt int userHandle) { 1483df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina try { 1484df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina mService.setUserEnabled(userHandle); 148527b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 1486f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1487df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina } 1488df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina } 1489df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina 1490df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina /** 1491b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * Return the number of users currently created on the device. 1492b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn */ 1493b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn public int getUserCount() { 1494b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn List<UserInfo> users = getUsers(); 1495b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn return users != null ? users.size() : 1; 1496b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn } 1497b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn 1498b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn /** 1499d04aaa323c3a788d26f18fc66e0a59b47e525b38Amith Yamasani * Returns information for all users on this device, including ones marked for deletion. 1500d04aaa323c3a788d26f18fc66e0a59b47e525b38Amith Yamasani * To retrieve only users that are alive, use {@link #getUsers(boolean)}. 1501d04aaa323c3a788d26f18fc66e0a59b47e525b38Amith Yamasani * <p> 15021952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1503940e8577a1569140521fb605336997863529f7adFyodor Kupolov * @return the list of users that exist on the device. 1504258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1505258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 1506258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public List<UserInfo> getUsers() { 1507258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1508920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani return mService.getUsers(false); 1509920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani } catch (RemoteException re) { 1510f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1511920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani } 1512920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani } 1513920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani 1514920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani /** 1515940e8577a1569140521fb605336997863529f7adFyodor Kupolov * Returns serial numbers of all users on this device. 1516940e8577a1569140521fb605336997863529f7adFyodor Kupolov * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1517940e8577a1569140521fb605336997863529f7adFyodor Kupolov * 1518940e8577a1569140521fb605336997863529f7adFyodor Kupolov * @param excludeDying specify if the list should exclude users being removed. 1519940e8577a1569140521fb605336997863529f7adFyodor Kupolov * @return the list of serial numbers of users that exist on the device. 1520940e8577a1569140521fb605336997863529f7adFyodor Kupolov * @hide 1521940e8577a1569140521fb605336997863529f7adFyodor Kupolov */ 1522940e8577a1569140521fb605336997863529f7adFyodor Kupolov @SystemApi 1523940e8577a1569140521fb605336997863529f7adFyodor Kupolov public long[] getSerialNumbersOfUsers(boolean excludeDying) { 1524940e8577a1569140521fb605336997863529f7adFyodor Kupolov try { 1525940e8577a1569140521fb605336997863529f7adFyodor Kupolov List<UserInfo> users = mService.getUsers(excludeDying); 1526940e8577a1569140521fb605336997863529f7adFyodor Kupolov long[] result = new long[users.size()]; 1527940e8577a1569140521fb605336997863529f7adFyodor Kupolov for (int i = 0; i < result.length; i++) { 1528940e8577a1569140521fb605336997863529f7adFyodor Kupolov result[i] = users.get(i).serialNumber; 1529940e8577a1569140521fb605336997863529f7adFyodor Kupolov } 1530940e8577a1569140521fb605336997863529f7adFyodor Kupolov return result; 1531940e8577a1569140521fb605336997863529f7adFyodor Kupolov } catch (RemoteException re) { 1532f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1533940e8577a1569140521fb605336997863529f7adFyodor Kupolov } 1534940e8577a1569140521fb605336997863529f7adFyodor Kupolov } 1535940e8577a1569140521fb605336997863529f7adFyodor Kupolov 1536940e8577a1569140521fb605336997863529f7adFyodor Kupolov /** 1537b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen * @return the user's account name, null if not found. 1538b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen * @hide 1539b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen */ 1540b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen @RequiresPermission( allOf = { 1541b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen Manifest.permission.INTERACT_ACROSS_USERS_FULL, 1542b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen Manifest.permission.MANAGE_USERS 1543b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen }) 15448588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public @Nullable String getUserAccount(@UserIdInt int userHandle) { 1545b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen try { 1546b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen return mService.getUserAccount(userHandle); 1547b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen } catch (RemoteException re) { 1548f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1549b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen } 1550b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen } 1551b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen 1552b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen /** 1553b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen * Set account name for the given user. 1554b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen * @hide 1555b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen */ 1556b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen @RequiresPermission( allOf = { 1557b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen Manifest.permission.INTERACT_ACROSS_USERS_FULL, 1558b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen Manifest.permission.MANAGE_USERS 1559b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen }) 15608588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public void setUserAccount(@UserIdInt int userHandle, @Nullable String accountName) { 1561b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen try { 1562b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen mService.setUserAccount(userHandle, accountName); 1563b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen } catch (RemoteException re) { 1564f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1565b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen } 1566b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen } 1567b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen 1568b3b9258ab6a01af5e0df4b8385b73084cd9ec530Xiaohui Chen /** 156970f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * Returns information for Primary user. 157070f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 157170f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * 157270f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * @return the Primary user, null if not found. 157370f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen * @hide 157470f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen */ 15757cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen public @Nullable UserInfo getPrimaryUser() { 157670f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen try { 157770f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen return mService.getPrimaryUser(); 157870f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen } catch (RemoteException re) { 1579f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 158070f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen } 158170f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen } 158270f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen 158370f6c38644a4a6e28c016c265e6987bf00dd61f1Xiaohui Chen /** 158495ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * Checks whether it's possible to add more users. Caller must hold the MANAGE_USERS 158595ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * permission. 158695ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * 158795ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * @return true if more users can be added, false if limit has been reached. 158895ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * @hide 158995ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani */ 159095ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani public boolean canAddMoreUsers() { 159195ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani final List<UserInfo> users = getUsers(true); 159295ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani final int totalUserCount = users.size(); 159395ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani int aliveUserCount = 0; 159495ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani for (int i = 0; i < totalUserCount; i++) { 159595ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani UserInfo user = users.get(i); 159695ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani if (!user.isGuest()) { 159795ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani aliveUserCount++; 159895ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani } 159995ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani } 160095ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani return aliveUserCount < getMaxSupportedUsers(); 160195ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani } 160295ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani 160395ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani /** 160472434b7088591828082dd952496d523ef3622de2Nicolas Prevot * Checks whether it's possible to add more managed profiles. Caller must hold the MANAGE_USERS 160572434b7088591828082dd952496d523ef3622de2Nicolas Prevot * permission. 160607387fedfafa72bcb68defd801eef82f1f494d7cNicolas Prevot * if allowedToRemoveOne is true and if the user already has a managed profile, then return if 160707387fedfafa72bcb68defd801eef82f1f494d7cNicolas Prevot * we could add a new managed profile to this user after removing the existing one. 160872434b7088591828082dd952496d523ef3622de2Nicolas Prevot * 160972434b7088591828082dd952496d523ef3622de2Nicolas Prevot * @return true if more managed profiles can be added, false if limit has been reached. 161072434b7088591828082dd952496d523ef3622de2Nicolas Prevot * @hide 161172434b7088591828082dd952496d523ef3622de2Nicolas Prevot */ 16128588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean canAddMoreManagedProfiles(@UserIdInt int userId, boolean allowedToRemoveOne) { 161372434b7088591828082dd952496d523ef3622de2Nicolas Prevot try { 161407387fedfafa72bcb68defd801eef82f1f494d7cNicolas Prevot return mService.canAddMoreManagedProfiles(userId, allowedToRemoveOne); 161572434b7088591828082dd952496d523ef3622de2Nicolas Prevot } catch (RemoteException re) { 1616f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 161772434b7088591828082dd952496d523ef3622de2Nicolas Prevot } 161872434b7088591828082dd952496d523ef3622de2Nicolas Prevot } 161972434b7088591828082dd952496d523ef3622de2Nicolas Prevot 162072434b7088591828082dd952496d523ef3622de2Nicolas Prevot /** 16212a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * Returns list of the profiles of userHandle including 16222a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * userHandle itself. 16234f7e2e334e4ca5f1a67baf4bdd40cd080b954161Amith Yamasani * Note that this returns both enabled and not enabled profiles. See 16247f75da2405cd910854448bb3801f776e036f926aRuben Brunk * {@link #getEnabledProfiles(int)} if you need only the enabled ones. 16254f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * 16262a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 16272a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @param userHandle profiles of this user will be returned. 16282a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @return the list of profiles. 16292a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @hide 16302a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy */ 16318588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public List<UserInfo> getProfiles(@UserIdInt int userHandle) { 1632a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy try { 1633385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina return mService.getProfiles(userHandle, false /* enabledOnly */); 1634a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } catch (RemoteException re) { 1635f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1636a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 1637a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 1638a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy 1639a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy /** 1640fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1641fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen * @param userId one of the two user ids to check. 1642fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen * @param otherUserId one of the two user ids to check. 1643fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen * @return true if the two user ids are in the same profile group. 1644fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen * @hide 1645fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen */ 16468588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean isSameProfileGroup(@UserIdInt int userId, int otherUserId) { 1647fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen try { 1648fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen return mService.isSameProfileGroup(userId, otherUserId); 1649fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen } catch (RemoteException re) { 1650f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1651fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen } 1652fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen } 1653fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen 1654fd5b77444edaec88895344a629d071ecf352cf36Xiaohui Chen /** 16557f75da2405cd910854448bb3801f776e036f926aRuben Brunk * Returns list of the profiles of userHandle including 16567f75da2405cd910854448bb3801f776e036f926aRuben Brunk * userHandle itself. 16577f75da2405cd910854448bb3801f776e036f926aRuben Brunk * Note that this returns only enabled. 16587f75da2405cd910854448bb3801f776e036f926aRuben Brunk * 16597f75da2405cd910854448bb3801f776e036f926aRuben Brunk * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 16607f75da2405cd910854448bb3801f776e036f926aRuben Brunk * @param userHandle profiles of this user will be returned. 16617f75da2405cd910854448bb3801f776e036f926aRuben Brunk * @return the list of profiles. 16627f75da2405cd910854448bb3801f776e036f926aRuben Brunk * @hide 16637f75da2405cd910854448bb3801f776e036f926aRuben Brunk */ 16648588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public List<UserInfo> getEnabledProfiles(@UserIdInt int userHandle) { 16657f75da2405cd910854448bb3801f776e036f926aRuben Brunk try { 16667f75da2405cd910854448bb3801f776e036f926aRuben Brunk return mService.getProfiles(userHandle, true /* enabledOnly */); 16677f75da2405cd910854448bb3801f776e036f926aRuben Brunk } catch (RemoteException re) { 1668f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 16697f75da2405cd910854448bb3801f776e036f926aRuben Brunk } 16707f75da2405cd910854448bb3801f776e036f926aRuben Brunk } 16717f75da2405cd910854448bb3801f776e036f926aRuben Brunk 16727f75da2405cd910854448bb3801f776e036f926aRuben Brunk /** 1673be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * Returns a list of UserHandles for profiles associated with the user that the calling process 1674be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * is running on, including the user itself. 16754f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * 16764f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * @return A non-empty list of UserHandles associated with the calling user. 16774f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani */ 16784f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani public List<UserHandle> getUserProfiles() { 16797f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov int[] userIds = getProfileIds(UserHandle.myUserId(), true /* enabledOnly */); 16807f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov List<UserHandle> result = new ArrayList<>(userIds.length); 16817f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov for (int userId : userIds) { 16827f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov result.add(UserHandle.of(userId)); 16837f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov } 16847f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov return result; 16857f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov } 16867f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov 16877f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov /** 16887f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * Returns a list of ids for profiles associated with the specified user including the user 16897f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * itself. 16907f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * 16917f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @param userId id of the user to return profiles for 16927f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @param enabledOnly whether return only {@link UserInfo#isEnabled() enabled} profiles 16937f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @return A non-empty list of ids of profiles associated with the specified user. 16947f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * 16957f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @hide 16967f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov */ 16977f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov public int[] getProfileIds(@UserIdInt int userId, boolean enabledOnly) { 1698385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina try { 16997f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov return mService.getProfileIds(userId, enabledOnly); 1700385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina } catch (RemoteException re) { 1701f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1702385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina } 17037f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov } 17047f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov 17057f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov /** 17067f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @see #getProfileIds(int, boolean) 17077f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @hide 17087f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov */ 17097f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov public int[] getProfileIdsWithDisabled(@UserIdInt int userId) { 17107f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov return getProfileIds(userId, false /* enabledOnly */); 17117f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov } 17127f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov 17137f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov /** 17147f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @see #getProfileIds(int, boolean) 17157f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov * @hide 17167f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov */ 17177f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov public int[] getEnabledProfileIds(@UserIdInt int userId) { 17187f98aa4aa93497692f200c553d2d6fff402e3de2Fyodor Kupolov return getProfileIds(userId, true /* enabledOnly */); 17194f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 17204f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani 17217dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani /** 1722c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales * Returns the device credential owner id of the profile from 1723c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales * which this method is called, or userHandle if called from a user that 1724c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales * is not a profile. 1725c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales * 1726c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales * @hide 1727c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales */ 17288588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public int getCredentialOwnerProfile(@UserIdInt int userHandle) { 1729c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales try { 1730c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales return mService.getCredentialOwnerProfile(userHandle); 1731c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales } catch (RemoteException re) { 1732f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1733c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales } 1734c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales } 1735c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales 1736c5548c02fe0aa768ebfce88ac09393dabe61ec06Andres Morales /** 1737be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * Returns the parent of the profile which this method is called from 1738be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * or null if called from a user that is not a profile. 1739be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * 1740be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * @hide 1741be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel */ 17428588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public UserInfo getProfileParent(@UserIdInt int userHandle) { 1743be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel try { 1744be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel return mService.getProfileParent(userHandle); 1745be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel } catch (RemoteException re) { 1746f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1747be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel } 1748be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel } 1749be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel 1750be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel /** 17510a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * Set quiet mode of a managed profile. 17520a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * 17530a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * @param userHandle The user handle of the profile. 17540a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * @param enableQuietMode Whether quiet mode should be enabled or disabled. 17550a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * @hide 17560a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu */ 17578588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public void setQuietModeEnabled(@UserIdInt int userHandle, boolean enableQuietMode) { 17580a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu try { 17590a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu mService.setQuietModeEnabled(userHandle, enableQuietMode); 176027b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 1761f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 17620a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu } 17630a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu } 17640a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu 17650a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu /** 17660a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * Returns whether the given profile is in quiet mode or not. 17677881cf8f818317cc6efe4d6a4c42da94d6bab223Ricky Wai * Notes: Quiet mode is only supported for managed profiles. 17680a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * 17690a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * @param userHandle The user handle of the profile to be queried. 17700a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu * @return true if the profile is in quiet mode, false otherwise. 17710a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu */ 17720a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu public boolean isQuietModeEnabled(UserHandle userHandle) { 17730a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu try { 17740a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu return mService.isQuietModeEnabled(userHandle.getIdentifier()); 177527b2e6978716f9886db40f4fcf2e060b50637ac5Jeff Sharkey } catch (RemoteException re) { 1776f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 17770a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu } 17780a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu } 17790a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu 17800a29ecd8a53b5ac63b628e870a344650ff34c4b0Rubin Xu /** 1781f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz * Tries disabling quiet mode for a given user. If the user is still locked, we unlock the user 1782f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz * first by showing the confirm credentials screen and disable quiet mode upon successful 1783f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz * unlocking. If the user is already unlocked, we call through to {@link #setQuietModeEnabled} 1784f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz * directly. 1785f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz * 1786f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz * @return true if the quiet mode was disabled immediately 1787f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz * @hide 1788f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz */ 1789f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz public boolean trySetQuietModeDisabled(@UserIdInt int userHandle, IntentSender target) { 1790f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz try { 1791f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz return mService.trySetQuietModeDisabled(userHandle, target); 1792f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz } catch (RemoteException re) { 1793f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz throw re.rethrowFromSystemServer(); 1794f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz } 1795f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz } 1796f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz 1797f02420c5e1bcc8b2c278f272aca633fe6d2b4e88Benjamin Franz /** 17987dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * If the target user is a managed profile of the calling user or the caller 17997dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * is itself a managed profile, then this returns a badged copy of the given 1800c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * icon to be able to distinguish it from the original icon. For badging an 1801c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * arbitrary drawable use {@link #getBadgedDrawableForUser( 1802c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 1803c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * <p> 1804c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * If the original drawable is a BitmapDrawable and the backing bitmap is 180566ae66a7f74ee835807a141a216afbb254664510Vadim Tryshev * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 1806c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * is performed in place and the original drawable is returned. 1807c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * </p> 1808c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * 1809c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param icon The icon to badge. 1810c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param user The target user. 1811c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @return A drawable that combines the original icon and a badge as 1812c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * determined by the system. 1813c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bbSvetoslav * @removed 1814c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav */ 1815c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav public Drawable getBadgedIconForUser(Drawable icon, UserHandle user) { 1816c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bbSvetoslav return mContext.getPackageManager().getUserBadgedIcon(icon, user); 1817c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 1818c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 1819c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav /** 1820c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * If the target user is a managed profile of the calling user or the caller 1821c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * is itself a managed profile, then this returns a badged copy of the given 1822c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * drawable allowing the user to distinguish it from the original drawable. 1823c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * The caller can specify the location in the bounds of the drawable to be 1824c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * badged where the badge should be applied as well as the density of the 1825c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * badge to be used. 1826c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * <p> 1827c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * If the original drawable is a BitmapDrawable and the backing bitmap is 182866ae66a7f74ee835807a141a216afbb254664510Vadim Tryshev * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 1829c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * is performed in place and the original drawable is returned. 1830c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * </p> 1831c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * 1832c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param badgedDrawable The drawable to badge. 1833c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param user The target user. 1834c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param badgeLocation Where in the bounds of the badged drawable to place 183566ae66a7f74ee835807a141a216afbb254664510Vadim Tryshev * the badge. If it's {@code null}, the badge is applied on top of the entire 1836c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * drawable being badged. 1837c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param badgeDensity The optional desired density for the badge as per 183866ae66a7f74ee835807a141a216afbb254664510Vadim Tryshev * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 1839c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * the density of the display is used. 1840c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @return A drawable that combines the original drawable and a badge as 1841c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * determined by the system. 1842c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bbSvetoslav * @removed 1843c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav */ 1844c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav public Drawable getBadgedDrawableForUser(Drawable badgedDrawable, UserHandle user, 1845c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav Rect badgeLocation, int badgeDensity) { 1846c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bbSvetoslav return mContext.getPackageManager().getUserBadgedDrawableForDensity(badgedDrawable, user, 1847c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bbSvetoslav badgeLocation, badgeDensity); 18484f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 18494f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani 1850701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy /** 1851701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * If the target user is a managed profile of the calling user or the caller 1852f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * is itself a managed profile, then this returns a copy of the label with 1853f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * badging for accessibility services like talkback. E.g. passing in "Email" 1854f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * and it might return "Work Email" for Email in the work profile. 1855f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * 1856f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * @param label The label to change. 1857f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * @param user The target user. 1858f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * @return A label that combines the original label and a badge as 1859f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * determined by the system. 1860c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bbSvetoslav * @removed 1861f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy */ 1862237aecd18d0edf56c038761f570758c310c9e6dfKenny Guy public CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user) { 1863c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bbSvetoslav return mContext.getPackageManager().getUserBadgedLabel(label, user); 18644f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 18654f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani 18664f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani /** 18674f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * Returns information for all users on this device. Requires 18684f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * {@link android.Manifest.permission#MANAGE_USERS} permission. 1869394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * 18704f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * @param excludeDying specify if the list should exclude users being 18714f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * removed. 1872920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani * @return the list of users that were created. 1873920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani * @hide 1874920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani */ 1875920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani public List<UserInfo> getUsers(boolean excludeDying) { 1876920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani try { 1877920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani return mService.getUsers(excludeDying); 1878258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1879f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1880258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1881258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1882258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1883258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 1884258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Removes a user and all associated data. 18851952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1886258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the integer handle of the user, where 0 is the primary user. 1887258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1888258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 18898588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public boolean removeUser(@UserIdInt int userHandle) { 1890258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1891258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return mService.removeUser(userHandle); 1892258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1893f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1894258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1895258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1896258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1897258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 1898258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Updates the user's name. 18991952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1900258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 1901258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the user's integer handle 1902258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param name the new name for the user 1903258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1904258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 19058588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public void setUserName(@UserIdInt int userHandle, String name) { 1906258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1907258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani mService.setUserName(userHandle, name); 1908258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1909f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1910258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1911258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1912258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1913258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 1914e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani * Sets the user's photo. 1915258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the user for whom to change the photo. 1916e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani * @param icon the bitmap to set as the photo. 1917258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1918258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 19198588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public void setUserIcon(@UserIdInt int userHandle, Bitmap icon) { 1920258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1921e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani mService.setUserIcon(userHandle, icon); 1922258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1923f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 1924258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1925258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1926258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1927258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 19283b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani * Returns a file descriptor for the user's photo. PNG data can be read from this file. 19293b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani * @param userHandle the user whose photo we want to read. 1930e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani * @return a {@link Bitmap} of the user's photo, or null if there's no photo. 193164d4dca63f65e4c7d4a829c85ff6670bdd34e2ebAlexandra Gherghina * @see com.android.internal.util.UserIcons#getDefaultUserIcon for a default. 19323b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani * @hide 19333b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani */ 19348588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public Bitmap getUserIcon(@UserIdInt int userHandle) { 19353b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani try { 19361bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos ParcelFileDescriptor fd = mService.getUserIcon(userHandle); 19371bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos if (fd != null) { 19381bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos try { 19391bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos return BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor()); 19401bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos } finally { 19411bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos try { 19421bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos fd.close(); 19431bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos } catch (IOException e) { 19441bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos } 19451bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos } 19461bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos } 19473b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani } catch (RemoteException re) { 1948f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 19493b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani } 19501bdff9139fd412b36d5d2d783574b6418fcb198aAdrian Roos return null; 19513b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani } 19523b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani 19533b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani /** 1954258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Returns the maximum number of users that can be created on this device. A return value 1955258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * of 1 means that it is a single user device. 1956258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1957a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @return a value greater than or equal to 1 1958258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 195927bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkey public static int getMaxSupportedUsers() { 1960ff54920ed222a2bd6abe618743a5a3e9fe10bd4bAmith Yamasani // Don't allow multiple users on certain builds 1961ff54920ed222a2bd6abe618743a5a3e9fe10bd4bAmith Yamasani if (android.os.Build.ID.startsWith("JVP")) return 1; 1962409297da182267465adbc21cfb75a23e8d678117Dianne Hackborn // Svelte devices don't get multi-user. 1963409297da182267465adbc21cfb75a23e8d678117Dianne Hackborn if (ActivityManager.isLowRamDeviceStatic()) return 1; 196427bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkey return SystemProperties.getInt("fw.max_users", 196527bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkey Resources.getSystem().getInteger(R.integer.config_multiuserMaximumUsers)); 1966258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 19672a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani 19682a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani /** 1969cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolov * Returns true if the user switcher should be shown, this will be if device supports multi-user 1970cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolov * and there are at least 2 users available that are not managed profiles. 19711a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy * @hide 19721a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy * @return true if user switcher should be shown. 19731a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy */ 19741a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy public boolean isUserSwitcherEnabled() { 1975cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolov if (!supportsMultipleUsers()) { 1976cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolov return false; 1977cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolov } 19781a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy List<UserInfo> users = getUsers(true); 19791a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy if (users == null) { 19801a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy return false; 19811a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 19821a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy int switchableUserCount = 0; 19831a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy for (UserInfo user : users) { 19847cb69df507f5f7956c52a2868a0d6e89aec6dde2Xiaohui Chen if (user.supportsSwitchToByUser()) { 19851a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy ++switchableUserCount; 19861a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 19871a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 1988cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolov final boolean guestEnabled = !mContext.getSystemService(DevicePolicyManager.class) 1989cd86ebf1c965c191f46b6480145c9d217a7d841eFyodor Kupolov .getGuestUserDisabled(null); 1990a596ff87cd899640334512371456b8481ba21b4aAmith Yamasani return switchableUserCount > 1 || guestEnabled; 19911a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 19921a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy 19931a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy /** 19942a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * Returns a serial number on this device for a given userHandle. User handles can be recycled 19952a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * when deleting and creating users, but serial numbers are not reused until the device is wiped. 19962a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @param userHandle 19972a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @return a serial number associated with that user, or -1 if the userHandle is not valid. 19982a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @hide 19992a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani */ 20008588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public int getUserSerialNumber(@UserIdInt int userHandle) { 20012a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani try { 20022a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani return mService.getUserSerialNumber(userHandle); 20032a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } catch (RemoteException re) { 2004f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 20052a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 20062a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 20072a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani 20082a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani /** 20092a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * Returns a userHandle on this device for a given user serial number. User handles can be 20102a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * recycled when deleting and creating users, but serial numbers are not reused until the device 20112a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * is wiped. 20122a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @param userSerialNumber 20132a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @return the userHandle associated with that user serial number, or -1 if the serial number 20142a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * is not valid. 20152a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @hide 20162a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani */ 20178588bc1ef1f020bbe4a24d46874f675708149a57Jeff Sharkey public @UserIdInt int getUserHandle(int userSerialNumber) { 20182a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani try { 20192a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani return mService.getUserHandle(userSerialNumber); 20202a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } catch (RemoteException re) { 2021f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 20222a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 20232a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 20246794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 20257e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani /** 2026953fe483298bff46558a4e0b2d891924c0c9c813Esteban Talavera * Returns a {@link Bundle} containing any saved application restrictions for this user, for the 20277e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * given package name. Only an application with this package name can call this method. 20285b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * 20295b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * <p>The returned {@link Bundle} consists of key-value pairs, as defined by the application, 20305b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * where the types of values may be: 20315b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * <ul> 20325b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * <li>{@code boolean} 20335b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * <li>{@code int} 20345b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * <li>{@code String} or {@code String[]} 20355b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * <li>From {@link android.os.Build.VERSION_CODES#M}, {@code Bundle} or {@code Bundle[]} 20365b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * </ul> 20375b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * 20387e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * @param packageName the package name of the calling application 2039953fe483298bff46558a4e0b2d891924c0c9c813Esteban Talavera * @return a {@link Bundle} with the restrictions for that package, or an empty {@link Bundle} 2040953fe483298bff46558a4e0b2d891924c0c9c813Esteban Talavera * if there are no saved restrictions. 20415b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * 20425b9f167a8e7395ca54fc0ef78af4523858de87a7Esteban Talavera * @see #KEY_RESTRICTIONS_PENDING 20437e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani */ 20447e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani public Bundle getApplicationRestrictions(String packageName) { 20457e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani try { 20467e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani return mService.getApplicationRestrictions(packageName); 20477e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani } catch (RemoteException re) { 2048f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 20497e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani } 20507e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani } 2051df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 2052df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani /** 2053df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * @hide 2054df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */ 20557e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani public Bundle getApplicationRestrictions(String packageName, UserHandle user) { 2056df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani try { 20577e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani return mService.getApplicationRestrictionsForUser(packageName, user.getIdentifier()); 2058df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } catch (RemoteException re) { 2059f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 2060df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 2061df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 2062df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 2063df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani /** 2064df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * @hide 2065df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */ 20667e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani public void setApplicationRestrictions(String packageName, Bundle restrictions, 2067df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani UserHandle user) { 2068df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani try { 20697e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani mService.setApplicationRestrictions(packageName, restrictions, user.getIdentifier()); 2070df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } catch (RemoteException re) { 2071f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 2072df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 2073df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 2074655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani 2075655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** 2076d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * Sets a new challenge PIN for restrictions. This is only for use by pre-installed 2077d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * apps and requires the MANAGE_USERS permission. 2078d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * @param newPin the PIN to use for challenge dialogs. 2079d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * @return Returns true if the challenge PIN was set successfully. 2080ef24909d84db9d5aefb825ee1556089fcdcc1678Fyodor Kupolov * @deprecated The restrictions PIN functionality is no longer provided by the system. 2081ef24909d84db9d5aefb825ee1556089fcdcc1678Fyodor Kupolov * This method is preserved for backwards compatibility reasons and always returns false. 2082655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani */ 2083d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani public boolean setRestrictionsChallenge(String newPin) { 2084655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani return false; 2085655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } 20861a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani 2087e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani /** 2088e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * @hide 2089e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * Set restrictions that should apply to any future guest user that's created. 2090e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani */ 2091e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani public void setDefaultGuestRestrictions(Bundle restrictions) { 2092e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani try { 2093e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani mService.setDefaultGuestRestrictions(restrictions); 2094e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } catch (RemoteException re) { 2095f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 2096e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 2097e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 2098e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani 2099e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani /** 2100e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * @hide 2101e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * Gets the default guest restrictions. 2102e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani */ 2103e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani public Bundle getDefaultGuestRestrictions() { 2104e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani try { 2105e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani return mService.getDefaultGuestRestrictions(); 2106e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } catch (RemoteException re) { 2107f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 2108e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 2109e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 2110ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov 2111ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov /** 2112ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov * Returns creation time of the user or of a managed profile associated with the calling user. 2113ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov * @param userHandle user handle of the user or a managed profile associated with the 2114ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov * calling user. 2115ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov * @return creation time in milliseconds since Epoch time. 2116ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov */ 2117385de624aa990266ffbaf70711ac8a330569429eFyodor Kupolov public long getUserCreationTime(UserHandle userHandle) { 2118ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov try { 2119385de624aa990266ffbaf70711ac8a330569429eFyodor Kupolov return mService.getUserCreationTime(userHandle.getIdentifier()); 2120ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov } catch (RemoteException re) { 2121f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 2122ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov } 2123ff7233e2e3df4965b9ecadabfd78bb991fd1e102Fyodor Kupolov } 212412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani 212512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani /** 212612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @hide 212712747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * Checks if any uninitialized user has the specific seed account name and type. 212812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * 212912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param mAccountName The account name to check for 213012747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @param mAccountType The account type of the account to check for 213112747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani * @return whether the seed account was found 213212747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani */ 213312747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani public boolean someUserHasSeedAccount(String accountName, String accountType) { 213412747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani try { 213512747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani return mService.someUserHasSeedAccount(accountName, accountType); 213612747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } catch (RemoteException re) { 2137f8880561e67e1da246970b49b14285efd4164ab1Jeff Sharkey throw re.rethrowFromSystemServer(); 213812747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 213912747879b0204b9dfee997eddc981d09289e8b77Amith Yamasani } 2140258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani} 2141