Ejemplo n.º 1
0
        public override void RecordCustomException(string name, string reason, string stackTraceString)
        {
            this.references.Clear();
            IntPtr num1      = AndroidJNI.FindClass("java/lang/Exception");
            IntPtr methodId1 = AndroidJNI.GetMethodID(num1, "<init>", "(Ljava/lang/String;)V");

            jvalue[] jvalueArray1 = new jvalue[1];
            jvalueArray1[0].l = (__Null)AndroidJNI.NewStringUTF(name + " : " + reason);
            IntPtr num2 = AndroidJNI.NewObject(num1, methodId1, jvalueArray1);

            this.references.Add((IntPtr)jvalueArray1[0].l);
            this.references.Add(num2);
            IntPtr num3      = AndroidJNI.FindClass("java/lang/StackTraceElement");
            IntPtr methodId2 = AndroidJNI.GetMethodID(num3, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");

            Dictionary <string, string>[] stackTraceString1 = Impl.ParseStackTraceString(stackTraceString);
            IntPtr num4 = AndroidJNI.NewObjectArray(stackTraceString1.Length, num3, IntPtr.Zero);

            this.references.Add(num4);
            for (int index = 0; index < stackTraceString1.Length; ++index)
            {
                Dictionary <string, string> dictionary = stackTraceString1[index];
                jvalue[] jvalueArray2 = new jvalue[4];
                jvalueArray2[0].l = (__Null)AndroidJNI.NewStringUTF(dictionary["class"]);
                jvalueArray2[1].l = (__Null)AndroidJNI.NewStringUTF(dictionary["method"]);
                jvalueArray2[2].l = (__Null)AndroidJNI.NewStringUTF(dictionary["file"]);
                this.references.Add((IntPtr)jvalueArray2[0].l);
                this.references.Add((IntPtr)jvalueArray2[1].l);
                this.references.Add((IntPtr)jvalueArray2[2].l);
                jvalueArray2[3].i = (__Null)int.Parse(dictionary["line"]);
                IntPtr num5 = AndroidJNI.NewObject(num3, methodId2, jvalueArray2);
                this.references.Add(num5);
                AndroidJNI.SetObjectArrayElement(num4, index, num5);
            }
            IntPtr methodId3 = AndroidJNI.GetMethodID(num1, "setStackTrace", "([Ljava/lang/StackTraceElement;)V");

            jvalue[] jvalueArray3 = new jvalue[1];
            jvalueArray3[0].l = (__Null)num4;
            AndroidJNI.CallVoidMethod(num2, methodId3, jvalueArray3);
            IntPtr num6           = AndroidJNI.FindClass("com/crashlytics/android/Crashlytics");
            IntPtr staticMethodId = AndroidJNI.GetStaticMethodID(num6, "logException", "(Ljava/lang/Throwable;)V");

            jvalue[] jvalueArray4 = new jvalue[1];
            jvalueArray4[0].l = (__Null)num2;
            AndroidJNI.CallStaticVoidMethod(num6, staticMethodId, jvalueArray4);
            using (List <IntPtr> .Enumerator enumerator = this.references.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    AndroidJNI.DeleteLocalRef(enumerator.Current);
                }
            }
        }
Ejemplo n.º 2
0
        public override void RecordCustomException(string name, string reason, string stackTraceString)
        {
            references.Clear();
            IntPtr clazz    = AndroidJNI.FindClass("java/lang/Exception");
            IntPtr methodID = AndroidJNI.GetMethodID(clazz, "<init>", "(Ljava/lang/String;)V");

            jvalue[] array = new jvalue[1];
            array[0].l = AndroidJNI.NewStringUTF(name + " : " + reason);
            IntPtr intPtr = AndroidJNI.NewObject(clazz, methodID, array);

            references.Add(array[0].l);
            references.Add(intPtr);
            IntPtr clazz2    = AndroidJNI.FindClass("java/lang/StackTraceElement");
            IntPtr methodID2 = AndroidJNI.GetMethodID(clazz2, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");

            Dictionary <string, string>[] array2 = Impl.ParseStackTraceString(stackTraceString);
            IntPtr intPtr2 = AndroidJNI.NewObjectArray(array2.Length, clazz2, IntPtr.Zero);

            references.Add(intPtr2);
            for (int i = 0; i < array2.Length; i++)
            {
                Dictionary <string, string> dictionary = array2[i];
                jvalue[] array3 = new jvalue[4];
                array3[0].l = AndroidJNI.NewStringUTF(dictionary["class"]);
                array3[1].l = AndroidJNI.NewStringUTF(dictionary["method"]);
                array3[2].l = AndroidJNI.NewStringUTF(dictionary["file"]);
                references.Add(array3[0].l);
                references.Add(array3[1].l);
                references.Add(array3[2].l);
                array3[3].i = int.Parse(dictionary["line"]);
                IntPtr intPtr3 = AndroidJNI.NewObject(clazz2, methodID2, array3);
                references.Add(intPtr3);
                AndroidJNI.SetObjectArrayElement(intPtr2, i, intPtr3);
            }
            IntPtr methodID3 = AndroidJNI.GetMethodID(clazz, "setStackTrace", "([Ljava/lang/StackTraceElement;)V");

            jvalue[] array4 = new jvalue[1];
            array4[0].l = intPtr2;
            AndroidJNI.CallVoidMethod(intPtr, methodID3, array4);
            IntPtr clazz3         = AndroidJNI.FindClass("com/crashlytics/android/Crashlytics");
            IntPtr staticMethodID = AndroidJNI.GetStaticMethodID(clazz3, "logException", "(Ljava/lang/Throwable;)V");

            jvalue[] array5 = new jvalue[1];
            array5[0].l = intPtr;
            AndroidJNI.CallStaticVoidMethod(clazz3, staticMethodID, array5);
            foreach (IntPtr reference in references)
            {
                AndroidJNI.DeleteLocalRef(reference);
            }
        }