1 /* 2 * Copyright (C) 2016 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.cts.comp; 18 19 import android.app.admin.DeviceAdminReceiver; 20 import android.content.ComponentName; 21 import android.content.Context; 22 import android.content.Intent; 23 import android.util.Log; 24 25 public class AdminReceiver extends DeviceAdminReceiver { 26 private static final String TAG = "AdminReceiver"; 27 // These two apps are built with this source. 28 public static final String COMP_DPC_PACKAGE_NAME = "com.android.cts.comp"; 29 public static final String COMP_DPC_2_PACKAGE_NAME = "com.android.cts.comp2"; 30 getComponentName(Context context)31 public static ComponentName getComponentName(Context context) { 32 return new ComponentName(context, AdminReceiver.class); 33 } 34 35 @Override onProfileProvisioningComplete(Context context, Intent intent)36 public void onProfileProvisioningComplete(Context context, Intent intent) { 37 super.onProfileProvisioningComplete(context, intent); 38 Log.i(TAG, "onProfileProvisioningComplete"); 39 // Enabled profile 40 getManager(context).setProfileEnabled(getWho(context)); 41 getManager(context).setProfileName(getWho(context), "Corp owned Managed Profile"); 42 } 43 } 44