UserManager.java revision 681bf60ce2a3973d5982f9b7a405bcef5fb72f20
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 */ 16258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasanipackage android.os; 17258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 18409297da182267465adbc21cfb75a23e8d678117Dianne Hackbornimport android.app.ActivityManager; 19a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackbornimport android.app.ActivityManagerNative; 20258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasaniimport android.content.Context; 21258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasaniimport android.content.pm.UserInfo; 2227bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkeyimport android.content.res.Resources; 236794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthallimport android.graphics.Bitmap; 244f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport android.graphics.Canvas; 254f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport android.graphics.Bitmap.Config; 264f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport android.graphics.Rect; 274f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport android.graphics.drawable.BitmapDrawable; 284f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport android.graphics.drawable.Drawable; 291e9c21871e81642669079cd290ef47818a3165bdAmith Yamasaniimport android.provider.Settings; 30258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasaniimport android.util.Log; 311c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monkimport android.view.WindowManager.LayoutParams; 32258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 336794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthallimport com.android.internal.R; 346794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 354f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasaniimport java.util.ArrayList; 36258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasaniimport java.util.List; 37258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 38258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani/** 39258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Manages users and user details on a multi-user system. 40258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 41258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasanipublic class UserManager { 42258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 43258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani private static String TAG = "UserManager"; 44258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani private final IUserManager mService; 45258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani private final Context mContext; 46258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 47e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 4871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Key for user restrictions. Specifies if a user is disallowed from adding and removing 4971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * accounts. 5071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 5171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * <p/> 52e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * Type: Boolean 53e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #setUserRestrictions(Bundle) 54e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 55e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 5671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts"; 57e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 58e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 5971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Key for user restrictions. Specifies if a user is disallowed from changing Wi-Fi 6071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * access points. 6171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 6271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * <p/> 63e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * Type: Boolean 64e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #setUserRestrictions(Bundle) 65e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 66e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 6771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_CONFIG_WIFI = "no_config_wifi"; 68e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 69e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 7071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Key for user restrictions. Specifies if a user is disallowed from installing applications. 7171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 7271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * <p/> 73e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * Type: Boolean 74e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #setUserRestrictions(Bundle) 75e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 76e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 7771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_INSTALL_APPS = "no_install_apps"; 78e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 79e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani /** 8071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Key for user restrictions. Specifies if a user is disallowed from uninstalling applications. 8171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 8271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * <p/> 83e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * Type: Boolean 84e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #setUserRestrictions(Bundle) 85e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani * @see #getUserRestrictions() 86e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani */ 8771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps"; 88e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 8971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 9071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Key for user restrictions. Specifies if a user is disallowed from toggling location sharing. 9171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * The default value is <code>false</code>. 9271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * <p/> 936794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall * Type: Boolean 946794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall * @see #setUserRestrictions(Bundle) 956794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall * @see #getUserRestrictions() 966794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall */ 9771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public static final String DISALLOW_SHARE_LOCATION = "no_share_location"; 986794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 99a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 100a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Key for user restrictions. Specifies if a user is disallowed from enabling the 101a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * "Unknown Sources" setting, that allows installation of apps from unknown sources. 102a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * The default value is <code>false</code>. 103a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * <p/> 104a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Type: Boolean 105a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #setUserRestrictions(Bundle) 106a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #getUserRestrictions() 107a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 108a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public static final String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources"; 109a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 110a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 111a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Key for user restrictions. Specifies if a user is disallowed from configuring bluetooth. 112a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * The default value is <code>false</code>. 113a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * <p/> 114a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Type: Boolean 115a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #setUserRestrictions(Bundle) 116a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #getUserRestrictions() 117a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 118a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public static final String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; 119a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 120a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 121a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Key for user restrictions. Specifies if a user is disallowed from transferring files over 122a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * USB. The default value is <code>false</code>. 123a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * <p/> 124a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Type: Boolean 125a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #setUserRestrictions(Bundle) 126a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @see #getUserRestrictions() 127a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 128a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public static final String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer"; 129a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 130b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier /** 131b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * Key for user restrictions. Specifies if a user is disallowed from configuring user 132b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * credentials. The default value is <code>false</code>. 133b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * <p/> 134b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * Type: Boolean 135b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * @see #setUserRestrictions(Bundle) 136b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * @see #getUserRestrictions() 137b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier */ 138b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier public static final String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials"; 139b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier 140b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier /** 1415b8224901b5de0cfe7b4a1d3cb158e38243ef99fJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from removing itself and other 1425b8224901b5de0cfe7b4a1d3cb158e38243ef99fJulia Reynolds * users. 143b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * The default value is <code>false</code>. 144b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * <p/> 145b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * Type: Boolean 146b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * @see #setUserRestrictions(Bundle) 147b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier * @see #getUserRestrictions() 148b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier */ 149b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier public static final String DISALLOW_REMOVE_USER = "no_remove_user"; 150b223f73a69f76f5e32a0bca267f945f464776f9dEmily Bernier 151d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 152d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from enabling or 153d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * accessing debugging features. The default value is <code>false</code>. 154d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p/> 155d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 156d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 157d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 158d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 159d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_DEBUGGING_FEATURES = "no_debugging_features"; 160d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 161d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 162d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from configuring VPN. 163d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * The default value is <code>false</code>. 164d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p/> 165d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 166d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 167d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 168d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 169d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_VPN = "no_config_vpn"; 170d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 171d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 172d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from configuring Tethering 173d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * & portable hotspots. The default value is <code>false</code>. 174d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p/> 175d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 176d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 177d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 178d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 179d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_TETHERING = "no_config_tethering"; 180d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 181d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 182d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from factory resetting 183d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * from Settings. 184d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * The default value is <code>false</code>. 185d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p> 186d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 187d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 188d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 189d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_FACTORY_RESET = "no_factory_reset"; 190d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 191d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 192d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from adding new users and 193d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * profiles. The default value is <code>false</code>. 194d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p> 195d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 196d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 197d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 198d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 199d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_ADD_USER = "no_add_user"; 200d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 201d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 202d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from disabling application 203d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * verification. The default value is <code>false</code>. 204d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p> 205d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 206d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 207d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 208d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 209d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String ENSURE_VERIFY_APPS = "ensure_verify_apps"; 210d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 211d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 212d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from configuring cell 213d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * broadcasts. The default value is <code>false</code>. 214d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p> 215d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 216d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 217d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 218d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 219d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; 220d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 221d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 222d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Key for user restrictions. Specifies if a user is disallowed from configuring mobile 223d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * networks. The default value is <code>false</code>. 224d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p> 225d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 226d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 227d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 228d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 229d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds public static final String DISALLOW_CONFIG_MOBILE_NETWORKS = "no_config_mobile_networks"; 230d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 231d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds /** 232c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * Key for user restrictions. Specifies if a user is disallowed from modifying 233c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * applications in Settings or launchers. The following actions will not be allowed when this 234c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * restriction is enabled: 235c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>uninstalling apps</li> 236c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>disabling apps</li> 237c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>clearing app caches</li> 238c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>clearing app data</li> 239c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>force stopping apps</li> 240c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <li>clearing app defaults</li> 241c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * <p> 242c617f815453b6e70a0165924907e69a0f993e651Julia Reynolds * The default value is <code>false</code>. 243d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * <p> 244d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * Type: Boolean 245d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #setUserRestrictions(Bundle) 246d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds * @see #getUserRestrictions() 247d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds */ 24836fbc8d6453da438a8ab83352ff1bcfcba5f25b5Julia Reynolds public static final String DISALLOW_APPS_CONTROL = "no_control_apps"; 249d46d0f9dcd72dfaa93a57d07d896def6ce53bbaeJulia Reynolds 250394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier /** 251394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * Key for user restrictions. Specifies if a user is disallowed from mounting 252394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * physical external media. The default value is <code>false</code>. 253394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * <p/> 254394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * Type: Boolean 255394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #setUserRestrictions(Bundle) 256394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #getUserRestrictions() 257394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier */ 258394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier public static final String DISALLOW_MOUNT_PHYSICAL_MEDIA = "no_physical_media"; 259394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier 260394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier /** 261394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * Key for user restrictions. Specifies if a user is disallowed from adjusting microphone 262394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * volume. 263394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * The default value is <code>false</code>. 264394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * <p/> 265394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * Type: Boolean 266394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #setUserRestrictions(Bundle) 267394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #getUserRestrictions() 268394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier */ 269394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier public static final String DISALLOW_UNMUTE_MICROPHONE = "no_unmute_microphone"; 270394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier 271394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier /** 272394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * Key for user restrictions. Specifies if a user is disallowed from adjusting the master 273394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * volume. 274394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * The default value is <code>false</code>. 275394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * <p/> 276394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * Type: Boolean 277394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #setUserRestrictions(Bundle) 278394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * @see #getUserRestrictions() 279394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier */ 280394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier public static final String DISALLOW_ADJUST_VOLUME = "no_adjust_volume"; 281394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier 2829f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani /** 283390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * Key for user restrictions. Specifies that the user is not allowed to make outgoing 284390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * phone calls. Emergency calls are still permitted. 285390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * The default value is <code>false</code>. 286390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * <p/> 287390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * Type: Boolean 288390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * @see #setUserRestrictions(Bundle) 289390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * @see #getUserRestrictions() 290390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani */ 291390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani public static final String DISALLOW_OUTGOING_CALLS = "no_outgoing_calls"; 292390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani 293390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani /** 2949f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani * Key for user restrictions. Specifies that the user is not allowed to send or receive 295390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani * SMS messages. 2969f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani * The default value is <code>false</code>. 2979f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani * <p/> 2989f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani * Type: Boolean 2999f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani * @see #setUserRestrictions(Bundle) 3009f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani * @see #getUserRestrictions() 3019f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani */ 302390989da1967f9d385212cd2e22a50589ce69046Amith Yamasani public static final String DISALLOW_SMS = "no_sms"; 3039f6c25f57e26f3e2f9c744547a139d14b7d3db5cAmith Yamasani 3041c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk /** 3051c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * Key for user restrictions. Specifies that windows besides app windows should not be 3061c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * created. This will block the creation of the following types of windows. 3071c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_TOAST}</li> 3081c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_PHONE}</li> 3091c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_PRIORITY_PHONE}</li> 3101c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_SYSTEM_ALERT}</li> 3111c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_SYSTEM_ERROR}</li> 3121c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <li>{@link LayoutParams#TYPE_SYSTEM_OVERLAY}</li> 3131c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * 3141c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <p>The default value is <code>false</code>. 3151c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * <p/> 3161c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * Type: Boolean 3171c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * @see #setUserRestrictions(Bundle) 3181c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk * @see #getUserRestrictions() 3191c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk */ 3201c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk public static final String DISALLOW_CREATE_WINDOWS = "no_create_windows"; 3211c7c319bb89b9988bfd12afc3e8d89449fd163fcJason Monk 322f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot /** 323f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * Key for user restrictions. Specifies if what is copied in the clipboard of this profile can 324f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * be pasted in related profiles. Does not restrict if the clipboard of related profiles can be 325f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * pasted in this profile. 326f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * The default value is <code>false</code>. 327f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * <p/> 328f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * Type: Boolean 329f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * @see #setUserRestrictions(Bundle) 330f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot * @see #getUserRestrictions() 331f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot */ 332f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot public static final String DISALLOW_CROSS_PROFILE_COPY_PASTE = "no_cross_profile_copy_paste"; 333f1939901d2ed0480069f0b23be64f122fce93995Nicolas Prevot 334655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** @hide */ 335655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani public static final int PIN_VERIFICATION_FAILED_INCORRECT = -3; 336655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** @hide */ 337655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani public static final int PIN_VERIFICATION_FAILED_NOT_SET = -2; 338655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** @hide */ 339655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani public static final int PIN_VERIFICATION_SUCCESS = -1; 340655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani 34127db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani private static UserManager sInstance = null; 34227db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani 3437e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani /** @hide */ 34427db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani public synchronized static UserManager get(Context context) { 34527db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani if (sInstance == null) { 34627db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani sInstance = (UserManager) context.getSystemService(Context.USER_SERVICE); 34727db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani } 34827db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani return sInstance; 34927db46850b708070452c0ce49daf5f79503fbde6Amith Yamasani } 350a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 351258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** @hide */ 352258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public UserManager(Context context, IUserManager service) { 353258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani mService = service; 354258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani mContext = context; 355258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 356258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 357258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 358258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Returns whether the system supports multiple users. 3591a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy * @return true if multiple users can be created by user, false if it is a single user device. 360e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani * @hide 361258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 3624673e7ea8d1f869910a9c0f9c211d4d27ad50b41Jeff Sharkey public static boolean supportsMultipleUsers() { 3631a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy return getMaxSupportedUsers() > 1 3641a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy && SystemProperties.getBoolean("fw.show_multiuserui", 3651a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy Resources.getSystem().getBoolean(R.bool.config_enableMultiUserUI)); 366258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 367258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 3686794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall /** 369be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * Returns the user handle for the user that the calling process is running on. 370be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * 371258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the user handle of the user making this call. 372258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 3736794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall */ 374258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public int getUserHandle() { 37579af1dd54c16cde063152922b42c96d72ae9eca8Dianne Hackborn return UserHandle.myUserId(); 376258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 377258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 378258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 3798832c18d8b63367929c2d394c9c508f56003d400Dianne Hackborn * Returns the user name of the user making this call. This call is only 3808832c18d8b63367929c2d394c9c508f56003d400Dianne Hackborn * available to applications on the system image; it requires the 3818832c18d8b63367929c2d394c9c508f56003d400Dianne Hackborn * MANAGE_USERS permission. 382258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the user name 383258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 384258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public String getUserName() { 385258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 386258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return mService.getUserInfo(getUserHandle()).name; 387258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 388258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani Log.w(TAG, "Could not get user name", re); 389258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return ""; 390258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 391258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 392258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 393e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill /** 394e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill * Used to determine whether the user making this call is subject to 395e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill * teleportations. 396a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @return whether the user making this call is a goat 397e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill */ 398e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill public boolean isUserAGoat() { 399e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill return false; 400e4ab16ad98b183afbf7a21ad7314372de41a8b57Dan Morrill } 401df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 402df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani /** 403e1375908a5f05e5c926e95049970c4505e4dfad9Amith Yamasani * Used to check if the user making this call is linked to another user. Linked users may have 40446bc4ebb87232b39d7b02ac0135c8ccf2c33f233Amith Yamasani * a reduced number of available apps, app restrictions and account restrictions. 405e1375908a5f05e5c926e95049970c4505e4dfad9Amith Yamasani * @return whether the user making this call is a linked user 4062555dafce87e60fae28d71913730abf73e40fcd7Amith Yamasani * @hide 407df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */ 408e1375908a5f05e5c926e95049970c4505e4dfad9Amith Yamasani public boolean isLinkedUser() { 409df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani try { 41071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani return mService.isRestricted(); 411df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } catch (RemoteException re) { 41246bc4ebb87232b39d7b02ac0135c8ccf2c33f233Amith Yamasani Log.w(TAG, "Could not check if user is limited ", re); 413df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani return false; 414df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 415df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 416df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 417258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 4181e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * Checks if the calling app is running as a guest user. 4191e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @return whether the caller is a guest user. 4201e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @hide 4211e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani */ 4221e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani public boolean isGuestUser() { 4231e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani UserInfo user = getUserInfo(UserHandle.myUserId()); 4241e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani return user != null ? user.isGuest() : false; 4251e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani } 4261e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani 4271e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani /** 428a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * Return whether the given user is actively running. This means that 429a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * the user is in the "started" state, not "stopped" -- it is currently 430a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * allowed to run code through scheduled alarms, receiving broadcasts, 431a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * etc. A started user may be either the current foreground user or a 432a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * background user; the result here does not distinguish between the two. 433a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * @param user The user to retrieve the running state for. 434a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn */ 435a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn public boolean isUserRunning(UserHandle user) { 436a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn try { 437a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn return ActivityManagerNative.getDefault().isUserRunning( 438a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn user.getIdentifier(), false); 439a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } catch (RemoteException e) { 440a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn return false; 441a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 442a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 443a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn 444a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn /** 445a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * Return whether the given user is actively running <em>or</em> stopping. 446a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * This is like {@link #isUserRunning(UserHandle)}, but will also return 447a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * true if the user had been running but is in the process of being stopped 448a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * (but is not yet fully stopped, and still running some code). 449a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn * @param user The user to retrieve the running state for. 450a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn */ 451a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn public boolean isUserRunningOrStopping(UserHandle user) { 452a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn try { 453a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn return ActivityManagerNative.getDefault().isUserRunning( 454a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn user.getIdentifier(), true); 455a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } catch (RemoteException e) { 456a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn return false; 457a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 458a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn } 459a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn 460a8a9bd65bf5865d83ef44f54552ca39522bfbcf0Dianne Hackborn /** 461258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Returns the UserInfo object describing a specific user. 4621952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 463258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the user handle of the user whose information is being requested. 464258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the UserInfo object for a specific user. 465258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 466b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn */ 467258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public UserInfo getUserInfo(int userHandle) { 468258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 469258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return mService.getUserInfo(userHandle); 470258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 471258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani Log.w(TAG, "Could not get user info", re); 472258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return null; 473258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 474258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 475258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 47671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 47771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Returns the user-wide restrictions imposed on this user. 47871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @return a Bundle containing all the restrictions. 47971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 480e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public Bundle getUserRestrictions() { 481e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani return getUserRestrictions(Process.myUserHandle()); 482e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 483e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 48471e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 48571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Returns the user-wide restrictions imposed on the user specified by <code>userHandle</code>. 48671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param userHandle the UserHandle of the user for whom to retrieve the restrictions. 48771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @return a Bundle containing all the restrictions. 48871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 489e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public Bundle getUserRestrictions(UserHandle userHandle) { 490e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani try { 491e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani return mService.getUserRestrictions(userHandle.getIdentifier()); 492e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } catch (RemoteException re) { 493e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani Log.w(TAG, "Could not get user restrictions", re); 494e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani return Bundle.EMPTY; 495e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 496e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 497e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 49871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 49971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Sets all the user-wide restrictions for this user. 500be46532c9fbebf3ab6498c1b78013a33f620cd31Amith Yamasani * Requires the MANAGE_USERS permission. 50171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param restrictions the Bundle containing all the restrictions. 5023d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * @deprecated use {@link android.app.admin.DevicePolicyManager#addUserRestriction( 5033d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} or 5043d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * {@link android.app.admin.DevicePolicyManager#clearUserRestriction( 5053d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} instead. 50671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 5073d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 508e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public void setUserRestrictions(Bundle restrictions) { 509e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani setUserRestrictions(restrictions, Process.myUserHandle()); 510e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 511e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 51271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 51371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Sets all the user-wide restrictions for the specified user. 514be46532c9fbebf3ab6498c1b78013a33f620cd31Amith Yamasani * Requires the MANAGE_USERS permission. 51571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param restrictions the Bundle containing all the restrictions. 51671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param userHandle the UserHandle of the user for whom to set the restrictions. 5173d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * @deprecated use {@link android.app.admin.DevicePolicyManager#addUserRestriction( 5183d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} or 5193d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * {@link android.app.admin.DevicePolicyManager#clearUserRestriction( 5203d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} instead. 52171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 5223d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 523e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani public void setUserRestrictions(Bundle restrictions, UserHandle userHandle) { 524e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani try { 525e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani mService.setUserRestrictions(restrictions, userHandle.getIdentifier()); 526e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } catch (RemoteException re) { 527e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani Log.w(TAG, "Could not set user restrictions", re); 528e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 529e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani } 530e4cf73437a18c1444055f88a1fcc0d146ec23ac5Amith Yamasani 53171e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 53271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Sets the value of a specific restriction. 533be46532c9fbebf3ab6498c1b78013a33f620cd31Amith Yamasani * Requires the MANAGE_USERS permission. 53471e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param key the key of the restriction 53571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param value the value for the restriction 5363d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * @deprecated use {@link android.app.admin.DevicePolicyManager#addUserRestriction( 5373d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} or 5383d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * {@link android.app.admin.DevicePolicyManager#clearUserRestriction( 5393d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} instead. 54071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 5413d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 54271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani public void setUserRestriction(String key, boolean value) { 54371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani Bundle bundle = getUserRestrictions(); 54471e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani bundle.putBoolean(key, value); 54571e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani setUserRestrictions(bundle); 54671e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani } 54771e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani 54871e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani /** 54971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @hide 55071e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * Sets the value of a specific restriction on a specific user. 551be46532c9fbebf3ab6498c1b78013a33f620cd31Amith Yamasani * Requires the MANAGE_USERS permission. 55271e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param key the key of the restriction 55371e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param value the value for the restriction 55471e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani * @param userHandle the user whose restriction is to be changed. 5553d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * @deprecated use {@link android.app.admin.DevicePolicyManager#addUserRestriction( 5563d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} or 5573d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * {@link android.app.admin.DevicePolicyManager#clearUserRestriction( 5583d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds * android.content.ComponentName, String)} instead. 55971e6c697e54a43d357cc25d87a446d140f17396aAmith Yamasani */ 5603d9eb78fe91ab2479eb38443aed588e10421e31bJulia Reynolds @Deprecated 5616794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall public void setUserRestriction(String key, boolean value, UserHandle userHandle) { 5626794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall Bundle bundle = getUserRestrictions(userHandle); 5636794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall bundle.putBoolean(key, value); 5646794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall setUserRestrictions(bundle, userHandle); 5656794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall } 5666794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 567258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 568a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * Returns whether the current user has been disallowed from performing certain actions 569a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * or setting certain settings. 5702b2cf72f10f13d9314a1c53386188ed48e12d47cJulia Reynolds * 5712b2cf72f10f13d9314a1c53386188ed48e12d47cJulia Reynolds * @param restrictionKey The string key representing the restriction. 5722b2cf72f10f13d9314a1c53386188ed48e12d47cJulia Reynolds * @return {@code true} if the current user has the given restriction, {@code false} otherwise. 573a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall */ 574a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall public boolean hasUserRestriction(String restrictionKey) { 575b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie return hasUserRestriction(restrictionKey, Process.myUserHandle()); 576b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie } 577b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie 578b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie /** 579b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * @hide 580b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * Returns whether the given user has been disallowed from performing certain actions 581b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * or setting certain settings. 582b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * @param restrictionKey the string key representing the restriction 583b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie * @param userHandle the UserHandle of the user for whom to retrieve the restrictions. 584b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie */ 585b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie public boolean hasUserRestriction(String restrictionKey, UserHandle userHandle) { 586b12ba933f3db9280edcb6a3591741d29c109a4e2David Christie return getUserRestrictions(userHandle).getBoolean(restrictionKey, false); 587a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall } 588a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall 589a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall /** 59033f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * Return the serial number for a user. This is a device-unique 591b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * number assigned to that user; if the user is deleted and then a new 592b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * user created, the new users will not be given the same serial number. 59333f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @param user The user whose serial number is to be retrieved. 594b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * @return The serial number of the given user; returns -1 if the 595b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * given UserHandle does not exist. 59633f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @see #getUserForSerialNumber(long) 59733f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn */ 59833f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn public long getSerialNumberForUser(UserHandle user) { 59933f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn return getUserSerialNumber(user.getIdentifier()); 60033f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn } 60133f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn 60233f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn /** 60333f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * Return the user associated with a serial number previously 60433f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * returned by {@link #getSerialNumberForUser(UserHandle)}. 60533f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @param serialNumber The serial number of the user that is being 60633f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * retrieved. 60733f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @return Return the user associated with the serial number, or null 60833f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * if there is not one. 60933f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn * @see #getSerialNumberForUser(UserHandle) 61033f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn */ 61133f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn public UserHandle getUserForSerialNumber(long serialNumber) { 61233f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn int ident = getUserHandle((int)serialNumber); 61333f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn return ident >= 0 ? new UserHandle(ident) : null; 61433f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn } 61533f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn 61633f9cb8cf01e0a6288eb5b9ce724c56aa4e1e382Dianne Hackborn /** 617258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Creates a user with the specified name and options. 6181952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 619258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 620258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param name the user's name 621258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param flags flags that identify the type of user and other properties. 622258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @see UserInfo 623258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 624258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the UserInfo object for the created user, or null if the user could not be created. 625258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 626258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 627258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public UserInfo createUser(String name, int flags) { 628258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 629258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return mService.createUser(name, flags); 630258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 631258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani Log.w(TAG, "Could not create a user", re); 632258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return null; 633258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 634258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 635258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 636258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 6371e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * Creates a guest user and configures it. 6381e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @param context an application context 6391e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @param name the name to set for the user 6401e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani * @hide 6411e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani */ 6421e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani public UserInfo createGuest(Context context, String name) { 6431e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani UserInfo guest = createUser(name, UserInfo.FLAG_GUEST); 6441e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani if (guest != null) { 6451e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani Settings.Secure.putStringForUser(context.getContentResolver(), 6461e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani Settings.Secure.SKIP_FIRST_USE_HINTS, "1", guest.id); 647bf3a9465483976dcd5692b619b47132c2b95f73eAmith Yamasani try { 6488616af1a4dd1877996fbd5bb0179659f4f123573Amith Yamasani Bundle guestRestrictions = mService.getDefaultGuestRestrictions(); 6498616af1a4dd1877996fbd5bb0179659f4f123573Amith Yamasani guestRestrictions.putBoolean(DISALLOW_SMS, true); 6508616af1a4dd1877996fbd5bb0179659f4f123573Amith Yamasani mService.setUserRestrictions(guestRestrictions, guest.id); 651bf3a9465483976dcd5692b619b47132c2b95f73eAmith Yamasani } catch (RemoteException re) { 652bf3a9465483976dcd5692b619b47132c2b95f73eAmith Yamasani Log.w(TAG, "Could not update guest restrictions"); 653bf3a9465483976dcd5692b619b47132c2b95f73eAmith Yamasani } 6541e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani } 6551e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani return guest; 6561e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani } 6571e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani 6581e9c21871e81642669079cd290ef47818a3165bdAmith Yamasani /** 6592a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * Creates a user with the specified name and options as a profile of another user. 660a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 661a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * 662a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @param name the user's name 663a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @param flags flags that identify the type of user and other properties. 664a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @see UserInfo 6652a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @param userHandle new user will be a profile of this use. 666a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * 667a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @return the UserInfo object for the created user, or null if the user could not be created. 668a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy * @hide 669a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy */ 6702a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy public UserInfo createProfileForUser(String name, int flags, int userHandle) { 671a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy try { 6722a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy return mService.createProfileForUser(name, flags, userHandle); 673a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } catch (RemoteException re) { 674a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy Log.w(TAG, "Could not create a user", re); 675a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy return null; 676a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 677a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 678a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy 679a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy /** 680df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * Sets the user as enabled, if such an user exists. 681df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 682df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * Note that the default is true, it's only that managed profiles might not be enabled. 683df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * 684df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * @param userHandle the id of the profile to enable 685df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina * @hide 686df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina */ 687df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina public void setUserEnabled(int userHandle) { 688df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina try { 689df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina mService.setUserEnabled(userHandle); 690df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina } catch (RemoteException e) { 691df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina Log.w(TAG, "Could not enable the profile", e); 692df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina } 693df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina } 694df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina 695df35d570ed25257c6782e632ab1bae5e1603855aAlexandra Gherghina /** 696b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn * Return the number of users currently created on the device. 697b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn */ 698b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn public int getUserCount() { 699b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn List<UserInfo> users = getUsers(); 700b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn return users != null ? users.size() : 1; 701b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn } 702b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn 703b26306ad5277097b3abb345112b24d9a142fb299Dianne Hackborn /** 704258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Returns information for all users on this device. 7051952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 706258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @return the list of users that were created. 707258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 708258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 709258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public List<UserInfo> getUsers() { 710258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 711920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani return mService.getUsers(false); 712920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani } catch (RemoteException re) { 713920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani Log.w(TAG, "Could not get user list", re); 714920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani return null; 715920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani } 716920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani } 717920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani 718920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani /** 71995ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * Checks whether it's possible to add more users. Caller must hold the MANAGE_USERS 72095ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * permission. 72195ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * 72295ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * @return true if more users can be added, false if limit has been reached. 72395ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani * @hide 72495ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani */ 72595ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani public boolean canAddMoreUsers() { 72695ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani final List<UserInfo> users = getUsers(true); 72795ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani final int totalUserCount = users.size(); 72895ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani int aliveUserCount = 0; 72995ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani for (int i = 0; i < totalUserCount; i++) { 73095ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani UserInfo user = users.get(i); 73195ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani if (!user.isGuest()) { 73295ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani aliveUserCount++; 73395ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani } 73495ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani } 73595ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani return aliveUserCount < getMaxSupportedUsers(); 73695ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani } 73795ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani 73895ab7849444125387dc88088bb5197ee463d8c17Amith Yamasani /** 7392a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * Returns list of the profiles of userHandle including 7402a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * userHandle itself. 7414f7e2e334e4ca5f1a67baf4bdd40cd080b954161Amith Yamasani * Note that this returns both enabled and not enabled profiles. See 742385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina * {@link #getUserProfiles()} if you need only the enabled ones. 7434f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * 7442a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 7452a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @param userHandle profiles of this user will be returned. 7462a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @return the list of profiles. 7472a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy * @hide 7482a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy */ 7492a764949c943681a4d25a17a0b203a0127a4a486Kenny Guy public List<UserInfo> getProfiles(int userHandle) { 750a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy try { 751385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina return mService.getProfiles(userHandle, false /* enabledOnly */); 752a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } catch (RemoteException re) { 753a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy Log.w(TAG, "Could not get user list", re); 754a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy return null; 755a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 756a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy } 757a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy 758a52dc3eb40777b055c0ca8d7885bd2c9577bcd1aKenny Guy /** 759be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * Returns a list of UserHandles for profiles associated with the user that the calling process 760be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * is running on, including the user itself. 7614f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * 7624f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * @return A non-empty list of UserHandles associated with the calling user. 7634f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani */ 7644f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani public List<UserHandle> getUserProfiles() { 7654f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani ArrayList<UserHandle> profiles = new ArrayList<UserHandle>(); 766385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina List<UserInfo> users = new ArrayList<UserInfo>(); 767385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina try { 768f2e7b3f56ae0ea9f49b5c50413b9be71d5249d6dAlexandra Gherghina users = mService.getProfiles(UserHandle.myUserId(), true /* enabledOnly */); 769385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina } catch (RemoteException re) { 770385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina Log.w(TAG, "Could not get user list", re); 771385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina return null; 772385124d8cee38dee00d4fac31e8fbe46fb30565bAlexandra Gherghina } 7734f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani for (UserInfo info : users) { 7744f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani UserHandle userHandle = new UserHandle(info.id); 7754f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani profiles.add(userHandle); 7764f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 7774f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani return profiles; 7784f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 7794f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani 7807dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani /** 781be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * Returns the parent of the profile which this method is called from 782be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * or null if called from a user that is not a profile. 783be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * 784be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel * @hide 785be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel */ 786be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel public UserInfo getProfileParent(int userHandle) { 787be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel try { 788be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel return mService.getProfileParent(userHandle); 789be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel } catch (RemoteException re) { 790be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel Log.w(TAG, "Could not get profile parent", re); 791be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel return null; 792be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel } 793be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel } 794be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel 795be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel /** 7967dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * If the target user is a managed profile of the calling user or the caller 7977dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * is itself a managed profile, then this returns a badged copy of the given 798c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * icon to be able to distinguish it from the original icon. For badging an 799c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * arbitrary drawable use {@link #getBadgedDrawableForUser( 800c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 801c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * <p> 802c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * If the original drawable is a BitmapDrawable and the backing bitmap is 803c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 804c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * is performed in place and the original drawable is returned. 805c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * </p> 806c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * 807c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param icon The icon to badge. 808c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param user The target user. 809c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @return A drawable that combines the original icon and a badge as 810c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * determined by the system. 811c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav */ 812c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav public Drawable getBadgedIconForUser(Drawable icon, UserHandle user) { 813c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav final int badgeResId = getBadgeResIdForUser(user.getIdentifier()); 814c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (badgeResId == 0) { 815c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return icon; 816c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 817c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav Drawable badgeIcon = mContext.getPackageManager() 818c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav .getDrawable("system", badgeResId, null); 819c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return getBadgedDrawable(icon, badgeIcon, null, true); 820c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 821c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 822c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav /** 823c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * If the target user is a managed profile of the calling user or the caller 824c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * is itself a managed profile, then this returns a badged copy of the given 8257dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * icon to be able to distinguish it from the original icon. 826c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * <p> 8277dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * If the original drawable is not a BitmapDrawable, then the original 8287dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * drawable is returned. 829c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * </p> 8307dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * 8317dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * @param icon The icon to badge. 8327dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * @param user The target user. 8337dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * @return A drawable that combines the original icon and a badge as 8347dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani * determined by the system. 835c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * 836c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @deprecation Use {@link #getBadgedIconForUser( 837c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * android.graphics.drawable.Drawable, UserHandle)} 838c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * 839c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @hide 8407dda2657be1fcc808566dab3482df9d643ceb0f5Amith Yamasani */ 841c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav @Deprecated 8424f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani public Drawable getBadgedDrawableForUser(Drawable icon, UserHandle user) { 8434f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani int badgeResId = getBadgeResIdForUser(user.getIdentifier()); 8444f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani if (badgeResId == 0) { 8454f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani return icon; 8464f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } else { 8474f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani Drawable badgeIcon = mContext.getPackageManager() 8484f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani .getDrawable("system", badgeResId, null); 849c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return getBadgedDrawable(icon, badgeIcon, null, false); 850c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 851c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 852c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 853c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav /** 854c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * If the target user is a managed profile of the calling user or the caller 855c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * is itself a managed profile, then this returns a badged copy of the given 856c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * drawable allowing the user to distinguish it from the original drawable. 857c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * The caller can specify the location in the bounds of the drawable to be 858c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * badged where the badge should be applied as well as the density of the 859c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * badge to be used. 860c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * <p> 861c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * If the original drawable is a BitmapDrawable and the backing bitmap is 862c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 863c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * is performed in place and the original drawable is returned. 864c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * </p> 865c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * 866c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param badgedDrawable The drawable to badge. 867c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param user The target user. 868c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param badgeLocation Where in the bounds of the badged drawable to place 869c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * the badge. If not provided, the badge is applied on top of the entire 870c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * drawable being badged. 871c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param badgeDensity The optional desired density for the badge as per 872c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * {@link android.util.DisplayMetrics#densityDpi}. If not provided, 873c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * the density of the display is used. 874c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @return A drawable that combines the original drawable and a badge as 875c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * determined by the system. 876c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav */ 877c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav public Drawable getBadgedDrawableForUser(Drawable badgedDrawable, UserHandle user, 878c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav Rect badgeLocation, int badgeDensity) { 879c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav Drawable badgeDrawable = getBadgeForUser(user, badgeDensity); 880c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (badgeDrawable == null) { 881c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return badgedDrawable; 8824f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 883c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return getBadgedDrawable(badgedDrawable, badgeDrawable, badgeLocation, true); 8844f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 8854f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani 886701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy /** 887701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * If the target user is a managed profile of the calling user or the caller 888f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * is itself a managed profile, then this returns a copy of the label with 889f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * badging for accessibility services like talkback. E.g. passing in "Email" 890f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * and it might return "Work Email" for Email in the work profile. 891f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * 892f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * @param label The label to change. 893f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * @param user The target user. 894f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * @return A label that combines the original label and a badge as 895f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * determined by the system. 896f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy */ 897237aecd18d0edf56c038761f570758c310c9e6dfKenny Guy public CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user) { 898f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy UserInfo userInfo = getUserIfProfile(user.getIdentifier()); 899f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy if (userInfo != null && userInfo.isManagedProfile()) { 900f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy return Resources.getSystem().getString( 901f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy R.string.managed_profile_label_badge, label); 902f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy } 903f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy return label; 904f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy } 905f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy 906f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy /** 907f7ecf7c80520c017255cb350d183f0b62022349bKenny Guy * If the target user is a managed profile of the calling user or the caller 908701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * is itself a managed profile, then this returns a drawable to use as a small 909701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * icon to include in a view to distinguish it from the original icon. 910701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * 911701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * @param user The target user. 912c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * @param density The optional desired density for the badge as per 913c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * {@link android.util.DisplayMetrics#densityDpi}. If not provided 914c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav * the density of the current display is used. 915701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * @return the drawable or null if no drawable is required. 916701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * @hide 917701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy */ 918c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav public Drawable getBadgeForUser(UserHandle user, int density) { 919701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy UserInfo userInfo = getUserIfProfile(user.getIdentifier()); 920701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy if (userInfo != null && userInfo.isManagedProfile()) { 921c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (density <= 0) { 922c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav density = mContext.getResources().getDisplayMetrics().densityDpi; 923c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 924c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return Resources.getSystem().getDrawableForDensity( 925c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav com.android.internal.R.drawable.ic_corp_badge, density); 926701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy } 927701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy return null; 928701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy } 929701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy 9304f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani private int getBadgeResIdForUser(int userHandle) { 9314f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani // Return the framework-provided badge. 932701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy UserInfo userInfo = getUserIfProfile(userHandle); 933701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy if (userInfo != null && userInfo.isManagedProfile()) { 934701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy return com.android.internal.R.drawable.ic_corp_icon_badge; 935701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy } 936701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy return 0; 937701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy } 938701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy 939701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy /** 940701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * @return UserInfo for userHandle if it exists and is a profile of the current 941701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy * user or null. 942701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy */ 943701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy private UserInfo getUserIfProfile(int userHandle) { 944be81c800ae6216e30b6008b4c73172b36531c405Jessica Hummel List<UserInfo> userProfiles = getProfiles(getUserHandle()); 9455abdbb656063160ff8df2306bd01feba0714d4c1Amith Yamasani for (UserInfo user : userProfiles) { 946701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy if (user.id == userHandle) { 947701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy return user; 9484f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 9494f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 950701ea7cf86b7d408b8d3bc1aab054be0333e1f26Kenny Guy return null; 9514f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 9524f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani 953c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav private Drawable getBadgedDrawable(Drawable badgedDrawable, Drawable badgeDrawable, 954c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav Rect badgeLocation, boolean tryBadgeInPlace) { 955c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav final int badgedWidth = badgedDrawable.getIntrinsicWidth(); 956c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav final int badgedHeight = badgedDrawable.getIntrinsicHeight(); 957c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav final boolean canBadgeInPlace = tryBadgeInPlace 958c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav && (badgedDrawable instanceof BitmapDrawable) 959c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav && ((BitmapDrawable) badgedDrawable).getBitmap().isMutable(); 960c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 961c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav final Bitmap bitmap; 962c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (canBadgeInPlace) { 963c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav bitmap = ((BitmapDrawable) badgedDrawable).getBitmap(); 964c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } else { 965c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav bitmap = Bitmap.createBitmap(badgedWidth, badgedHeight, Config.ARGB_8888); 966c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 9674f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani Canvas canvas = new Canvas(bitmap); 968c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 969c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (!canBadgeInPlace) { 970c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav badgedDrawable.setBounds(0, 0, badgedWidth, badgedHeight); 971c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav badgedDrawable.draw(canvas); 9724f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 973c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 974c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (badgeLocation != null) { 975c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (badgeLocation.left < 0 || badgeLocation.top < 0 976681bf60ce2a3973d5982f9b7a405bcef5fb72f20Sunny Goyal || badgeLocation.width() > badgedWidth || badgeLocation.height() > badgedHeight) { 977c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav throw new IllegalArgumentException("Badge location " + badgeLocation 978c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav + " not in badged drawable bounds " 979c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav + new Rect(0, 0, badgedWidth, badgedHeight)); 980c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 981c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav badgeDrawable.setBounds(0, 0, badgeLocation.width(), badgeLocation.height()); 982c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 983c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav canvas.save(); 984c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav canvas.translate(badgeLocation.left, badgeLocation.top); 985c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav badgeDrawable.draw(canvas); 986c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav canvas.restore(); 987c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } else { 988c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav badgeDrawable.setBounds(0, 0, badgedWidth, badgedHeight); 989c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav badgeDrawable.draw(canvas); 990c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 991c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 992c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (!canBadgeInPlace) { 993c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav BitmapDrawable mergedDrawable = new BitmapDrawable(mContext.getResources(), bitmap); 994c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 995c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav if (badgedDrawable instanceof BitmapDrawable) { 996c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav BitmapDrawable bitmapDrawable = (BitmapDrawable) badgedDrawable; 997c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav mergedDrawable.setTargetDensity(bitmapDrawable.getBitmap().getDensity()); 998c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 999c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 1000c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return mergedDrawable; 1001c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav } 1002c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav 1003c71c42fdb2ee54a419dc8eb0a5f4f82532b16c0cSvetoslav return badgedDrawable; 10044f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani } 10054f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani 10064f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani /** 10074f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * Returns information for all users on this device. Requires 10084f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * {@link android.Manifest.permission#MANAGE_USERS} permission. 1009394a6cdd987fed79bd040f39e2d3e47d4484bab4Emily Bernier * 10104f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * @param excludeDying specify if the list should exclude users being 10114f58263d02f296430a9653126d28501e95c7bb6cAmith Yamasani * removed. 1012920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani * @return the list of users that were created. 1013920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani * @hide 1014920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani */ 1015920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani public List<UserInfo> getUsers(boolean excludeDying) { 1016920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani try { 1017920ace0bbc2d4133dbec991d2636c99a57d6245eAmith Yamasani return mService.getUsers(excludeDying); 1018258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1019258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani Log.w(TAG, "Could not get user list", re); 1020258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return null; 1021258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1022258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1023258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1024258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 1025258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Removes a user and all associated data. 10261952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1027258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the integer handle of the user, where 0 is the primary user. 1028258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1029258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 1030258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public boolean removeUser(int userHandle) { 1031258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1032258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return mService.removeUser(userHandle); 1033258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1034258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani Log.w(TAG, "Could not remove user ", re); 1035258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani return false; 1036258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1037258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1038258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1039258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 1040258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Updates the user's name. 10411952637425eece18aa1ce3d80d4b49086ef3bcf7Amith Yamasani * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. 1042258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * 1043258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the user's integer handle 1044258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param name the new name for the user 1045258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1046258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 1047258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani public void setUserName(int userHandle, String name) { 1048258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1049258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani mService.setUserName(userHandle, name); 1050258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1051258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani Log.w(TAG, "Could not set the user name ", re); 1052258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1053258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1054258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1055258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 1056e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani * Sets the user's photo. 1057258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @param userHandle the user for whom to change the photo. 1058e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani * @param icon the bitmap to set as the photo. 1059258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1060258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 1061e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani public void setUserIcon(int userHandle, Bitmap icon) { 1062258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani try { 1063e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani mService.setUserIcon(userHandle, icon); 1064258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } catch (RemoteException re) { 1065258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani Log.w(TAG, "Could not set the user icon ", re); 1066258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1067258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 1068258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani 1069258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani /** 10703b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani * Returns a file descriptor for the user's photo. PNG data can be read from this file. 10713b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani * @param userHandle the user whose photo we want to read. 1072e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani * @return a {@link Bitmap} of the user's photo, or null if there's no photo. 10733b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani * @hide 10743b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani */ 1075e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani public Bitmap getUserIcon(int userHandle) { 10763b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani try { 10773b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani return mService.getUserIcon(userHandle); 10783b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani } catch (RemoteException re) { 1079e928d7d95dbb64627e6ff3a0572190c555b59d96Amith Yamasani Log.w(TAG, "Could not get the user icon ", re); 10803b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani return null; 10813b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani } 10823b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani } 10833b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani 10843b49f07a452e0a77c1d22db2065255689a461d31Amith Yamasani /** 1085258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * Returns the maximum number of users that can be created on this device. A return value 1086258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * of 1 means that it is a single user device. 1087258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani * @hide 1088a12fccf57d5ec289793699d9b22ff45daccd3933Maggie Benthall * @return a value greater than or equal to 1 1089258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani */ 109027bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkey public static int getMaxSupportedUsers() { 1091ff54920ed222a2bd6abe618743a5a3e9fe10bd4bAmith Yamasani // Don't allow multiple users on certain builds 1092ff54920ed222a2bd6abe618743a5a3e9fe10bd4bAmith Yamasani if (android.os.Build.ID.startsWith("JVP")) return 1; 1093409297da182267465adbc21cfb75a23e8d678117Dianne Hackborn // Svelte devices don't get multi-user. 1094409297da182267465adbc21cfb75a23e8d678117Dianne Hackborn if (ActivityManager.isLowRamDeviceStatic()) return 1; 109527bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkey return SystemProperties.getInt("fw.max_users", 109627bd34d9d9fe99f11b80aa0bbdb402fb47ef4158Jeff Sharkey Resources.getSystem().getInteger(R.integer.config_multiuserMaximumUsers)); 1097258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani } 10982a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani 10992a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani /** 11001a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy * Returns true if the user switcher should be shown, this will be if there 11011a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy * are multiple users that aren't managed profiles. 11021a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy * @hide 11031a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy * @return true if user switcher should be shown. 11041a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy */ 11051a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy public boolean isUserSwitcherEnabled() { 11061a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy List<UserInfo> users = getUsers(true); 11071a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy if (users == null) { 11081a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy return false; 11091a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 11101a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy int switchableUserCount = 0; 11111a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy for (UserInfo user : users) { 11121a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy if (user.supportsSwitchTo()) { 11131a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy ++switchableUserCount; 11141a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 11151a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 1116a596ff87cd899640334512371456b8481ba21b4aAmith Yamasani final boolean guestEnabled = Settings.Global.getInt(mContext.getContentResolver(), 1117a596ff87cd899640334512371456b8481ba21b4aAmith Yamasani Settings.Global.GUEST_USER_ENABLED, 0) == 1; 1118a596ff87cd899640334512371456b8481ba21b4aAmith Yamasani return switchableUserCount > 1 || guestEnabled; 11191a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy } 11201a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy 11211a447535cef7e3739d5f763dfe13e568568b9789Kenny Guy /** 11222a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * Returns a serial number on this device for a given userHandle. User handles can be recycled 11232a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * when deleting and creating users, but serial numbers are not reused until the device is wiped. 11242a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @param userHandle 11252a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @return a serial number associated with that user, or -1 if the userHandle is not valid. 11262a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @hide 11272a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani */ 11282a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani public int getUserSerialNumber(int userHandle) { 11292a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani try { 11302a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani return mService.getUserSerialNumber(userHandle); 11312a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } catch (RemoteException re) { 11322a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani Log.w(TAG, "Could not get serial number for user " + userHandle); 11332a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 11342a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani return -1; 11352a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 11362a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani 11372a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani /** 11382a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * Returns a userHandle on this device for a given user serial number. User handles can be 11392a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * recycled when deleting and creating users, but serial numbers are not reused until the device 11402a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * is wiped. 11412a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @param userSerialNumber 11422a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @return the userHandle associated with that user serial number, or -1 if the serial number 11432a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * is not valid. 11442a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani * @hide 11452a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani */ 11462a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani public int getUserHandle(int userSerialNumber) { 11472a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani try { 11482a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani return mService.getUserHandle(userSerialNumber); 11492a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } catch (RemoteException re) { 11502a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani Log.w(TAG, "Could not get userHandle for user " + userSerialNumber); 11512a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 11522a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani return -1; 11532a00329c6d55c6cd9166e01963d7410e95d80d21Amith Yamasani } 11546794458f8626c3be27eac3db3a5c89d94f132675Maggie Benthall 11557e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani /** 11567e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * Returns a Bundle containing any saved application restrictions for this user, for the 11577e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * given package name. Only an application with this package name can call this method. 11587e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * @param packageName the package name of the calling application 11597e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * @return a Bundle with the restrictions as key/value pairs, or null if there are no 11607e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * saved restrictions. The values can be of type Boolean, String or String[], depending 11617e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani * on the restriction type, as defined by the application. 11627e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani */ 11637e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani public Bundle getApplicationRestrictions(String packageName) { 11647e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani try { 11657e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani return mService.getApplicationRestrictions(packageName); 11667e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani } catch (RemoteException re) { 11677e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani Log.w(TAG, "Could not get application restrictions for package " + packageName); 11687e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani } 11697e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani return null; 11707e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani } 1171df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 1172df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani /** 1173df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * @hide 1174df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */ 11757e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani public Bundle getApplicationRestrictions(String packageName, UserHandle user) { 1176df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani try { 11777e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani return mService.getApplicationRestrictionsForUser(packageName, user.getIdentifier()); 1178df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } catch (RemoteException re) { 1179df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani Log.w(TAG, "Could not get application restrictions for user " + user.getIdentifier()); 1180df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 1181df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani return null; 1182df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 1183df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani 1184df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani /** 1185df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani * @hide 1186df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani */ 11877e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani public void setApplicationRestrictions(String packageName, Bundle restrictions, 1188df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani UserHandle user) { 1189df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani try { 11907e99bc02c8e2f44dd92d70bfa6e654297e5286d8Amith Yamasani mService.setApplicationRestrictions(packageName, restrictions, user.getIdentifier()); 1191df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } catch (RemoteException re) { 1192df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani Log.w(TAG, "Could not set application restrictions for user " + user.getIdentifier()); 1193df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 1194df2e92a535e19c00edd37318d974dab992ccc2c1Amith Yamasani } 1195655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani 1196655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** 1197d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * Sets a new challenge PIN for restrictions. This is only for use by pre-installed 1198d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * apps and requires the MANAGE_USERS permission. 1199d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * @param newPin the PIN to use for challenge dialogs. 1200d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * @return Returns true if the challenge PIN was set successfully. 1201655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani */ 1202d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani public boolean setRestrictionsChallenge(String newPin) { 1203655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani try { 1204d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani return mService.setRestrictionsChallenge(newPin); 1205655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } catch (RemoteException re) { 1206655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani Log.w(TAG, "Could not change restrictions pin"); 1207655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } 1208655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani return false; 1209655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } 1210655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani 1211655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** 1212655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * @hide 1213655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * @param pin The PIN to verify, or null to get the number of milliseconds to wait for before 1214655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * allowing the user to enter the PIN. 1215655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * @return Returns a positive number (including zero) for how many milliseconds before 1216655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * you can accept another PIN, when the input is null or the input doesn't match the saved PIN. 1217655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * Returns {@link #PIN_VERIFICATION_SUCCESS} if the input matches the saved PIN. Returns 1218655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * {@link #PIN_VERIFICATION_FAILED_NOT_SET} if there is no PIN set. 1219655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani */ 1220d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani public int checkRestrictionsChallenge(String pin) { 1221655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani try { 1222d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani return mService.checkRestrictionsChallenge(pin); 1223655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } catch (RemoteException re) { 1224655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani Log.w(TAG, "Could not check restrictions pin"); 1225655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } 1226655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani return PIN_VERIFICATION_FAILED_INCORRECT; 1227655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } 1228655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani 1229655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani /** 1230d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * @hide 1231655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * Checks whether the user has restrictions that are PIN-protected. An application that 1232655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * participates in restrictions can check if the owner has requested a PIN challenge for 1233655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * any restricted operations. If there is a PIN in effect, the application should launch 1234d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * the PIN challenge activity {@link android.content.Intent#ACTION_RESTRICTIONS_CHALLENGE}. 1235d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani * @see android.content.Intent#ACTION_RESTRICTIONS_CHALLENGE 1236655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani * @return whether a restrictions PIN is in effect. 1237655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani */ 1238d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani public boolean hasRestrictionsChallenge() { 1239655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani try { 1240d304af69891483aad808356af1ac5f00e90c8edfAmith Yamasani return mService.hasRestrictionsChallenge(); 1241655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } catch (RemoteException re) { 1242655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani Log.w(TAG, "Could not change restrictions pin"); 1243655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } 1244655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani return false; 1245655d0e2029e6ae77a47e922dce4c4989818b8dd1Amith Yamasani } 12461a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani 12471a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani /** @hide */ 12481a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani public void removeRestrictions() { 12491a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani try { 12501a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani mService.removeRestrictions(); 12511a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani } catch (RemoteException re) { 12521a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani Log.w(TAG, "Could not change restrictions pin"); 12531a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani } 12541a7472e7220a2b027464fb4a2281550f784a2ca3Amith Yamasani } 1255e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani 1256e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani /** 1257e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * @hide 1258e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * Set restrictions that should apply to any future guest user that's created. 1259e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani */ 1260e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani public void setDefaultGuestRestrictions(Bundle restrictions) { 1261e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani try { 1262e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani mService.setDefaultGuestRestrictions(restrictions); 1263e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } catch (RemoteException re) { 1264e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani Log.w(TAG, "Could not set guest restrictions"); 1265e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 1266e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 1267e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani 1268e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani /** 1269e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * @hide 1270e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani * Gets the default guest restrictions. 1271e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani */ 1272e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani public Bundle getDefaultGuestRestrictions() { 1273e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani try { 1274e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani return mService.getDefaultGuestRestrictions(); 1275e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } catch (RemoteException re) { 1276e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani Log.w(TAG, "Could not set guest restrictions"); 1277e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 1278e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani return new Bundle(); 1279e4afaa3a3d7c2885b82fe43f51bcf04e036f7462Amith Yamasani } 1280258848d2ae04f447ff1c18023fa76b139fcc0862Amith Yamasani} 1281