1 /*
2  * Copyright (C) 2024 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 
17 package com.android.intentresolver.emptystate;
18 
19 import android.app.admin.DevicePolicyEventLogger;
20 import android.stats.devicepolicy.nano.DevicePolicyEnums;
21 
22 import androidx.annotation.NonNull;
23 import androidx.annotation.Nullable;
24 
25 public class WorkProfileOffEmptyState implements EmptyState {
26 
27     private final String mTitle;
28     private final ClickListener mOnClick;
29     private final String mMetricsCategory;
30 
WorkProfileOffEmptyState(String title, @NonNull ClickListener onClick, @NonNull String metricsCategory)31     public WorkProfileOffEmptyState(String title, @NonNull ClickListener onClick,
32             @NonNull String metricsCategory) {
33         mTitle = title;
34         mOnClick = onClick;
35         mMetricsCategory = metricsCategory;
36     }
37 
38     @Nullable
39     @Override
getTitle()40     public String getTitle() {
41         return mTitle;
42     }
43 
44     @Nullable
45     @Override
getButtonClickListener()46     public ClickListener getButtonClickListener() {
47         return mOnClick;
48     }
49 
50     @Override
onEmptyStateShown()51     public void onEmptyStateShown() {
52         DevicePolicyEventLogger
53                 .createEvent(DevicePolicyEnums.RESOLVER_EMPTY_STATE_WORK_APPS_DISABLED)
54                 .setStrings(mMetricsCategory)
55                 .write();
56     }
57 }
58