You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by jc...@apache.org on 2022/10/12 22:06:46 UTC

[cordova-plugin-device] 01/01: fix!: remove deprecated platforms

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

jcesarmobile pushed a commit to branch remove-platforms
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-device.git

commit baa43e060261d4a6a51977fd4b939469e0d29291
Author: Julio César <jc...@gmail.com>
AuthorDate: Thu Oct 13 00:06:31 2022 +0200

    fix!: remove deprecated platforms
---
 README.md                  |  20 -------
 package.json               |   8 +--
 plugin.xml                 |  20 -------
 src/osx/CDVDevice.h        |  28 ----------
 src/osx/CDVDevice.m        | 126 ---------------------------------------------
 src/windows/DeviceProxy.js |  94 ---------------------------------
 6 files changed, 2 insertions(+), 294 deletions(-)

diff --git a/README.md b/README.md
index 93ed8fa..ea2a2db 100644
--- a/README.md
+++ b/README.md
@@ -70,8 +70,6 @@ The `device.cordova` property will display `10.1.1`.
 - Android
 - Browser
 - iOS
-- Windows
-- OS X
 
 ## device.model
 
@@ -84,8 +82,6 @@ different across versions of the same product.
 - Android
 - Browser
 - iOS
-- Windows
-- OS X
 
 ### Quick Example
 
@@ -126,8 +122,6 @@ var string = device.platform;
 - Android
 - Browser
 - iOS
-- Windows
-- OS X
 
 ### Quick Example
 
@@ -136,8 +130,6 @@ var string = device.platform;
 //   - "Android"
 //   - "browser"
 //   - "iOS"
-//   - "WinCE"
-//   - "Mac OS X"
 //
 var devicePlatform = device.platform;
 ```
@@ -158,8 +150,6 @@ The details of how a UUID is generated are determined by the device manufacturer
 
 - Android
 - iOS
-- Windows
-- OS X
 
 ### Quick Example
 
@@ -169,9 +159,6 @@ The details of how a UUID is generated are determined by the device manufacturer
 // iOS: (Paraphrased from the UIDevice Class documentation)
 //         Returns the [UIDevice identifierForVendor] UUID which is unique and the same for all apps installed by the same vendor. However the UUID can be different if the user deletes all apps from the vendor and then reinstalls it.
 //
-// Windows Phone 7 : Returns a hash of device+current user,
-// if the user is not defined, a guid is generated and will persist until the app is uninstalled
-//
 var deviceID = device.uuid;
 ```
 
@@ -212,8 +199,6 @@ Get the operating system version.
 - Android
 - Browser
 - iOS
-- Windows
-- OS X
 
 ### Quick Example
 
@@ -226,10 +211,6 @@ Get the operating system version.
 //
 // iOS:     iOS 3.2 returns "3.2"
 //
-// Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384
-//
-// OS X:        El Capitan would return "10.11.2"
-//
 var deviceVersion = device.version;
 ```
 
@@ -243,7 +224,6 @@ Get the device's manufacturer.
 
 - Android
 - iOS
-- Windows
 
 ### Quick Example
 
diff --git a/package.json b/package.json
index 840a183..00a44f1 100644
--- a/package.json
+++ b/package.json
@@ -9,9 +9,7 @@
       "android",
       "electron",
       "ios",
-      "windows",
-      "browser",
-      "osx"
+      "browser"
     ]
   },
   "repository": "github:apache/cordova-plugin-device",
@@ -23,9 +21,7 @@
     "cordova-android",
     "cordova-electron",
     "cordova-ios",
-    "cordova-windows",
-    "cordova-browser",
-    "cordova-osx"
+    "cordova-browser"
   ],
   "scripts": {
     "test": "npm run lint",
diff --git a/plugin.xml b/plugin.xml
index 8e44b8b..0bfbf7d 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -66,13 +66,6 @@
         <framework src="src/electron" />
     </platform>
 
-    <!-- windows -->
-    <platform name="windows">
-        <js-module src="src/windows/DeviceProxy.js" name="DeviceProxy">
-            <runs />
-        </js-module>
-    </platform>
-
     <!-- browser -->
     <platform name="browser">
         <config-file target="config.xml" parent="/*">
@@ -86,17 +79,4 @@
         </js-module>
     </platform>
 
-    <!-- osx -->
-    <platform name="osx">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Device">
-                <param name="ios-package" value="Device"/>
-            </feature>
-        </config-file>
-
-        <header-file src="src/osx/CDVDevice.h" />
-        <source-file src="src/osx/CDVDevice.m" />
-    </platform>
-
-
 </plugin>
diff --git a/src/osx/CDVDevice.h b/src/osx/CDVDevice.h
deleted file mode 100644
index 46bde27..0000000
--- a/src/osx/CDVDevice.h
+++ /dev/null
@@ -1,28 +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.
- */
-
-#import <Cordova/CDVPlugin.h>
-
-@interface Device : CDVPlugin
-
-+ (NSString*) cordovaVersion;
-
-- (void) getDeviceInfo:(CDVInvokedUrlCommand*)command;
-
-@end
diff --git a/src/osx/CDVDevice.m b/src/osx/CDVDevice.m
deleted file mode 100644
index dd6f811..0000000
--- a/src/osx/CDVDevice.m
+++ /dev/null
@@ -1,126 +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.
- */
-
-#include <sys/sysctl.h>
-
-#import <Availability.h>
-
-#import "CDVDevice.h"
-
-#define SYSTEM_VERSION_PLIST    @"/System/Library/CoreServices/SystemVersion.plist"
-
-@implementation Device
-
-- (NSString*) modelVersion {
-    size_t size;
-
-    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
-    char* machine = malloc(size);
-    sysctlbyname("hw.machine", machine, &size, NULL, 0);
-    NSString* modelVersion = [NSString stringWithUTF8String:machine];
-    free(machine);
-
-    return modelVersion;
-}
-
-- (NSString*) getSerialNr {
-    NSString* serialNr;
-    io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
-    if (platformExpert) {
-        CFTypeRef serialNumberAsCFString =
-                IORegistryEntryCreateCFProperty(platformExpert,
-                        CFSTR(kIOPlatformSerialNumberKey),
-                        kCFAllocatorDefault, 0);
-        if (serialNumberAsCFString) {
-            serialNr = (__bridge NSString*) serialNumberAsCFString;
-        }
-        IOObjectRelease(platformExpert);
-    }
-    return serialNr;
-}
-
-- (NSString*) uniqueAppInstanceIdentifier {
-    NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
-    static NSString* UUID_KEY = @"CDVUUID";
-
-    NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
-
-    if (app_uuid == nil) {
-        CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
-        CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
-
-        app_uuid = [NSString stringWithString:(__bridge NSString*) uuidString];
-        [userDefaults setObject:app_uuid forKey:UUID_KEY];
-        [userDefaults synchronize];
-
-        CFRelease(uuidString);
-        CFRelease(uuidRef);
-    }
-
-    return app_uuid;
-}
-
-- (NSString*) platform {
-    return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductName"];
-}
-
-- (NSString*) systemVersion {
-    return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductVersion"];
-}
-
-- (void) getDeviceInfo:(CDVInvokedUrlCommand*) command {
-    NSDictionary* deviceProperties = [self deviceProperties];
-    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
-
-    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (NSDictionary*) deviceProperties {
-    NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
-
-    devProps[@"manufacturer"] = @"Apple";
-    devProps[@"model"] = [self modelVersion];
-    devProps[@"platform"] = [self platform];
-    devProps[@"version"] = [self systemVersion];
-    devProps[@"uuid"] = [self uniqueAppInstanceIdentifier];
-    devProps[@"cordova"] = [[self class] cordovaVersion];
-    devProps[@"serial"] = [self getSerialNr];
-    devProps[@"isVirtual"] = @NO;
-    devProps[@"isiOSAppOnMac"]: [self isiOSAppOnMac];
-
-    NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
-    return devReturn;
-}
-
-+ (NSString*) cordovaVersion {
-    return CDV_VERSION;
-}
-
-- (BOOL) isiOSAppOnMac
-{
-    #if __IPHONE_14_0
-    if (@available(iOS 14.0, *)) {
-        return [[NSProcessInfo processInfo] isiOSAppOnMac];
-    }
-    #endif
-
-    return false;
-}
-
-@end
diff --git a/src/windows/DeviceProxy.js b/src/windows/DeviceProxy.js
deleted file mode 100644
index b3d095f..0000000
--- a/src/windows/DeviceProxy.js
+++ /dev/null
@@ -1,94 +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, createUUID */
-
-var ROOT_CONTAINER = '{00000000-0000-0000-FFFF-FFFFFFFFFFFF}';
-var DEVICE_CLASS_KEY = '{A45C254E-DF1C-4EFD-8020-67D146A850E0},10';
-var DEVICE_CLASS_KEY_NO_SEMICOLON = '{A45C254E-DF1C-4EFD-8020-67D146A850E0}10';
-var ROOT_CONTAINER_QUERY = 'System.Devices.ContainerId:="' + ROOT_CONTAINER + '"';
-var HAL_DEVICE_CLASS = '4d36e966-e325-11ce-bfc1-08002be10318';
-var DEVICE_DRIVER_VERSION_KEY = '{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3';
-
-module.exports = {
-    getDeviceInfo: function (win, fail, args) {
-        // deviceId aka uuid, stored in Windows.Storage.ApplicationData.current.localSettings.values.deviceId
-        var deviceId;
-        // get deviceId, or create and store one
-        var localSettings = Windows.Storage.ApplicationData.current.localSettings;
-        if (localSettings.values.deviceId) {
-            deviceId = localSettings.values.deviceId;
-        } else {
-            // App-specific hardware id could be used as uuid, but it changes if the hardware changes...
-            try {
-                var ASHWID = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(null).id;
-                deviceId = Windows.Storage.Streams.DataReader.fromBuffer(ASHWID).readGuid();
-            } catch (e) {
-                // Couldn't get the hardware UUID
-                deviceId = createUUID();
-            }
-            // ...so cache it per-install
-            localSettings.values.deviceId = deviceId;
-        }
-
-        var userAgent = window.clientInformation.userAgent;
-        // this will report "windows" in windows8.1 and windows phone 8.1 apps
-        // and "windows8" in windows 8.0 apps similar to cordova.js
-        // See https://github.com/apache/cordova-js/blob/master/src/windows/platform.js#L25
-        var devicePlatform = userAgent.indexOf('MSAppHost/1.0') === -1 ? 'windows' : 'windows8';
-        var versionString = userAgent.match(/Windows (?:Phone |NT )?([0-9.]+)/)[1];
-
-        var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
-        // Running in the Windows Simulator is a remote session.
-        // Running in the Windows Phone Emulator has the systemProductName set to "Virtual"
-        var isVirtual = Windows.System.RemoteDesktop.InteractiveSession.isRemote || deviceInfo.systemProductName === 'Virtual';
-        var manufacturer = deviceInfo.systemManufacturer;
-        var model = deviceInfo.systemProductName;
-
-        var Pnp = Windows.Devices.Enumeration.Pnp;
-
-        Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.device, [DEVICE_DRIVER_VERSION_KEY, DEVICE_CLASS_KEY], ROOT_CONTAINER_QUERY).then(
-            function (rootDevices) {
-                for (var i = 0; i < rootDevices.length; i++) {
-                    var rootDevice = rootDevices[i];
-                    if (!rootDevice.properties) continue;
-                    if (rootDevice.properties[DEVICE_CLASS_KEY_NO_SEMICOLON] === HAL_DEVICE_CLASS) {
-                        versionString = rootDevice.properties[DEVICE_DRIVER_VERSION_KEY];
-                        break;
-                    }
-                }
-
-                setTimeout(function () {
-                    win({
-                        platform: devicePlatform,
-                        version: versionString,
-                        uuid: deviceId,
-                        isVirtual: isVirtual,
-                        model: model,
-                        manufacturer: manufacturer
-                    });
-                }, 0);
-            }
-        );
-    }
-}; // exports
-
-require('cordova/exec/proxy').add('Device', module.exports);


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