Show different error screen for PS creation based on error
This contains the change to show a different fragment on private space creation error based on the error code returned by UserManager. On private space create error checks for the returned error code and if PS is not supported on the device showns error screen containing a link to Help Center atricle to find out more about the reason for profile creation failure. ACTION_PRIVATE_SPACE_SETUP_SPACE_ERRORS metric is logged with the error code on create error else 0 on sucessful space creation. Recording: b/340130375#comment17 Bug: 340130375 Test: Manual Flag: android.multiuser.show_different_creation_error_for_unsupported_devices Change-Id: Ifa0345fb6aad64599009f8aa79d168f57fd35c03
This commit is contained in:
@@ -60,6 +60,7 @@ public class PrivateSpaceMaintainer {
|
||||
private final Context mContext;
|
||||
private final UserManager mUserManager;
|
||||
private final ActivityManager mActivityManager;
|
||||
private int mErrorCode;
|
||||
@GuardedBy("this")
|
||||
private UserHandle mUserHandle;
|
||||
private final KeyguardManager mKeyguardManager;
|
||||
@@ -111,6 +112,9 @@ public class PrivateSpaceMaintainer {
|
||||
userName, USER_TYPE_PROFILE_PRIVATE, new ArraySet<>());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error creating private space", e);
|
||||
if (android.multiuser.Flags.showDifferentCreationErrorForUnsupportedDevices()) {
|
||||
mErrorCode = ((UserManager.UserOperationException) e).getUserOperationResult();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -312,6 +316,11 @@ public class PrivateSpaceMaintainer {
|
||||
return mUserManager.canAddPrivateProfile() || doesPrivateSpaceExist();
|
||||
}
|
||||
|
||||
/** Returns the error code for private space creation failure*/
|
||||
public int getPrivateSpaceCreateError() {
|
||||
return mErrorCode;
|
||||
}
|
||||
|
||||
/** Returns true if private space exists and is running, otherwise returns false */
|
||||
@VisibleForTesting
|
||||
synchronized boolean isPrivateProfileRunning() {
|
||||
|
||||
Reference in New Issue
Block a user