Example usage for java.lang Character MAX_VALUE

List of usage examples for java.lang Character MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Character MAX_VALUE.

Prototype

char MAX_VALUE

To view the source code for java.lang Character MAX_VALUE.

Click Source Link

Document

The constant value of this field is the largest value of type char , '\u005CuFFFF' .

Usage

From source file:org.wso2.emm.agent.services.operation.OperationManager.java

public static String getOperationResponseFromLogcat(Context context, String logcat) throws IOException {
    File logcatFile = new File(logcat);
    if (logcatFile.exists() && logcatFile.canRead()) {
        DeviceInfo deviceInfo = new DeviceInfo(context);
        EventPayload eventPayload = new EventPayload();
        eventPayload.setPayload(logcat);
        eventPayload.setType("LOGCAT");
        eventPayload.setDeviceIdentifier(deviceInfo.getDeviceId());

        StringBuilder emmBuilder = new StringBuilder();
        StringBuilder publisherBuilder = new StringBuilder();
        int index = 0;
        String line;//from w  w w . jav a 2 s.c  om
        ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(logcatFile,
                Charset.forName("US-ASCII"));
        while ((line = reversedLinesFileReader.readLine()) != null) {
            publisherBuilder.insert(0, "\n");
            publisherBuilder.insert(0, line);
            //OPERATION_RESPONSE filed in the DM_DEVICE_OPERATION_RESPONSE is declared as a blob and hence can only hold 64Kb.
            //So we don't want to throw exceptions in the server. Limiting the response in here to limit the server traffic also.
            if (emmBuilder.length() < Character.MAX_VALUE - 8192) { //Keeping 8kB for rest of the response payload.
                emmBuilder.insert(0, "\n");
                emmBuilder.insert(0, line);
            }
            if (++index >= Constants.LogPublisher.NUMBER_OF_LOG_LINES) {
                break;
            }
        }
        LogPublisherFactory publisher = new LogPublisherFactory(context);
        if (publisher.getLogPublisher() != null) {
            eventPayload.setPayload(publisherBuilder.toString());
            publisher.getLogPublisher().publish(eventPayload);
            if (Constants.DEBUG_MODE_ENABLED) {
                Log.d(TAG, "Logcat published size: " + eventPayload.getPayload().length());
            }
        }
        eventPayload.setPayload(emmBuilder.toString());
        Gson logcatResponse = new Gson();
        logcatFile.delete();
        if (Constants.DEBUG_MODE_ENABLED) {
            Log.d(TAG, "Logcat payload size: " + eventPayload.getPayload().length());
        }
        return logcatResponse.toJson(eventPayload);
    } else {
        throw new IOException("Unable to find or read log file.");
    }
}