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

Commit e9e14d9c authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Expose managed profile sensitiveness preferences"

parents b90b74b4 960b7e7f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.InitController;
import com.android.systemui.SystemUIAppComponentFactory;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.KeyguardSliceProvider;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.InjectionInflationController;

@@ -105,4 +106,9 @@ public interface SystemUIRootComponent {
     * Member injection into the supplied argument.
     */
    void inject(ContentProvider contentProvider);

    /**
     * Member injection into the supplied argument.
     */
    void inject(KeyguardSliceProvider keyguardSliceProvider);
}
+32 −44
Original line number Diff line number Diff line
@@ -52,13 +52,13 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SystemUIAppComponentFactory;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.NextAlarmControllerImpl;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.util.wakelock.SettableWakeLock;
import com.android.systemui.util.wakelock.WakeLock;
@@ -68,6 +68,8 @@ import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;

import javax.inject.Inject;

/**
 * Simple Slice provider that shows the current date.
 */
@@ -108,26 +110,31 @@ public class KeyguardSliceProvider extends SliceProvider implements
    private final Handler mHandler;
    private final Handler mMediaHandler;
    private final AlarmManager.OnAlarmListener mUpdateNextAlarm = this::updateNextAlarm;
    private DozeParameters mDozeParameters;
    @Inject
    public DozeParameters mDozeParameters;
    @VisibleForTesting
    protected SettableWakeLock mMediaWakeLock;
    @VisibleForTesting
    protected ZenModeController mZenModeController;
    @Inject
    public ZenModeController mZenModeController;
    private String mDatePattern;
    private DateFormat mDateFormat;
    private String mLastText;
    private boolean mRegistered;
    private String mNextAlarm;
    private NextAlarmController mNextAlarmController;
    @VisibleForTesting
    protected AlarmManager mAlarmManager;
    @VisibleForTesting
    protected ContentResolver mContentResolver;
    @Inject
    public NextAlarmController mNextAlarmController;
    @Inject
    public AlarmManager mAlarmManager;
    @Inject
    public ContentResolver mContentResolver;
    private AlarmManager.AlarmClockInfo mNextAlarmInfo;
    private PendingIntent mPendingIntent;
    protected NotificationMediaManager mMediaManager;
    private StatusBarStateController mStatusBarStateController;
    private KeyguardBypassController mKeyguardBypassController;
    @Inject
    public NotificationMediaManager mMediaManager;
    @Inject
    public StatusBarStateController mStatusBarStateController;
    @Inject
    public KeyguardBypassController mKeyguardBypassController;
    private CharSequence mMediaTitle;
    private CharSequence mMediaArtist;
    protected boolean mDozing;
@@ -188,26 +195,6 @@ public class KeyguardSliceProvider extends SliceProvider implements
        mMediaUri = Uri.parse(KEYGUARD_MEDIA_URI);
    }

    /**
     * Initialize dependencies that don't exist during {@link android.content.ContentProvider}
     * instantiation.
     *
     * @param mediaManager {@link NotificationMediaManager} singleton.
     * @param statusBarStateController {@link StatusBarStateController} singleton.
     */
    public void initDependencies(
            NotificationMediaManager mediaManager,
            StatusBarStateController statusBarStateController,
            KeyguardBypassController keyguardBypassController,
            DozeParameters dozeParameters) {
        mMediaManager = mediaManager;
        mMediaManager.addCallback(this);
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController.addCallback(this);
        mKeyguardBypassController = keyguardBypassController;
        mDozeParameters = dozeParameters;
    }

    @AnyThread
    @Override
    public Slice onBindSlice(Uri sliceUri) {
@@ -310,25 +297,19 @@ public class KeyguardSliceProvider extends SliceProvider implements

    @Override
    public boolean onCreateSliceProvider() {
        if (mContextAvailableCallback != null) {
        mContextAvailableCallback.onContextAvailable(getContext());
        }
        inject();
        synchronized (KeyguardSliceProvider.sInstanceLock) {
            KeyguardSliceProvider oldInstance = KeyguardSliceProvider.sInstance;
            if (oldInstance != null) {
                oldInstance.onDestroy();
            }

            mAlarmManager = getContext().getSystemService(AlarmManager.class);
            mContentResolver = getContext().getContentResolver();
            mNextAlarmController = new NextAlarmControllerImpl(getContext());
            mNextAlarmController.addCallback(this);
            mZenModeController = Dependency.get(ZenModeController.class);
            mZenModeController.addCallback(this);
            mDatePattern = getContext().getString(R.string.system_ui_aod_date_pattern);
            mPendingIntent = PendingIntent.getActivity(getContext(), 0, new Intent(), 0);
            mMediaWakeLock = new SettableWakeLock(WakeLock.createPartial(getContext(), "media"),
                    "media");
            mMediaManager.addCallback(this);
            mStatusBarStateController.addCallback(this);
            mNextAlarmController.addCallback(this);
            mZenModeController.addCallback(this);
            KeyguardSliceProvider.sInstance = this;
            registerClockUpdate();
            updateClockLocked();
@@ -336,6 +317,13 @@ public class KeyguardSliceProvider extends SliceProvider implements
        return true;
    }

    @VisibleForTesting
    protected void inject() {
        SystemUIFactory.getInstance().getRootComponent().inject(this);
        mMediaWakeLock = new SettableWakeLock(WakeLock.createPartial(getContext(), "media"),
                "media");
    }

    @VisibleForTesting
    protected void onDestroy() {
        synchronized (KeyguardSliceProvider.sInstanceLock) {
+55 −8
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class NotificationLockscreenUserManagerImpl implements

    private final DeviceProvisionedController mDeviceProvisionedController;
    private final KeyguardStateController mKeyguardStateController;
    private final Object mLock = new Object();

    // Lazy
    private NotificationEntryManager mEntryManager;
@@ -181,6 +182,7 @@ public class NotificationLockscreenUserManagerImpl implements
    protected final Context mContext;
    private final Handler mMainHandler;
    protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>();
    protected final ArrayList<UserInfo> mCurrentManagedProfiles = new ArrayList<>();

    protected int mCurrentUserId = 0;
    protected NotificationPresenter mPresenter;
@@ -300,7 +302,7 @@ public class NotificationLockscreenUserManagerImpl implements
    }

    public boolean isCurrentProfile(int userId) {
        synchronized (mCurrentProfiles) {
        synchronized (mLock) {
            return userId == UserHandle.USER_ALL || mCurrentProfiles.get(userId) != null;
        }
    }
@@ -417,6 +419,20 @@ public class NotificationLockscreenUserManagerImpl implements
        return mUsersAllowingPrivateNotifications.get(userHandle);
    }

    /**
     * If all managed profiles (work profiles) can show private data in public (secure & locked.)
     */
    public boolean allowsManagedPrivateNotificationsInPublic() {
        synchronized (mLock) {
            for (UserInfo profile : mCurrentManagedProfiles) {
                if (!userAllowsPrivateNotificationsInPublic(profile.id)) {
                    return false;
                }
            }
        }
        return true;
    }

    private boolean adminAllowsKeyguardFeature(int userHandle, int feature) {
        if (userHandle == UserHandle.USER_ALL) {
            return true;
@@ -495,11 +511,15 @@ public class NotificationLockscreenUserManagerImpl implements
    }

    private void updateCurrentProfilesCache() {
        synchronized (mCurrentProfiles) {
        synchronized (mLock) {
            mCurrentProfiles.clear();
            mCurrentManagedProfiles.clear();
            if (mUserManager != null) {
                for (UserInfo user : mUserManager.getProfiles(mCurrentUserId)) {
                    mCurrentProfiles.put(user.id, user);
                    if (UserManager.USER_TYPE_PROFILE_MANAGED.equals(user.userType)) {
                        mCurrentManagedProfiles.add(user);
                    }
                }
            }
        }
@@ -510,12 +530,31 @@ public class NotificationLockscreenUserManagerImpl implements
        });
    }

    /**
     * If any of the profiles are in public mode.
     */
    public boolean isAnyProfilePublicMode() {
        synchronized (mLock) {
            for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) {
                if (isLockscreenPublicMode(mCurrentProfiles.valueAt(i).id)) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * If any managed/work profiles are in public mode.
     */
    public boolean isAnyManagedProfilePublicMode() {
        synchronized (mLock) {
            for (int i = mCurrentManagedProfiles.size() - 1; i >= 0; i--) {
                if (isLockscreenPublicMode(mCurrentManagedProfiles.get(i).id)) {
                    return true;
                }
            }
        }
        return false;
    }

@@ -620,10 +659,18 @@ public class NotificationLockscreenUserManagerImpl implements
        pw.print("  mAllowLockscreenRemoteInput=");
        pw.println(mAllowLockscreenRemoteInput);
        pw.print("  mCurrentProfiles=");
        synchronized (mLock) {
            for (int i = mCurrentProfiles.size() - 1; i >= 0; i--) {
                final int userId = mCurrentProfiles.valueAt(i).id;
                pw.print("" + userId + " ");
            }
        }
        pw.print("  mCurrentManagedProfiles=");
        synchronized (mLock) {
            for (UserInfo userInfo : mCurrentManagedProfiles) {
                pw.print("" + userInfo.id + " ");
            }
        }
        pw.println();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class KeyguardBypassController : Dumpable {
open class KeyguardBypassController : Dumpable {

    private val mKeyguardStateController: KeyguardStateController
    private val statusBarStateController: StatusBarStateController
+0 −8
Original line number Diff line number Diff line
@@ -144,7 +144,6 @@ import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.fragments.ExtensionFragmentListener;
import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.KeyguardSliceProvider;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -794,13 +793,6 @@ public class StatusBar extends SystemUI implements DemoMode,
        mBypassHeadsUpNotifier.setUp(mEntryManager);
        mBubbleController.setExpandListener(mBubbleExpandListener);
        mActivityIntentHelper = new ActivityIntentHelper(mContext);
        KeyguardSliceProvider sliceProvider = KeyguardSliceProvider.getAttachedInstance();
        if (sliceProvider != null) {
            sliceProvider.initDependencies(mMediaManager, mStatusBarStateController,
                    mKeyguardBypassController, mDozeParameters);
        } else {
            Log.w(TAG, "Cannot init KeyguardSliceProvider dependencies");
        }

        mColorExtractor.addOnColorsChangedListener(this);
        mStatusBarStateController.addCallback(this,
Loading