Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 15 | package com.android.systemui.statusbar.phone; |
| 16 | |
| 17 | import static com.android.systemui.statusbar.phone.StatusBar.DEBUG; |
| 18 | import static com.android.systemui.statusbar.phone.StatusBar.MULTIUSER_DEBUG; |
| 19 | |
| 20 | import android.service.notification.StatusBarNotification; |
| 21 | import android.util.Log; |
| 22 | |
| 23 | import com.android.systemui.Dependency; |
| 24 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 25 | import com.android.systemui.statusbar.notification.collection.NotificationData.KeyguardEnvironment; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 26 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
| 27 | |
Govinda Wasserman | 2e86fb6 | 2019-08-13 11:35:44 -0400 | [diff] [blame^] | 28 | import javax.inject.Inject; |
| 29 | import javax.inject.Singleton; |
| 30 | |
| 31 | @Singleton |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 32 | public 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 Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 40 | |
Govinda Wasserman | 2e86fb6 | 2019-08-13 11:35:44 -0400 | [diff] [blame^] | 41 | @Inject |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 42 | 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 | } |