Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8620804 authored by Anthony Hugh's avatar Anthony Hugh
Browse files

Remove CarUserManagerHelper #getCurrentForegroundUserInfo and #getCurrentForegroundUserId

Removes these two APIs in favor of using UserManager APIs and
ActivityManager.getCurrentUser().

Bug: 131776619
Test: atest CarServiceUnitTest
Test: atest CarServiceTest
Test: atest CarSettingsRoboTests
Change-Id: I9dd4b5757d18946e3670a380cf504eb267f755b2
parent a063a5ff
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.car;
import static android.content.DialogInterface.BUTTON_NEGATIVE;
import static android.content.DialogInterface.BUTTON_POSITIVE;

import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
@@ -34,6 +35,7 @@ import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.AsyncTask;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -61,6 +63,7 @@ public class UserGridRecyclerView extends RecyclerView {
    private UserSelectionListener mUserSelectionListener;
    private UserAdapter mAdapter;
    private CarUserManagerHelper mCarUserManagerHelper;
    private UserManager mUserManager;
    private Context mContext;

    private final BroadcastReceiver mUserUpdateReceiver = new BroadcastReceiver() {
@@ -74,8 +77,9 @@ public class UserGridRecyclerView extends RecyclerView {
        super(context, attrs);
        mContext = context;
        mCarUserManagerHelper = new CarUserManagerHelper(mContext);
        mUserManager = UserManager.get(mContext);

        addItemDecoration(new ItemSpacingDecoration(context.getResources().getDimensionPixelSize(
        addItemDecoration(new ItemSpacingDecoration(mContext.getResources().getDimensionPixelSize(
                R.dimen.car_user_switcher_vertical_spacing_between_users)));
    }

@@ -124,8 +128,7 @@ public class UserGridRecyclerView extends RecyclerView {
                continue;
            }

            boolean isForeground =
                    mCarUserManagerHelper.getCurrentForegroundUserId() == userInfo.id;
            boolean isForeground = ActivityManager.getCurrentUser() == userInfo.id;
            UserRecord record = new UserRecord(userInfo, false /* isStartGuestSession */,
                    false /* isAddUser */, isForeground);
            userRecords.add(record);
@@ -143,7 +146,7 @@ public class UserGridRecyclerView extends RecyclerView {
    }

    private UserRecord createForegroundUserRecord() {
        return new UserRecord(mCarUserManagerHelper.getCurrentForegroundUserInfo(),
        return new UserRecord(mUserManager.getUserInfo(ActivityManager.getCurrentUser()),
                false /* isStartGuestSession */, false /* isAddUser */, true /* isForeground */);
    }

+2 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.systemui.statusbar.car.privacy;

import android.car.userlib.CarUserManagerHelper;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -34,10 +34,9 @@ public class PrivacyApplication {

    public PrivacyApplication(String packageName, Context context) {
        try {
            CarUserManagerHelper carUserManagerHelper = new CarUserManagerHelper(context);
            ApplicationInfo app = context.getPackageManager()
                    .getApplicationInfoAsUser(packageName, 0,
                            carUserManagerHelper.getCurrentForegroundUserId());
                            ActivityManager.getCurrentUser());
            mIcon = context.getPackageManager().getApplicationIcon(app);
            mApplicationName = context.getPackageManager().getApplicationLabel(app).toString();
        } catch (PackageManager.NameNotFoundException e) {