DRM to Message - Android android.drm

Android examples for android.drm:DrmEvent

Description

DRM to Message

Demo Code


//package com.java2s;
import android.drm.DrmErrorEvent;
import android.drm.DrmEvent;
import android.drm.DrmInfoEvent;

public class Main {
    public static String toMessage(DrmEvent event) {

        String name = "null";

        if (event != null) {

            int type = event.getType();
            switch (type) {
            case DrmEvent.TYPE_ALL_RIGHTS_REMOVED:
                name = "TYPE_ALL_RIGHTS_REMOVED";
                break;
            case DrmEvent.TYPE_DRM_INFO_PROCESSED:
                name = "TYPE_DRM_INFO_PROCESSED";
                break;
            default:
                name = "UNKNOWN_TYPE";
                break;
            }//from   ww w. j  a  v a 2 s  .c  o m
            name += "(" + type + "):" + event.getMessage();
        }

        return name;
    }

    public static String toMessage(DrmInfoEvent event) {
        String name = "null";

        if (event != null) {

            int type = event.getType();
            switch (type) {
            case DrmInfoEvent.TYPE_ACCOUNT_ALREADY_REGISTERED:
                name = "TYPE_ACCOUNT_ALREADY_REGISTERED";
                break;
            case DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT:
                name = "TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT";
                break;
            case DrmInfoEvent.TYPE_REMOVE_RIGHTS:
                name = "TYPE_REMOVE_RIGHTS";
                break;
            case DrmInfoEvent.TYPE_RIGHTS_INSTALLED:
                name = "TYPE_RIGHTS_INSTALLED";
                break;
            case DrmInfoEvent.TYPE_RIGHTS_REMOVED:
                name = "TYPE_RIGHTS_REMOVED";
                break;
            case DrmInfoEvent.TYPE_WAIT_FOR_RIGHTS:
                name = "TYPE_WAIT_FOR_RIGHTS";
                break;
            default:
                name = "UNKNOWN_TYPE";
                break;
            }
            name += "(" + type + "):" + event.getMessage();
        }

        return name;
    }

    public static String toMessage(DrmErrorEvent event) {
        String name = "null";

        if (event != null) {

            int type = event.getType();
            switch (type) {
            case DrmErrorEvent.TYPE_ACQUIRE_DRM_INFO_FAILED:
                name = "TYPE_ACQUIRE_DRM_INFO_FAILED";
                break;
            case DrmErrorEvent.TYPE_NOT_SUPPORTED:
                name = "TYPE_NOT_SUPPORTED";
                break;
            case DrmErrorEvent.TYPE_NO_INTERNET_CONNECTION:
                name = "TYPE_NO_INTERNET_CONNECTION";
                break;
            case DrmErrorEvent.TYPE_OUT_OF_MEMORY:
                name = "TYPE_OUT_OF_MEMORY";
                break;
            case DrmErrorEvent.TYPE_PROCESS_DRM_INFO_FAILED:
                name = "TYPE_PROCESS_DRM_INFO_FAILED";
                break;
            case DrmErrorEvent.TYPE_REMOVE_ALL_RIGHTS_FAILED:
                name = "TYPE_REMOVE_ALL_RIGHTS_FAILED";
                break;
            case DrmErrorEvent.TYPE_RIGHTS_NOT_INSTALLED:
                name = "TYPE_RIGHTS_NOT_INSTALLED";
                break;
            case DrmErrorEvent.TYPE_RIGHTS_RENEWAL_NOT_ALLOWED:
                name = "TYPE_RIGHTS_RENEWAL_NOT_ALLOWED";
                break;
            default:
                name = "UNKNOWN_TYPE";
                break;
            }
            name += "(" + type + "):" + event.getMessage();
        }

        return name;
    }
}

Related Tutorials