Device Policy Management

Dependencies

  • Tizen 5.5 and Higher

Content

Related Info

The Device Policy Management (DPM) framework supports enterprise applications by providing IT administrator functions to create security-aware applications. These applications are useful in scenarios where IT administrators require rich control over employee devices.

DPM framework consists of:

  • Device policy client library: This contains all the device administration functions that a client application can call. The device policy client library communicates with the device policy manager using a built-in remote method invocation (RMI) engine.
  • Device policy manager: This manages all the device policies. It also provides interfaces for the device policy client library.

The main features of the Tizen.Security.DevicePolicyManager namespace are:

The following figure illustrates the DPM framework process:

Figure: DPM framework process

DPM framework process

Prerequisites

To use the methods and properties of the Tizen.Security.DevicePolicyManager namespace, include it in your application:

using Tizen.Security.DevicePolicyManager;

Managing Device Policies

To manage device policies:

  1. Create a DevicePolicyManager instance:

        DevicePolicyManager dpm = new DevicePolicyManager();
    
  2. Get the policy instance using getPolicy<T>() of the DevicePolicyManager instance:
        MediaPolicy mediaPolicy = dpm.getPolicy<MediaPolicy>();
    
    Note The DevicePolicyManager instance must exist when you use the policy instance.
  3. Register an event handler to manage the policies of the policy instance:
    try
    {
        DevicePolicyManager dpm = new DevicePolicyManager();
        MediaPolicy mediaPolicy = dpm.getPolicy<MediaPolicy>();
    
        /// Register the event handler
        mediaPolicy.CameraPolicyChanged += onCameraPolicyChanged;
    }
    catch (Exception e)
    {
        /// Handle exception
    }
    
    /// Create the event handler
    void onCameraPolicyChanged(Object Sender, PolicyChangedEventArgs args)
    {
        Console.WriteLine("PolicyName: " + args.PolicyName + ", Current policy state: " + args.IsAllowed);
    }
    
  4. Check the device restriction state:
    /// Check the restriction state of the camera
    /// false: using the camera is not allowed
    /// true: using the camera is allowed
    bool cameraPolicyState = mediaPolicy.IsCameraAllowed;
    
  5. When no longer needed, destroy the policy instance and DPM instance:
    mediaPolicy.Dispose();
    dpm.Dispose();
    
    Note The policy instance must be destroyed before the DPM instance.