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 17 package com.android.car.settings.qc; 18 19 import android.app.PendingIntent; 20 import android.app.admin.DevicePolicyManager; 21 import android.content.Context; 22 import android.content.Intent; 23 24 import com.android.car.settings.enterprise.ActionDisabledByAdminActivity; 25 26 /** 27 * General helper methods for quick controls. 28 */ 29 public class QCUtils { QCUtils()30 private QCUtils() { 31 } 32 33 /** 34 * See {@link #getActionDisabledDialogIntent(Context, String, int)}. 35 */ getActionDisabledDialogIntent(Context context, String restriction)36 public static PendingIntent getActionDisabledDialogIntent(Context context, String restriction) { 37 return getActionDisabledDialogIntent(context, restriction, /* requestCode= */ 0); 38 } 39 40 /** 41 * Returns a {@link PendingIntent} for launching a {@link ActionDisabledByAdminActivity} with 42 * the specified restriction and request code. 43 */ getActionDisabledDialogIntent(Context context, String restriction, int requestCode)44 public static PendingIntent getActionDisabledDialogIntent(Context context, String restriction, 45 int requestCode) { 46 Intent intent = new Intent(); 47 intent.setClass(context, ActionDisabledByAdminActivity.class); 48 intent.putExtra(DevicePolicyManager.EXTRA_RESTRICTION, restriction); 49 return PendingIntent.getActivity(context, requestCode, intent, 50 PendingIntent.FLAG_IMMUTABLE); 51 } 52 } 53