Exemple #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);
        }
Exemple #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);
            }
        }
Exemple #3
0
        /// <summary>
        /// Handle incoming profiling data.  The MPSE packet includes the
        /// complete .trace file.
        /// </summary>
        private void handleMPSE(Client client, ByteBuffer data)
        {
            ClientData.IMethodProfilingHandler handler = ClientData.methodProfilingHandler;
            if (handler != null)
            {
                var stuff = new byte[data.capacity];
                data.get(stuff, 0, stuff.Length);

                Log.d("ddm-prof", "got trace file, size: " + stuff.Length + " bytes");

                handler.onSuccess(stuff, client);
            }

            client.clientData.methodProfilingStatus = ClientData.MethodProfilingStatus.OFF;
            client.update(Client.CHANGE_METHOD_PROFILING_STATUS);
        }