Merge "DO NOT MERGE - Defer migration to CarUserManagerHelper, until CarSysUI" into pi-dev
am: 330713b381
Change-Id: I16ae2912f0650a9712bd6e0dd8dd1986537c9050
This commit is contained in:
@@ -18,13 +18,13 @@ package com.android.systemui.statusbar.car;
|
|||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.car.user.CarUserManagerHelper;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewStub;
|
import android.view.ViewStub;
|
||||||
|
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
|
||||||
|
import com.android.settingslib.users.UserManagerHelper;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.statusbar.phone.StatusBar;
|
import com.android.systemui.statusbar.phone.StatusBar;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public class FullscreenUserSwitcher {
|
|||||||
private final UserGridRecyclerView mUserGridView;
|
private final UserGridRecyclerView mUserGridView;
|
||||||
private final int mShortAnimDuration;
|
private final int mShortAnimDuration;
|
||||||
private final StatusBar mStatusBar;
|
private final StatusBar mStatusBar;
|
||||||
private final CarUserManagerHelper mCarUserManagerHelper;
|
private final UserManagerHelper mUserManagerHelper;
|
||||||
private int mCurrentForegroundUserId;
|
private int mCurrentForegroundUserId;
|
||||||
private boolean mShowing;
|
private boolean mShowing;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class FullscreenUserSwitcher {
|
|||||||
mUserGridView.buildAdapter();
|
mUserGridView.buildAdapter();
|
||||||
mUserGridView.setUserSelectionListener(this::onUserSelected);
|
mUserGridView.setUserSelectionListener(this::onUserSelected);
|
||||||
|
|
||||||
mCarUserManagerHelper = new CarUserManagerHelper(context);
|
mUserManagerHelper = new UserManagerHelper(context);
|
||||||
updateCurrentForegroundUser();
|
updateCurrentForegroundUser();
|
||||||
|
|
||||||
mShortAnimDuration = mContainer.getResources()
|
mShortAnimDuration = mContainer.getResources()
|
||||||
@@ -84,11 +84,11 @@ public class FullscreenUserSwitcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean foregroundUserChanged() {
|
private boolean foregroundUserChanged() {
|
||||||
return mCurrentForegroundUserId != mCarUserManagerHelper.getCurrentForegroundUserId();
|
return mCurrentForegroundUserId != mUserManagerHelper.getForegroundUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentForegroundUser() {
|
private void updateCurrentForegroundUser() {
|
||||||
mCurrentForegroundUserId = mCarUserManagerHelper.getCurrentForegroundUserId();
|
mCurrentForegroundUserId = mUserManagerHelper.getForegroundUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
|
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import static android.content.DialogInterface.BUTTON_POSITIVE;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.car.user.CarUserManagerHelper;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
@@ -42,6 +41,7 @@ import android.widget.TextView;
|
|||||||
import androidx.car.widget.PagedListView;
|
import androidx.car.widget.PagedListView;
|
||||||
|
|
||||||
import com.android.internal.util.UserIcons;
|
import com.android.internal.util.UserIcons;
|
||||||
|
import com.android.settingslib.users.UserManagerHelper;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
|
||||||
import com.android.systemui.statusbar.phone.SystemUIDialog;
|
import com.android.systemui.statusbar.phone.SystemUIDialog;
|
||||||
@@ -53,16 +53,16 @@ import java.util.List;
|
|||||||
* One of the uses of this is for the lock screen in auto.
|
* One of the uses of this is for the lock screen in auto.
|
||||||
*/
|
*/
|
||||||
public class UserGridRecyclerView extends PagedListView implements
|
public class UserGridRecyclerView extends PagedListView implements
|
||||||
CarUserManagerHelper.OnUsersUpdateListener {
|
UserManagerHelper.OnUsersUpdateListener {
|
||||||
private UserSelectionListener mUserSelectionListener;
|
private UserSelectionListener mUserSelectionListener;
|
||||||
private UserAdapter mAdapter;
|
private UserAdapter mAdapter;
|
||||||
private CarUserManagerHelper mCarUserManagerHelper;
|
private UserManagerHelper mUserManagerHelper;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public UserGridRecyclerView(Context context, AttributeSet attrs) {
|
public UserGridRecyclerView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mCarUserManagerHelper = new CarUserManagerHelper(mContext);
|
mUserManagerHelper = new UserManagerHelper(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +71,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
@Override
|
@Override
|
||||||
public void onFinishInflate() {
|
public void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
mCarUserManagerHelper.registerOnUsersUpdateListener(this);
|
mUserManagerHelper.registerOnUsersUpdateListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +80,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
@Override
|
@Override
|
||||||
public void onDetachedFromWindow() {
|
public void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
mCarUserManagerHelper.unregisterOnUsersUpdateListener();
|
mUserManagerHelper.unregisterOnUsersUpdateListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,8 +89,8 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
* @return the adapter
|
* @return the adapter
|
||||||
*/
|
*/
|
||||||
public void buildAdapter() {
|
public void buildAdapter() {
|
||||||
List<UserRecord> userRecords = createUserRecords(mCarUserManagerHelper
|
List<UserRecord> userRecords = createUserRecords(mUserManagerHelper
|
||||||
.getAllUsers());
|
.getAllUsersExcludesSystemUser());
|
||||||
mAdapter = new UserAdapter(mContext, userRecords);
|
mAdapter = new UserAdapter(mContext, userRecords);
|
||||||
super.setAdapter(mAdapter);
|
super.setAdapter(mAdapter);
|
||||||
}
|
}
|
||||||
@@ -103,19 +103,19 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean isForeground =
|
boolean isForeground =
|
||||||
mCarUserManagerHelper.getCurrentForegroundUserId() == userInfo.id;
|
mUserManagerHelper.getForegroundUserId() == userInfo.id;
|
||||||
UserRecord record = new UserRecord(userInfo, false /* isStartGuestSession */,
|
UserRecord record = new UserRecord(userInfo, false /* isStartGuestSession */,
|
||||||
false /* isAddUser */, isForeground);
|
false /* isAddUser */, isForeground);
|
||||||
userRecords.add(record);
|
userRecords.add(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add guest user record if the foreground user is not a guest
|
// Add guest user record if the foreground user is not a guest
|
||||||
if (!mCarUserManagerHelper.isForegroundUserGuest()) {
|
if (!mUserManagerHelper.foregroundUserIsGuestUser()) {
|
||||||
userRecords.add(addGuestUserRecord());
|
userRecords.add(addGuestUserRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add add user record if the foreground user can add users
|
// Add add user record if the foreground user can add users
|
||||||
if (mCarUserManagerHelper.canForegroundUserAddUsers()) {
|
if (mUserManagerHelper.foregroundUserCanAddUsers()) {
|
||||||
userRecords.add(addUserRecord());
|
userRecords.add(addUserRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
@Override
|
@Override
|
||||||
public void onUsersUpdate() {
|
public void onUsersUpdate() {
|
||||||
mAdapter.clearUsers();
|
mAdapter.clearUsers();
|
||||||
mAdapter.updateUsers(createUserRecords(mCarUserManagerHelper.getAllUsers()));
|
mAdapter.updateUsers(createUserRecords(mUserManagerHelper.getAllUsersExcludesSystemUser()));
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
|
|
||||||
// If the user selects Guest, start the guest session.
|
// If the user selects Guest, start the guest session.
|
||||||
if (userRecord.mIsStartGuestSession) {
|
if (userRecord.mIsStartGuestSession) {
|
||||||
mCarUserManagerHelper.startNewGuestSession(mGuestName);
|
mUserManagerHelper.startNewGuestSession(mGuestName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,14 +240,14 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the user doesn't want to be a guest or add a user, switch to the user selected
|
// If the user doesn't want to be a guest or add a user, switch to the user selected
|
||||||
mCarUserManagerHelper.switchToUser(userRecord.mInfo);
|
mUserManagerHelper.switchToUser(userRecord.mInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap getUserRecordIcon(UserRecord userRecord) {
|
private Bitmap getUserRecordIcon(UserRecord userRecord) {
|
||||||
if (userRecord.mIsStartGuestSession) {
|
if (userRecord.mIsStartGuestSession) {
|
||||||
return mCarUserManagerHelper.getGuestDefaultIcon();
|
return mUserManagerHelper.getGuestDefaultIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userRecord.mIsAddUser) {
|
if (userRecord.mIsAddUser) {
|
||||||
@@ -255,7 +255,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
.getDrawable(R.drawable.car_add_circle_round));
|
.getDrawable(R.drawable.car_add_circle_round));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mCarUserManagerHelper.getUserIcon(userRecord.mInfo);
|
return mUserManagerHelper.getUserIcon(userRecord.mInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -273,10 +273,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected UserInfo doInBackground(String... userNames) {
|
protected UserInfo doInBackground(String... userNames) {
|
||||||
// Default to create a non admin user for now. Need to add logic
|
return mUserManagerHelper.createNewUser(userNames[0]);
|
||||||
// for user to choose whether they want to create an admin or non-admin
|
|
||||||
// user later.
|
|
||||||
return mCarUserManagerHelper.createNewNonAdminUser(userNames[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,7 +283,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(UserInfo user) {
|
protected void onPostExecute(UserInfo user) {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
mCarUserManagerHelper.switchToUser(user);
|
mUserManagerHelper.switchToUser(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user