private Task StartUpload()
        {
#if DEBUG
            // For local testing on macOS: https://docs.microsoft.com/en-US/aspnet/core/grpc/troubleshoot?view=aspnetcore-3.0#unable-to-start-aspnet-core-grpc-app-on-macos
            // 'HTTP/2 over TLS is not supported on macOS due to missing ALPN support.'.
            AppContext.SetSwitch(
                "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif
            var bundle = PackageManager.GetApplicationInfo(PackageName, global::Android.Content.PM.PackageInfoFlags.MetaData).MetaData;
            var url    = bundle.GetString("io.sentry.symbol-collector");
            Log.Info(Tag, "Using Symbol Collector endpoint: " + url);

            return(Task.Run(async() =>
            {
                var paths = new[] { "/system/lib", "/system/lib64", "/system/" };
                var client = new Client(new Uri(url), logger: new LoggerAdapter <Client>());
                try
                {
                    await client.UploadAllPathsAsync(paths, CancellationToken.None);
                }
                catch (Exception e)
                {
                    Log.Error(Tag, Throwable.FromException(e), "Failed uploading.");
                }
            }));
        }
Example #2
0
        /// <summary>
        /// Attempt interactive authentication through the broker.
        /// </summary>
        /// <param name="platformParams"> Additional paramaters for authentication.</param>
        /// <returns>The AuthenticationResult on succes, null otherwise.</returns>
        public async Task <AuthenticationResult> SignInWithPrompt(PlatformParameters platformParams)
        {
            AuthenticationResult result = null;

            try
            {
                Log.Info(_logTagAuth, "Attempting interactive authentication");
                result = await AuthContext.AcquireTokenAsync(
                    _resourceID,
                    _clientID,
                    new Uri(_redirectURI),
                    platformParams);
            }
            catch (AdalException e)
            {
                string msg = Resource.String.err_auth + e.Message;
                Log.Error(_logTagAuth, Throwable.FromException(e), msg);
                Toast.MakeText(platformParams.CallerActivity, msg, ToastLength.Long).Show();
                return(null);
            }

            isAuthenticated = true;

            return(result);
        }
        private void InitPaymentForm()
        {
            Task.Run(async() =>
            {
                var paymentMethods    = await DemoBackend.GetPaymentMethods(amount);
                var cardPaymentMethod = paymentMethods.FirstOrDefault(x => x.Type == "scheme");
                if (cardPaymentMethod == null)
                {
                    RunOnUiThread(() => Snackbar.Make(layout, "Credit card payments not available!", Snackbar.LengthLong).Show());
                    return;
                }

                var cardConfigurationBuilder = new CardConfiguration.Builder(this, Config.PublicKey);
                cardConfigurationBuilder.SetEnvironment(Com.Adyen.Checkout.Core.Api.Environment.Europe);
                var cardConfiguration = cardConfigurationBuilder.Build();

                RunOnUiThread(() =>
                {
                    try
                    {
                        var cardComponent = CardComponent.Provider.Get(this, cardPaymentMethod, cardConfiguration) as CardComponent;

                        var cardView = new CardView(this)
                        {
                            Id = View.GenerateViewId()
                        };
                        var cardLayout = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                        cardLayout.AddRule(LayoutRules.AlignParentTop);
                        cardView.Attach(cardComponent, this);
                        layout.AddView(cardView, cardLayout);
                        textViewLoading.Visibility = ViewStates.Gone;

                        cardComponent.Observe(this, new PaymentComponentObserver
                        {
                            Changed = state =>
                            {
                                var paymentMethod = state.Data.PaymentMethod as CardPaymentMethod;

                                Android.Util.Log.Debug("ObserverImpl", $"Onchanged -- Valid: {state.IsValid}, {paymentMethod.Type}");

                                if (state.IsValid)
                                {
                                    fab.Enabled        = true;
                                    this.paymentMethod = paymentMethod;
                                }
                                else
                                {
                                    fab.Enabled = false;
                                }
                            }
                        });
                    }
                    catch (System.Exception ex)
                    {
                        Android.Util.Log.Error("MainActivity", Throwable.FromException(ex), ex.Message);
                    }
                });
            });
        }
Example #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Login);
            FindViewById <ImageButton>(Resource.Id.login_button).Click += LoginToApp;

            // Create your application here
            AppCenter.Start("4b376e42-98b2-47fd-af73-7a84453954f9");
            FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.GetInstance(this);
            FirebaseOptions   options            = new FirebaseOptions.Builder()
                                                   .SetApiKey("AIzaSyBnw6unIyRQ4XfFZNekTpU7rWumSvv5cnw")
                                                   .SetApplicationId("1:316655980255:android:05c55f9b9a1c0243")
                                                   .Build();

            if (Intent != null)
            {
                if (FirebaseDynamicLinks.Instance != null)
                {
                    try
                    {
                        Task dynamicTask = FirebaseDynamicLinks.Instance.GetDynamicLink(Intent);
                        dynamicTask?.AddOnSuccessListener(this);
                    }
                    catch (System.Exception e)
                    {
                        Crashlytics.Crashlytics.LogException(Throwable.FromException(e));
                    }
                }

                FirebaseApp firebaseApp = FirebaseApp.Instance ?? FirebaseApp.InitializeApp(ApplicationContext, options);
                Intent      intent      = Intent;

                string          dataString = intent?.DataString;
                Android.Net.Uri data       = intent?.Data;
                if (dataString != null && data != null)
                {
                    Bundle bundle = new Bundle();
                    bundle.PutString(FirebaseAnalytics.Param.ItemId, data.Scheme);
                    bundle.PutString(FirebaseAnalytics.Param.ItemName, data.Host);
                    bundle.PutString(FirebaseAnalytics.Param.ContentType, "text");
                    mFirebaseAnalytics.LogEvent(FirebaseAnalytics.Event.GenerateLead, bundle);

                    if (dataString.Contains("https://cycles.page.link/tc4X"))
                    {
                    }
                }
            }

            FindViewById <Button>(Resource.Id.goto_signup).Click += GotoSignUp;
        }
Example #5
0
        /// <summary>
        /// Build and send report for Exception
        /// </summary>
        /// <param name="th">Throwable that caused exception</param>
        public void ProcessException(Exception th)
        {
            Log.Error(Constants.LOG_TAG, "Caught a " + th.GetType().Name + " exception for " + _context.PackageName + ". Start building report.");

            var data = ReportDataFactory.BuildReportData(_context, _reportFields, _appStartDate,
                                                         _initialConfiguration, th,
                                                         _interactionMode == InteractionMode.Silent);

            Parallel.ForEach(_customReportDataProviders, s =>
            {
                try
                {
                    var cdata = s.GetReportData(_context);
                    foreach (var d in cdata)
                    {
                        data.Add(d);
                    }
                }
                catch (Exception e)
                {
                    Log.Error(Constants.LOG_TAG, Throwable.FromException(e), "Error getting custom data from " + s.GetType().Name);
                }
            });

            Log.Debug(Constants.LOG_TAG, "Start sending report");
            Parallel.ForEach(_reportSenders, s =>
            {
                try
                {
                    Log.Debug(Constants.LOG_TAG, "Start sending report by " + s.GetType().Name);
                    s.Send(data);
                    Log.Debug(Constants.LOG_TAG, "Report was successfully sent by " + s.GetType().Name);
                }
                catch (ReportSenderException e)
                {
                    Log.Error(Constants.LOG_TAG, Throwable.FromException(e), e.Message);
                }
                catch (Exception e)
                {
                    Log.Error(Constants.LOG_TAG, Throwable.FromException(e),
                              "Unhandled error when sending report with " +
                              s.GetType().FullName);
                }
            });
            Log.Debug(Constants.LOG_TAG, "Report was builded and sent");
        }
 internal static void InvokeMethod(Object @object, Method method, params Object[] args)
 {
     try
     {
         method?.Invoke(@object, args);
     }
     catch (Exception ex)
     {
         if (ex is IllegalAccessException || ex is InvocationTargetException)
         {
             Log.Debug(TAG, Throwable.FromException(ex), "Can't invoke method using reflection");
         }
         else
         {
             throw;
         }
     }
 }
Example #7
0
        private IEnumerable <IWidget> GetWidgets()
        {
            SmeedeeApp.Instance.RegisterAvailableWidgets();

            var availableWidgets = SmeedeeApp.Instance.AvailableWidgets;
            var instances        = new List <IWidget>();

            foreach (var widget in availableWidgets)
            {
                try
                {
                    logger.Log("SMEEDEE", "Instantiating widget of type: " + widget.Type.Name);
                    instances.Add(Activator.CreateInstance(widget.Type, this) as IWidget);
                }
                catch (Exception e)
                {
                    logger.Log("SMEEDEE", Throwable.FromException(e).ToString(), "Exception thrown when instatiating widget");
                }
            }
            return(instances);
        }
        /// <summary>
        /// Attempt interactive authentication through the broker.
        /// </summary>
        /// <returns>The AuthenticationResult on succes, null otherwise.</returns>
        public async Task <AuthenticationResult> SignInWithPrompt(Activity activity)
        {
            AuthenticationResult result = null;

            try
            {
                Log.Info(_logTagAuth, "Attempting interactive authentication");
                result = await PCA.AcquireTokenInteractive(_scopes)
                         .WithParentActivityOrWindow(activity)
                         .WithUseEmbeddedWebView(true)
                         .ExecuteAsync();
            }
            catch (MsalException e)
            {
                string msg = Resource.String.err_auth + e.Message;
                Log.Error(_logTagAuth, Throwable.FromException(e), msg);
                Toast.MakeText(activity, msg, ToastLength.Long).Show();
                return(null);
            }

            return(result);
        }
Example #9
0
        public void Log(ILogEvent logEvent)
        {
            LogPriority priority  = TranslateToAndroidPriority(logEvent.Level);
            Throwable   throwable = null;

            if (logEvent.Exception != null)
            {
                throwable = Throwable.FromException(logEvent.Exception);
            }

            if (Android.Util.Log.IsLoggable(Tag, priority))
            {
                if (logEvent.Level == Level.Error)
                {
                    Error(logEvent.Message, throwable);
                }
                else if (logEvent.Level == Level.Debug)
                {
                    Debug(logEvent.Message, throwable);
                }
                else if (logEvent.Level == Level.Info)
                {
                    Info(logEvent.Message, throwable);
                }
                else if (logEvent.Level == Level.Trace)
                {
                    Verbose(logEvent.Message, throwable);
                }
                else if (logEvent.Level == Level.Warn)
                {
                    Warn(logEvent.Message, throwable);
                }
                else if (logEvent.Level == Level.Fatal)
                {
                    Wtf(logEvent.Message, throwable);
                }
            }
        }
        private void EmailSignUpGo_Clicked(object sender, EventArgs e)
        {
            try
            {
                FirebaseOptions options = new FirebaseOptions.Builder()
                                          .SetApiKey("AIzaSyBnw6unIyRQ4XfFZNekTpU7rWumSvv5cnw")
                                          .SetApplicationId("1:316655980255:android:05c55f9b9a1c0243")
                                          .Build();
                FirebaseApp App = FirebaseApp.Instance ?? FirebaseApp.InitializeApp(Activity, options);

                ActionCodeSettings actionCodeSettings = ActionCodeSettings.NewBuilder()
                                                        .SetUrl("https://cycles.page.link/tc4X")
                                                        .SetHandleCodeInApp(true)
                                                        .SetAndroidPackageName(Activity.PackageName, true, null)
                                                        .Build();

                FirebaseAuth auth = FirebaseAuth.GetInstance(App);
                if (auth.CurrentUser != null)
                {
                    auth.SignOut();
                }



                var email = EmailSignUpLayout?.FindViewById <EditText>(Resource.Id.emailEditText).Text;
                auth.SendSignInLinkToEmail(email, actionCodeSettings)
                .AddOnSuccessListener(this)
                .AddOnCompleteListener(this)
                .AddOnFailureListener(this);
            }
            catch (System.Exception ex)
            {
                Log.Error(Tag, "Error occured", ex);
                Crashlytics.Crashlytics.LogException(Throwable.FromException(ex));
            }
        }
 private void AndroidEnvironmentUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
 {
     ProcessException(Throwable.FromException(e.Exception));
 }
Example #12
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            lock (this._startLocker)
            {
                if (!this._started)
                {
                    ILogger log = null;
                    try
                    {
                        MessagingCenter.Instance.Subscribe <FormsApplication, ServiceLogMessage>(
                            this,
                            nameof(ServiceLogMessage),
                            (_, logMessage) => Device.BeginInvokeOnMainThread(
                                () =>
                        {
                            if (this._logMessages.Count > c_MaxLogMessages)
                            {
                                this._logMessages.RemoveAt(0);
                            }

                            this._logMessages.Add(logMessage);
                        }));

                        var listenEndPoint  = new IPEndPoint(IPAddress.Loopback, this._settings.ListenPort);
                        var serviceProvider = this.CreateServiceProvider();

                        this._serviceScope = serviceProvider.CreateScope();
                        log = serviceProvider.GetRequiredService <ILoggerFactory>().CreateLogger(this.GetType().Name);

                        var socksServer = this._serviceScope.ServiceProvider.GetRequiredService <SocksServer>();
                        socksServer.Start();

                        var notification = new Notification.Builder(this)
                                           .SetSubText(listenEndPoint.ToString())
                                           .SetVisibility(NotificationVisibility.Secret)
                                           .SetSmallIcon(Resource.Drawable.ic_stat_socks)
                                           .SetContentIntent(
                            PendingIntent.GetActivity(
                                this,
                                0,
                                new Intent(this, typeof(MainActivity)).AddFlags(ActivityFlags.ReorderToFront),
                                PendingIntentFlags.UpdateCurrent))
                                           .SetOngoing(true)
                                           .Build();
                        this.StartForeground(1, notification);

                        this._started = true;
                        this.NotifyStatusUpdate();
                    }
                    catch (Exception ex)
                    {
                        if (log != null)
                        {
                            log.LogError(ex, "Failed to start service");
                        }
                        else
                        {
                            Log.Error(nameof(MangleSocks), Throwable.FromException(ex), "Failed to start service");
                        }

                        this.StopSelfResult(1);
                    }
                }

                return(StartCommandResult.Sticky);
            }
        }
 public void LogException(System.Exception exception)
 {
     FirebaseCrashlytics.Instance.RecordException(Throwable.FromException(exception));
 }
        public void HandleUncaughtException(bool shouldThrowFormattedException = true)
        {
            if (_handler != null)
            {
                AndroidEnvironment.UnhandledExceptionRaiser -= _handler;
            }

            _handler = (s, e) => {
                if (shouldThrowFormattedException && Thread.DefaultUncaughtExceptionHandler != null)
                {
                    Thread.DefaultUncaughtExceptionHandler.UncaughtException(Thread.CurrentThread(), Throwable.FromException(e.Exception));
                }
                else
                {
                    LogException(e.Exception);
                }
            };

            AndroidEnvironment.UnhandledExceptionRaiser += _handler;
        }
Example #15
0
        public void DontSendIfJavaProxyThrowable()
        {
            Throwable throwable = Throwable.FromException(_exception);

            Assert.IsFalse(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(throwable)));
        }
Example #16
0
        public void DontSendIfWrappedJavaProxyThrowable()
        {
            Throwable throwable = new RuntimeException(new InvocationTargetException(Throwable.FromException(_exception)));

            Assert.IsFalse(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(throwable)));
        }
Example #17
0
 public void Exception(System.Exception ex)
 {
     IO.Sentry.Sentry.Capture(Throwable.FromException(ex));
 }