1 /*
2  * Copyright (C) 2021 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.cts.devicepolicy;
17 
18 import android.app.admin.DevicePolicyManager;
19 
20 //TODO(b/174859111): move to automotive-only section
21 /**
22  * Represents an operation safety event received by a
23  * {@link android.app.admin.DeviceAdminReceiver#onOperationSafetyStateChanged(
24  * android.content.Context, int, boolean)}.
25  *
26  * <p>NOTE: doesn't implement {@code Parcelable} because it needs to cross process boundaries on
27  * automotive, which trows a {@code ClassNotFoundException} in the receiving end - it't not worth
28  * to fix that...
29  */
30 public final class OperationSafetyChangedEvent {
31 
32     public final int reason;
33     public final boolean isSafe;
34 
OperationSafetyChangedEvent(int reason, boolean isSafe)35     public OperationSafetyChangedEvent(int reason, boolean isSafe) {
36         this.reason = reason;
37         this.isSafe = isSafe;
38     }
39 
40     @Override
toString()41     public String toString() {
42         return "OperationSafetyChangedEvent["
43             + DevicePolicyManager.operationSafetyReasonToString(reason) + ": "
44             + (isSafe ? "SAFE" : "UNSAFE") + ']';
45     }
46 }
47