1 /*
2  * Copyright (C) 2014 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.example.android.apprestrictionenforcer;
18 
19 import android.app.admin.DeviceAdminReceiver;
20 import android.content.ComponentName;
21 import android.content.Context;
22 import android.content.Intent;
23 
24 /**
25  * Handles events related to managed profile.
26  */
27 public class EnforcerDeviceAdminReceiver extends DeviceAdminReceiver {
28 
29     /**
30      * Called on the new profile when managed profile provisioning has completed. Managed profile
31      * provisioning is the process of setting up the device so that it has a separate profile which
32      * is managed by the mobile device management(mdm) application that triggered the provisioning.
33      * Note that the managed profile is not fully visible until it is enabled.
34      */
35     @Override
onProfileProvisioningComplete(Context context, Intent intent)36     public void onProfileProvisioningComplete(Context context, Intent intent) {
37         // EnableProfileActivity is launched with the newly set up profile.
38         Intent launch = new Intent(context, EnableProfileActivity.class);
39         launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
40         context.startActivity(launch);
41     }
42 
43     /**
44      * Generates a {@link ComponentName} that is used throughout the app.
45      * @return a {@link ComponentName}
46      */
getComponentName(Context context)47     public static ComponentName getComponentName(Context context) {
48         return new ComponentName(context.getApplicationContext(),
49                 EnforcerDeviceAdminReceiver.class);
50     }
51 
52 }
53