예제 #1
0
        /// <summary>
        /// Handle notification that method profiling has finished writing
        /// data to disk.
        /// </summary>
        private void handleMPRE(Client client, ByteBuffer data)
        {
            // get the filename and make the client not have pending HPROF dump anymore.
            string filename = client.clientData.pendingMethodProfiling;

            client.clientData.pendingMethodProfiling = null;

            byte result = data.get();

            // get the app-level handler for method tracing dump
            ClientData.IMethodProfilingHandler handler = ClientData.methodProfilingHandler;
            if (handler != null)
            {
                if (result == 0)
                {
                    handler.onSuccess(filename, client);

                    Log.d("ddm-prof", "Method profiling has finished");
                }
                else
                {
                    handler.onEndFailure(client, null);                     //message

                    Log.w("ddm-prof", "Method profiling has failed (check device log)");
                }
            }

            client.clientData.methodProfilingStatus = ClientData.MethodProfilingStatus.OFF;
            client.update(Client.CHANGE_METHOD_PROFILING_STATUS);
        }
예제 #2
0
        private void handleFAIL(Client client, ByteBuffer data)
        {
            /*int errorCode =*/ data.getInt();
            int    length  = data.getInt() * 2;
            string message = null;

            if (length > 0)
            {
                var messageBuffer = new byte[length];
                data.get(messageBuffer, 0, length);
                message = Encoding.Default.GetString(messageBuffer);
            }

            // this can be sent if
            // - MPRS failed (like wrong permission)
            // - MPSE failed for whatever reason

            string filename = client.clientData.pendingMethodProfiling;

            if (filename != null)
            {
                // reset the pending file.
                client.clientData.pendingMethodProfiling = null;

                // and notify of failure
                ClientData.IMethodProfilingHandler handler = ClientData.methodProfilingHandler;
                if (handler != null)
                {
                    handler.onStartFailure(client, message);
                }
            }
            else
            {
                // this is MPRE
                // notify of failure
                ClientData.IMethodProfilingHandler handler = ClientData.methodProfilingHandler;
                if (handler != null)
                {
                    handler.onEndFailure(client, message);
                }
            }

            // send a query to know the current status
            try
            {
                sendMPRQ(client);
            }
            catch (IOException e)
            {
                Log.e("HandleProfiling", e);
            }
        }