You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2026/07/17 10:32:36 UTC

(cordova-plugin-device-motion) branch master updated: feat!: drop windows platform support (#96)

This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-device-motion.git


The following commit(s) were added to refs/heads/master by this push:
     new 68bb7d4  feat!: drop windows platform support (#96)
68bb7d4 is described below

commit 68bb7d45540bce0ca4359aef18f5b971ee487172
Author: Norman Breau <no...@breautek.com>
AuthorDate: Fri Jul 17 07:32:31 2026 -0300

    feat!: drop windows platform support (#96)
---
 README.md                         |  3 +-
 package.json                      |  2 --
 plugin.xml                        |  7 ----
 src/windows/AccelerometerProxy.js | 74 ---------------------------------------
 tests/tests.js                    | 42 ----------------------
 www/accelerometer.js              | 17 ---------
 6 files changed, 1 insertion(+), 144 deletions(-)

diff --git a/README.md b/README.md
index 7844d09..21b912a 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ description: Access accelerometer data.
 
 # Usage Notice
 
-With the [W3C Device Orientation API](https://www.w3.org/TR/orientation-event/), Android, iOS, and Windows devices may not need this plugin anymore.
+With the [W3C Device Orientation API](https://www.w3.org/TR/orientation-event/), Android and iOS devices may not need this plugin anymore.
 
 However, on iOS 13+, potential issues with permissions and secure contexts can arise. Therefore it is recommended to use this plugin as it uses a native implementation.
 
@@ -61,7 +61,6 @@ Report issues with this plugin on the [Apache Cordova issue tracker](https://iss
 - Android
 - Browser
 - iOS
-- Windows
 
 ## Methods
 
diff --git a/package.json b/package.json
index 9e8dfc8..20d556d 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,6 @@
     "platforms": [
       "android",
       "ios",
-      "windows",
       "browser"
     ]
   },
@@ -21,7 +20,6 @@
     "ecosystem:cordova",
     "cordova-android",
     "cordova-ios",
-    "cordova-windows",
     "cordova-browser"
   ],
   "scripts": {
diff --git a/plugin.xml b/plugin.xml
index 6f57f1e..d33e5ff 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -63,13 +63,6 @@
         <framework src="CoreMotion.framework" />
     </platform>
 
-    <!-- windows -->
-    <platform name="windows">
-        <js-module src="src/windows/AccelerometerProxy.js" name="AccelerometerProxy">
-            <runs />
-        </js-module>
-    </platform>
-
     <!-- browser -->
     <platform name="browser">
         <js-module src="src/browser/AccelerometerProxy.js" name="AccelerometerProxy">
diff --git a/src/windows/AccelerometerProxy.js b/src/windows/AccelerometerProxy.js
deleted file mode 100644
index c98d64d..0000000
--- a/src/windows/AccelerometerProxy.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/* global Windows */
-
-var Acceleration = require('cordova-plugin-device-motion.Acceleration');
-
-/* This is the actual implementation part that returns the result on Windows 8
- */
-var gConstant = -9.81;
-
-module.exports = {
-    onDataChanged: null,
-    start: function (win, lose) {
-        var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
-        if (!accel) {
-            if (lose) {
-                lose('No accelerometer found');
-            }
-        } else {
-            accel.reportInterval = Math.max(16, accel.minimumReportInterval);
-
-            // store our bound function
-            this.onDataChanged = function (e) {
-                var a = e.reading;
-                win(new Acceleration(a.accelerationX * gConstant, a.accelerationY * gConstant, a.accelerationZ * gConstant), {
-                    keepCallback: true
-                });
-            };
-            accel.addEventListener('readingchanged', this.onDataChanged);
-
-            setTimeout(function () {
-                var a = accel.getCurrentReading();
-                win(new Acceleration(a.accelerationX * gConstant, a.accelerationY * gConstant, a.accelerationZ * gConstant), {
-                    keepCallback: true
-                });
-            }, 0); // async do later
-        }
-    },
-    stop: function (win, lose) {
-        win = win || function () {};
-        var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
-        if (!accel) {
-            if (lose) {
-                lose('No accelerometer found');
-            }
-        } else {
-            accel.removeEventListener('readingchanged', this.onDataChanged);
-            this.onDataChanged = null;
-            accel.reportInterval = 0; // back to the default
-            win();
-        }
-    }
-};
-
-require('cordova/exec/proxy').add('Accelerometer', module.exports);
diff --git a/tests/tests.js b/tests/tests.js
index d67a0b2..a4e16d4 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,15 +19,7 @@
  *
  */
 
-/* global cordova, Windows */
-
 exports.defineAutoTests = function () {
-    const isWindows = cordova.platformId === 'windows';
-    // Checking existence of accelerometer for windows platform
-    // Assumed that accelerometer always exists on other platforms. Extend
-    // condition to support accelerometer check on other platforms
-    let isAccelExist = isWindows ? Windows.Devices.Sensors.Accelerometer.getDefault() !== null : true;
-
     describe('Accelerometer (navigator.accelerometer)', function () {
         const fail = function (done) {
             expect(true).toBe(false);
@@ -53,10 +45,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.3 success callback should be called with an Acceleration object', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
                 const win = function (a) {
                     expect(a).toBeDefined();
                     expect(a.x).toBeDefined();
@@ -73,7 +61,6 @@ exports.defineAutoTests = function () {
                 const onError = function (err) {
                     console.log(err);
                     console.log('Skipping gyroscope tests, marking all as pending.');
-                    isAccelExist = false;
                     expect(true).toBe(true);
                     done();
                 };
@@ -82,10 +69,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.4 success callback Acceleration object should have (reasonable) values for x, y and z expressed in m/s^2', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
                 const reasonableThreshold = 15;
                 const win = function (a) {
                     expect(a.x).toBeLessThan(reasonableThreshold);
@@ -101,10 +84,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.5 success callback Acceleration object should return a recent timestamp', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
                 const veryRecently = new Date().getTime();
                 // Need to check that dates returned are not vastly greater than a recent time stamp.
                 // In case the timestamps returned are ridiculously high
@@ -137,10 +116,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.7 success callback should be called with an Acceleration object', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
                 const win = function (a) {
                     expect(a).toBeDefined();
                     expect(a.x).toBeDefined();
@@ -158,10 +133,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.8 success callback Acceleration object should have (reasonable) values for x, y and z expressed in m/s^2', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
                 const reasonableThreshold = 15;
                 const win = function (a) {
                     expect(a.x).toBeLessThan(reasonableThreshold);
@@ -177,10 +148,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.9 success callback Acceleration object should return a recent timestamp', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
                 const veryRecently = new Date().getTime();
                 // Need to check that dates returned are not vastly greater than a recent time stamp.
                 // In case the timestamps returned are ridiculously high
@@ -195,10 +162,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.12 success callback should be preserved and called several times', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
                 let callbacksCallCount = 0;
                 const callbacksCallTestCount = 3;
 
@@ -221,11 +184,6 @@ exports.defineAutoTests = function () {
             });
 
             it('accelerometer.spec.11 should clear an existing watch', function (done) {
-                // skip the test if Accelerometer doesn't exist on this device
-                if (!isAccelExist) {
-                    pending();
-                }
-
                 // expect win to get called exactly once
                 let win = function (a) {
                     // clear watch on first call
diff --git a/www/accelerometer.js b/www/accelerometer.js
index 93297f1..94f77b7 100644
--- a/www/accelerometer.js
+++ b/www/accelerometer.js
@@ -102,23 +102,6 @@ var accelerometer = {
     getCurrentAcceleration: function (successCallback, errorCallback, options) {
         argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
 
-        if (cordova.platformId === 'windowsphone') {
-            exec(
-                function (a) {
-                    accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
-                    successCallback(accel);
-                },
-                function (e) {
-                    errorCallback(e);
-                },
-                'Accelerometer',
-                'getCurrentAcceleration',
-                []
-            );
-
-            return;
-        }
-
         if (cordova.platformId === 'browser' && !eventTimerId) {
             // fire devicemotion event once
             var devicemotionEvent = new Event('devicemotion');


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org