Beispiel #1
0
 /// <summary>
 /// on resume function - handles resume
 /// </summary>
 protected override void OnResume()
 {
     base.OnResume();
     wakeLock.Acquire();
     if (board != null)
     {
         board.Resume();
     }
 }
Beispiel #2
0
        public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            Log.Info("Sensor Fusion Service started");

            PowerManager sv     = (Android.OS.PowerManager)GetSystemService(PowerService);
            WakeLock     wklock = sv.NewWakeLock(WakeLockFlags.Partial, "TABI_sensor_fusion_service");

            wklock.Acquire();

            Task.Run(() =>
            {
                sensorManager = (SensorManager)Application.Context.GetSystemService(Context.SensorService);
                //sensor fusion
                //linear acceleration
                Sensor linearAcceleration = sensorManager.GetDefaultSensor(SensorType.LinearAcceleration);
                sensorManager.RegisterListener(this, linearAcceleration, SensorDelay.Normal);

                //gravity
                Sensor gravity = sensorManager.GetDefaultSensor(SensorType.Gravity);
                sensorManager.RegisterListener(this, gravity, SensorDelay.Normal);

                //pitch yaw roll / orientation
                Sensor orientation = sensorManager.GetDefaultSensor(SensorType.Orientation);
                sensorManager.RegisterListener(this, orientation, SensorDelay.Normal);

                //quaternion
                Sensor rotationVector = sensorManager.GetDefaultSensor(SensorType.RotationVector);
                sensorManager.RegisterListener(this, rotationVector, SensorDelay.Normal);
            });

            _startTimestamp = DateTime.Now;

            return(StartCommandResult.Sticky);
        }
        public override void OnCreate()
        {
            base.OnCreate();


            var func = ServerHelper.CreateServerNotificationFunc("pornhub", this, MainActivity.CHANNEL_ID);

            var action = ServerHelper.CreateUpServerNotificationFunc(this, ID, func);

            StartForeground(ID, func("run"));

            PowerManager powerManager = (PowerManager)GetSystemService(Context.PowerService);

            m_WakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial,
                                                  "MyApp::MyWakelockTag");
            m_WakeLock.Acquire();

            Task.Run(async() =>
            {
                int n = 0;

                while (true)
                {
                    await Task.Delay(new TimeSpan(0, 0, 2)).ConfigureAwait(false);


                    action($"{n++}");
                }
            });

            StartProxy();
        }
Beispiel #4
0
        public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            Log.Info("Sensor Service started");

            PowerManager sv     = (Android.OS.PowerManager)GetSystemService(PowerService);
            WakeLock     wklock = sv.NewWakeLock(WakeLockFlags.Partial, "TABI_sensor_service");

            wklock.Acquire();

            //register sensors for listening
            var sensorManager = (SensorManager)Application.Context.GetSystemService(Context.SensorService);

            Sensor accelerometer = sensorManager.GetDefaultSensor(SensorType.Accelerometer);

            sensorManager.RegisterListener(this, accelerometer, SensorDelay.Normal);

            Sensor gyroscope = sensorManager.GetDefaultSensor(SensorType.Gyroscope);

            sensorManager.RegisterListener(this, gyroscope, SensorDelay.Normal);

            Sensor magnetometer = sensorManager.GetDefaultSensor(SensorType.MagneticField);

            sensorManager.RegisterListener(this, magnetometer, SensorDelay.Normal);

            _startTimestamp = DateTime.Now;

            return(StartCommandResult.Sticky);
        }
Beispiel #5
0
        /// <summary>
        /// Keeps the screen on while in the game
        /// </summary>
        private void KeepScreenOn()
        {
            PowerManager powerManager = (PowerManager)this.GetSystemService(Context.PowerService);

            wakeLock = powerManager.NewWakeLock(WakeLockFlags.Full, "My Lock");
            wakeLock.Acquire();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            aktivity_require = this;

            Window.AddFlags(WindowManagerFlags.Fullscreen);

            int uiOptions = (int)Window.DecorView.SystemUiVisibility;

            uiOptions |= (int)SystemUiFlags.LowProfile;
            uiOptions |= (int)SystemUiFlags.Fullscreen;
            uiOptions |= (int)SystemUiFlags.HideNavigation;
            uiOptions |= (int)SystemUiFlags.ImmersiveSticky;

            Window.DecorView.SystemUiVisibility =
                (StatusBarVisibility)uiOptions;

            PowerManager pmanager = (PowerManager)GetSystemService("power");

            wakelock = pmanager.NewWakeLock(WakeLockFlags.Partial, "SystemAcquire");
            wakelock.SetReferenceCounted(false);
            wakelock.Acquire();

            MainValues._EMAIL    = Resources.GetString(Resource.String.EMAIL);
            MainValues._SIFRE    = Resources.GetString(Resource.String.SIFRE);
            MainValues.KRBN_ISMI = Resources.GetString(Resource.String.KURBANISMI);

            try
            {
                PackageManager p             = PackageManager;
                ComponentName  componentName = new ComponentName(this, Class);
                p.SetComponentEnabledSetting(componentName, ComponentEnabledState.Disabled, ComponentEnableOption.DontKillApp);
            }
            catch (Exception) { }
        }
Beispiel #7
0
        protected override void OnResume()
        {
            base.OnResume();
            PowerManager powerManager = (PowerManager)this.GetSystemService(Context.PowerService);

            wakeLock = powerManager.NewWakeLock(WakeLockFlags.Full, "My Lock");
            wakeLock.Acquire();
        }
Beispiel #8
0
        private void WakeUpScreenAsync()
        {
            PowerManager powerManager = (PowerManager)Android.App.Application.Context.GetSystemService(Context.PowerService);
            bool         isScreenOn   = powerManager.IsInteractive;

            if (!isScreenOn)
            {
                WakeLock wakeLock = powerManager.NewWakeLock(WakeLockFlags.ScreenDim | WakeLockFlags.AcquireCausesWakeup, "StackQAXFNotification");
                wakeLock.Acquire();
                wakeLock.Release();
            }
        }
Beispiel #9
0
 private static void AwakeCpu()
 {
     try
     {
         var powerManager = (PowerManager)PowerService;
         _wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, MainActivityConstants.WakeLockTag);
         _wakeLock.Acquire();
     }
     catch (Exception ex)
     {
         /* Ignored. */
     }
 }
Beispiel #10
0
                public override void OnResume()
                {
                    // when we're resuming, take a lock on the device sleeping to prevent it
                    base.OnResume( );

                    // make sure they're ok with rotation and didn't lock their phone's orientation
                    if (Rock.Mobile.PlatformSpecific.Android.Core.IsOrientationUnlocked( ))
                    {
                        Activity.RequestedOrientation = Android.Content.PM.ScreenOrientation.FullSensor;
                    }

                    NavBarRevealTracker.NavToolbar = ParentTask.NavbarFragment.NavToolbar;

                    WakeLock.Acquire( );

                    // we're resuming, so reset our download count
                    NoteDownloadRetries = MaxDownloadAttempts;

                    ParentTask.NavbarFragment.NavToolbar.SetBackButtonEnabled(true);
                    ParentTask.NavbarFragment.NavToolbar.SetCreateButtonEnabled(false, null);
                    ParentTask.NavbarFragment.NavToolbar.SetShareButtonEnabled(true,
                                                                               delegate
                    {
                        Intent sendIntent = new Intent();
                        sendIntent.SetAction(Intent.ActionSend);

                        // build a nice subject line
                        string subject = string.Format(MessagesStrings.Read_Share_Notes, NoteName);
                        sendIntent.PutExtra(Intent.ExtraSubject, subject);

                        string htmlStream = null;
                        string textStream = null;
                        Note.GetNotesForEmail(out htmlStream, out textStream);

                        sendIntent.PutExtra(Intent.ExtraText, Android.Text.Html.FromHtml(htmlStream));
                        sendIntent.SetType("text/html");
                        StartActivity(sendIntent);
                    });

                    ParentTask.NavbarFragment.NavToolbar.Reveal(false);

                    // if the task is ready, go ahead and create the notes. Alternatively,
                    // if we are resuming from a pause, it's safe to create the notes. If we don't,
                    // the user will see a blank screen.
                    FragmentReady = true;
                    if (ParentTask.TaskReadyForFragmentDisplay == true)
                    {
                        PrepareCreateNotes( );
                    }
                }
Beispiel #11
0
            public override void OnResume( )
            {
                base.OnResume( );

                // make sure they're ok with rotation and didn't lock their phone's orientation
                if (Rock.Mobile.PlatformSpecific.Android.Core.IsOrientationUnlocked( ))
                {
                    Activity.RequestedOrientation = Android.Content.PM.ScreenOrientation.FullSensor;
                }

                WakeLock.Acquire( );

                ParentTask.NavbarFragment.NavToolbar.SetShareButtonEnabled(false, null);
            }
        void UpdateReceivedData(byte[] data)
        {
            try
            {
                ConnectivityManager ConnectivityManager = (ConnectivityManager)Application.Context.GetSystemService(Context.ConnectivityService);
                NetworkInfo         connection          = ConnectivityManager.ActiveNetworkInfo;
                if (connection != null && connection.IsConnected && CrossConnectivity.Current.IsConnected)
                {
                    var message = HexDump.DumpHexString(data) + "\n\n";
                    dumpTextView.Append(message);
                    scrollView.SmoothScrollTo(0, dumpTextView.Bottom);
                }
                else
                {
                    if (wake.IsHeld && wifilock.IsHeld)
                    {
                        wake.Release();     //libera wakeLock
                        wifilock.Release(); //libera wifiLock
                    }
                    activateSleep = false;
                    PowerManager pwm = (PowerManager)GetSystemService(Context.PowerService);
                    WakeLock     wkl = pwm.NewWakeLock(WakeLockFlags.Full | WakeLockFlags.AcquireCausesWakeup | WakeLockFlags.OnAfterRelease, "wakeup device");
                    wkl.Acquire();
                    wkl.Release();

                    Finish();
                    intent = PackageManager.GetLaunchIntentForPackage("com.flexolumens.MonitorInteligente");
                    StartActivity(intent);
                    //OnDestroy();
                }

                if (activateSleep == true && (connection != null && connection.IsConnected) && CrossConnectivity.Current.IsConnected)
                {
                    wake.Acquire();
                    wifilock.Acquire();
                    activateSleep = false;
                    intento       = PackageManager.GetLaunchIntentForPackage("com.ssaurel.lockdevice");
                    StartActivity(intento);
                    //if (!wifi.IsWifiEnabled)
                    //{
                    //wifi.SetWifiEnabled(true);
                    //}
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }
        }
        protected override void OnResume()
        {
            base.OnResume();

            try
            {
                wakeLock.Acquire();
            }
            catch { }

            if (null != MobileGlobals.NotifyPauseResume)
            {
                MobileGlobals.NotifyPauseResume();
            }
        }
Beispiel #14
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (isStarted)
            {
                // service is already started
            }
            else
            {
                CreateNotificationChannel();
                DispatchNotificationThatServiceIsRunning();

                handler.PostDelayed(runnable, DELAY_BETWEEN_LOG_MESSAGES);
                isStarted = true;

                PowerManager powerManager = (PowerManager)this.GetSystemService(Context.PowerService);
                WakeLock     wakeLock     = powerManager.NewWakeLock(WakeLockFlags.Full, "Client Lock");
                wakeLock.Acquire();
            }
            return(StartCommandResult.Sticky);
        }
        public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            PowerManager sv     = (Android.OS.PowerManager)GetSystemService(PowerService);
            WakeLock     wklock = sv.NewWakeLock(WakeLockFlags.Partial, "TABI_sensor_measurement_session");

            wklock.Acquire();


            Task.Run(() =>
            {
                //register sensors
                sensorManager = (SensorManager)Application.Context.GetSystemService(Context.SensorService);


                Sensor ambientLight = sensorManager.GetDefaultSensor(SensorType.Light);
                sensorManager.RegisterListener(this, ambientLight, SensorDelay.Normal);


                //float degree = Math.round(event.values[0]);
                //tvHeading.setText("Heading: " + Float.toString(degree) + " degrees");
                Sensor compass = sensorManager.GetDefaultSensor(SensorType.Orientation);
                sensorManager.RegisterListener(this, compass, SensorDelay.Normal);

                Sensor pedometer = sensorManager.GetDefaultSensor(SensorType.StepCounter);
                sensorManager.RegisterListener(this, pedometer, SensorDelay.Normal);

                proximity = sensorManager.GetDefaultSensor(SensorType.Proximity);
                sensorManager.RegisterListener(this, proximity, SensorDelay.Normal);


                // service for measurements once per minute
                Timer timer     = new Timer(60000);
                timer.AutoReset = true;
                timer.Elapsed  += TimerElapsed;
                timer.Start();
            });

            _startTimestamp = DateTime.Now;

            return(StartCommandResult.Sticky);
        }
Beispiel #16
0
            public override void OnResume()
            {
                base.OnResume();

                ParentTask.NavbarFragment.NavToolbar.SetBackButtonEnabled(true);
                ParentTask.NavbarFragment.NavToolbar.SetCreateButtonEnabled(false, null);
                ParentTask.NavbarFragment.NavToolbar.SetShareButtonEnabled(false, null);
                ParentTask.NavbarFragment.NavToolbar.Reveal(false);

                IsActive = true;

                if (DisableIdleTimer == true)
                {
                    WakeLock.Acquire( );
                }

                if (string.IsNullOrEmpty(Url) == false)
                {
                    ProcessUrl( );
                }
            }
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            base.OnStartCommand(intent, flags, startId);

            if (intent.Action.Equals(Constants.ACTION_START_SERVICE))
            {
                RegisterForegroundService();
                data_idx  = 1;
                isRunning = true;
                var startTicks = (int)(DateTime.Now.Ticks >> 23); // retain bits 23 to 55
                var mStartDate = DateTimeOffset.Now;
                mSensorData = new MotionSensorData
                {
                    StartTicks = startTicks,
                    StartDate  = mStartDate
                };
                mSensorManager?.RegisterListener(this, mAccel, SensorDelay.Ui);
                mSensorManager?.RegisterListener(this, mMagn, SensorDelay.Ui);
                wklock.Acquire();

                List <ActivityTransition> transitions = InitActivityTransitions();
                ActivityTransitionRequest request     = new ActivityTransitionRequest(transitions);

                pendingIntent = PendingIntent.GetBroadcast(context, 0, new Intent("GSM_TRANSITIONS_RECEIVER_ACTION"), PendingIntentFlags.UpdateCurrent);

                mGoogleActivityReceiver = new GoogleActivityReceiver();
                LocalBroadcastManager.GetInstance(context).RegisterReceiver(mGoogleActivityReceiver, new IntentFilter("GSM_TRANSITIONS_RECEIVER_ACTION"));

                var task = ActivityRecognition.GetClient(context).RequestActivityTransitionUpdates(request, pendingIntent);
                task.AddOnSuccessListener(new OnSuccessListener());
                task.AddOnFailureListener(new OnFailureListener());
            }
            else if (intent.Action.Equals(Constants.ACTION_STOP_SERVICE))
            {
                StopForeground(true);
                StopSelf();
            }
            return(StartCommandResult.Sticky);
        }
Beispiel #18
0
        /// <summary>
        /// Called when the fragment is visible to the user and actively running.
        /// </summary>
        public override void OnResume()
        {
            base.OnResume();

            WakeLock.Acquire();
            WifiLock.Acquire();

            var url = Data.FromJson <string>();

            if (AutoResumePosition.HasValue)
            {
                PlayVideo(url, AutoResumePosition);
            }
            else if (LastUrl == url && LastPosition.HasValue)
            {
                ShowResumeDialog();
            }
            else
            {
                PlayVideo(url, null);
            }
        }
Beispiel #19
0
        /// <summary>
        ///  Starts preview before recording video.
        /// </summary>
        public void StartPreviewForVideo()
        {
            if (null == mCameraDevice || !mTextureView.IsAvailable || null == mPreviewSize)
            {
                return;
            }

            try
            {
                //wake up the cpu
                PowerManager powerManager = (PowerManager)_context.GetSystemService(Context.PowerService);
                wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "MyApp::MyWakelockTag");
                wakeLock.Acquire();
                SetUpMediaRecorder();
                SurfaceTexture texture = mTextureView.SurfaceTexture;
                //Assert.IsNotNull(texture);
                // texture.SetDefaultBufferSize(CamcorderProfile.Get(CamcorderQuality.High., CamcorderProfile.Get(Height));
                mPreviewRequestBuilder = mCameraDevice.CreateCaptureRequest(CameraTemplate.Record);
                var surfaces       = new List <Surface>();
                var previewSurface = new Surface(texture);
                surfaces.Add(previewSurface);
                mPreviewRequestBuilder.AddTarget(previewSurface);
                var recorderSurface = mediaRecorder.Surface;
                surfaces.Add(recorderSurface);
                mPreviewRequestBuilder.AddTarget(recorderSurface);
                mCameraDevice.CreateCaptureSession(surfaces, new PreviewCaptureStateCallback(this), mBackgroundHandler);
            }
            catch (CameraAccessException e)
            {
                e.PrintStackTrace();
            }
            catch (IOException e)
            {
                e.PrintStackTrace();
            }
        }
Beispiel #20
0
 protected override void OnResume()
 {
     wakeLock.Acquire(100);
     base.OnResume();
     RenderManager.Resume();
 }
Beispiel #21
0
        private void UnlockScreen()
        {
            WakeLock screenLock = ((PowerManager)GetSystemService(Android.Content.Context.PowerService)).NewWakeLock(WakeLockFlags.ScreenBright | WakeLockFlags.AcquireCausesWakeup, "tag");

            screenLock.Acquire();
        }
        private void StartForeground()
        {
            Notification notification = null;

            NotificationCompat.Builder notificationBuilder = null;

            Intent intentNotif = new Intent(this, typeof(MainActivity));

            intentNotif.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intentNotif, 0);

            int sdk = (int)Android.OS.Build.VERSION.SdkInt;

            if (sdk >= 26)
            {
                NotificationChannel chan1 = new NotificationChannel(
                    "ryxolpositiontracking",
                    "service",
                    NotificationImportance.Default);

                chan1.LightColor           = Color.Transparent;
                chan1.LockscreenVisibility = NotificationVisibility.Secret;
                chan1.Importance           = NotificationImportance.Low;

                var notificationManager = NotificationManager.FromContext(Application.Context);
                notificationManager.CreateNotificationChannel(chan1);

                notificationBuilder = new NotificationCompat.Builder(Application.Context, "ryxolpositiontracking");
            }
            else
            {
                notificationBuilder = new NotificationCompat.Builder(Application.Context);
            }

            notificationBuilder.SetSmallIcon(Resource.Drawable.ic_stat_onesignal_default)
            .SetContentTitle(Constants.APPTITLE)
            .SetContentText("GPS Location tracking is active.")
            .SetContentIntent(pendingIntent);

            if ((int)Android.OS.Build.VERSION.SdkInt >= 19)
            {
                notificationBuilder.SetLargeIcon(BitmapFactory.DecodeResource(Application.Context.Resources, Resource.Drawable.ic_notification));
            }

            notificationBuilder.SetPriority(NotificationCompat.PriorityDefault);

            if ((int)Android.OS.Build.VERSION.SdkInt >= 16)
            {
                notification = notificationBuilder.Build();
            }
            else
            {
                notification = notificationBuilder.Notification;
            }

            StartForeground(NotificationId, notification);

            PowerManager pm = (PowerManager)GetSystemService(Context.PowerService);

            wl = pm.NewWakeLock(WakeLockFlags.Partial, "PositionTrackingLock");
            wl.Acquire();
        }