1*90c8c64dSAndroid Build Coastguard Worker /* 2*90c8c64dSAndroid Build Coastguard Worker * Copyright (C) 2014 The Android Open Source Project 3*90c8c64dSAndroid Build Coastguard Worker * 4*90c8c64dSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*90c8c64dSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*90c8c64dSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*90c8c64dSAndroid Build Coastguard Worker * 8*90c8c64dSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*90c8c64dSAndroid Build Coastguard Worker * 10*90c8c64dSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*90c8c64dSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*90c8c64dSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*90c8c64dSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*90c8c64dSAndroid Build Coastguard Worker * limitations under the License. 15*90c8c64dSAndroid Build Coastguard Worker */ 16*90c8c64dSAndroid Build Coastguard Worker 17*90c8c64dSAndroid Build Coastguard Worker package com.example.android.basicmanagedprofile; 18*90c8c64dSAndroid Build Coastguard Worker 19*90c8c64dSAndroid Build Coastguard Worker import android.app.admin.DeviceAdminReceiver; 20*90c8c64dSAndroid Build Coastguard Worker import android.content.ComponentName; 21*90c8c64dSAndroid Build Coastguard Worker import android.content.Context; 22*90c8c64dSAndroid Build Coastguard Worker import android.content.Intent; 23*90c8c64dSAndroid Build Coastguard Worker 24*90c8c64dSAndroid Build Coastguard Worker /** 25*90c8c64dSAndroid Build Coastguard Worker * Handles events related to managed profile. 26*90c8c64dSAndroid Build Coastguard Worker */ 27*90c8c64dSAndroid Build Coastguard Worker public class BasicDeviceAdminReceiver extends DeviceAdminReceiver { 28*90c8c64dSAndroid Build Coastguard Worker 29*90c8c64dSAndroid Build Coastguard Worker /** 30*90c8c64dSAndroid Build Coastguard Worker * Called on the new profile when managed profile provisioning has completed. Managed profile 31*90c8c64dSAndroid Build Coastguard Worker * provisioning is the process of setting up the device so that it has a separate profile which 32*90c8c64dSAndroid Build Coastguard Worker * is managed by the mobile device management(mdm) application that triggered the provisioning. 33*90c8c64dSAndroid Build Coastguard Worker * Note that the managed profile is not fully visible until it is enabled. 34*90c8c64dSAndroid Build Coastguard Worker */ 35*90c8c64dSAndroid Build Coastguard Worker @Override onProfileProvisioningComplete(Context context, Intent intent)36*90c8c64dSAndroid Build Coastguard Worker public void onProfileProvisioningComplete(Context context, Intent intent) { 37*90c8c64dSAndroid Build Coastguard Worker // EnableProfileActivity is launched with the newly set up profile. 38*90c8c64dSAndroid Build Coastguard Worker Intent launch = new Intent(context, EnableProfileActivity.class); 39*90c8c64dSAndroid Build Coastguard Worker launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 40*90c8c64dSAndroid Build Coastguard Worker context.startActivity(launch); 41*90c8c64dSAndroid Build Coastguard Worker } 42*90c8c64dSAndroid Build Coastguard Worker 43*90c8c64dSAndroid Build Coastguard Worker /** 44*90c8c64dSAndroid Build Coastguard Worker * Generates a {@link ComponentName} that is used throughout the app. 45*90c8c64dSAndroid Build Coastguard Worker * @return a {@link ComponentName} 46*90c8c64dSAndroid Build Coastguard Worker */ getComponentName(Context context)47*90c8c64dSAndroid Build Coastguard Worker public static ComponentName getComponentName(Context context) { 48*90c8c64dSAndroid Build Coastguard Worker return new ComponentName(context.getApplicationContext(), BasicDeviceAdminReceiver.class); 49*90c8c64dSAndroid Build Coastguard Worker } 50*90c8c64dSAndroid Build Coastguard Worker 51*90c8c64dSAndroid Build Coastguard Worker } 52