Home | History | Annotate | Download | only in devicepolicy
      1 /*
      2  * Copyright (C) 2018 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 package com.android.server.devicepolicy;
     17 
     18 import android.app.admin.DevicePolicyCache;
     19 import android.util.SparseBooleanArray;
     20 
     21 import com.android.internal.annotations.GuardedBy;
     22 
     23 /**
     24  * Implementation of {@link DevicePolicyCache}, to which {@link DevicePolicyManagerService} pushes
     25  * policies.
     26  *
     27  * TODO Move other copies of policies into this class too.
     28  */
     29 public class DevicePolicyCacheImpl extends DevicePolicyCache {
     30     /**
     31      * Lock object. For simplicity we just always use this as the lock. We could use each object
     32      * as a lock object to make it more fine-grained, but that'd make copy-paste error-prone.
     33      */
     34     private final Object mLock = new Object();
     35 
     36     @GuardedBy("mLock")
     37     private final SparseBooleanArray mScreenCaptureDisabled = new SparseBooleanArray();
     38 
     39     public void onUserRemoved(int userHandle) {
     40         synchronized (mLock) {
     41             mScreenCaptureDisabled.delete(userHandle);
     42         }
     43     }
     44 
     45     @Override
     46     public boolean getScreenCaptureDisabled(int userHandle) {
     47         synchronized (mLock) {
     48             return mScreenCaptureDisabled.get(userHandle);
     49         }
     50     }
     51 
     52     public void setScreenCaptureDisabled(int userHandle, boolean disabled) {
     53         synchronized (mLock) {
     54             mScreenCaptureDisabled.put(userHandle, disabled);
     55         }
     56     }
     57 }
     58