blob: 2c931ae1c8ef7934b9703a0ce23a111181b3e379 [file] [log] [blame]
Jason Monk297c04e2018-08-23 17:16:59 -04001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15package com.android.systemui.statusbar.phone;
16
17import static com.android.systemui.statusbar.phone.StatusBar.DEBUG;
18import static com.android.systemui.statusbar.phone.StatusBar.MULTIUSER_DEBUG;
19
20import android.service.notification.StatusBarNotification;
21import android.util.Log;
22
23import com.android.systemui.Dependency;
24import com.android.systemui.statusbar.NotificationLockscreenUserManager;
Ned Burnsf81c4c42019-01-07 14:10:43 -050025import com.android.systemui.statusbar.notification.collection.NotificationData.KeyguardEnvironment;
Jason Monk297c04e2018-08-23 17:16:59 -040026import com.android.systemui.statusbar.policy.DeviceProvisionedController;
27
Govinda Wasserman3e7ce552019-08-13 11:35:44 -040028import javax.inject.Inject;
29import javax.inject.Singleton;
30
31@Singleton
Jason Monk297c04e2018-08-23 17:16:59 -040032public class KeyguardEnvironmentImpl implements KeyguardEnvironment {
33
34 private static final String TAG = "KeyguardEnvironmentImpl";
35
36 private final NotificationLockscreenUserManager mLockscreenUserManager =
37 Dependency.get(NotificationLockscreenUserManager.class);
38 private final DeviceProvisionedController mDeviceProvisionedController =
39 Dependency.get(DeviceProvisionedController.class);
Jason Monk297c04e2018-08-23 17:16:59 -040040
Govinda Wasserman3e7ce552019-08-13 11:35:44 -040041 @Inject
Jason Monk297c04e2018-08-23 17:16:59 -040042 public KeyguardEnvironmentImpl() {
43 }
44
45 @Override // NotificationData.KeyguardEnvironment
46 public boolean isDeviceProvisioned() {
47 return mDeviceProvisionedController.isDeviceProvisioned();
48 }
49
50 @Override // NotificationData.KeyguardEnvironment
51 public boolean isNotificationForCurrentProfiles(StatusBarNotification n) {
52 final int notificationUserId = n.getUserId();
53 if (DEBUG && MULTIUSER_DEBUG) {
54 Log.v(TAG, String.format("%s: current userid: %d, notification userid: %d", n,
55 mLockscreenUserManager.getCurrentUserId(), notificationUserId));
56 }
57 return mLockscreenUserManager.isCurrentProfile(notificationUserId);
58 }
59}