1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.systemui.statusbar.policy; 18 19import java.util.ArrayList; 20 21public final class KeyguardMonitor { 22 23 private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); 24 25 private boolean mShowing; 26 private boolean mSecure; 27 28 public void addCallback(Callback callback) { 29 mCallbacks.add(callback); 30 } 31 32 public void removeCallback(Callback callback) { 33 mCallbacks.remove(callback); 34 } 35 36 public boolean isShowing() { 37 return mShowing; 38 } 39 40 public boolean isSecure() { 41 return mSecure; 42 } 43 44 public void notifyKeyguardState(boolean showing, boolean secure) { 45 if (mShowing == showing && mSecure == secure) return; 46 mShowing = showing; 47 mSecure = secure; 48 for (Callback callback : mCallbacks) { 49 callback.onKeyguardChanged(); 50 } 51 } 52 53 public interface Callback { 54 void onKeyguardChanged(); 55 } 56}