From fbf9d30913abf1c80e61d14140bdc48a225b2b9d Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Mon, 13 May 2024 22:32:17 +0200 Subject: [PATCH] fix!: remove deprecated platforms (#181) --- 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(-) delete mode 100644 src/osx/CDVDevice.h delete mode 100644 src/osx/CDVDevice.m delete mode 100644 src/windows/DeviceProxy.js diff --git a/README.md b/README.md index 48a1848b..0c0190c0 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 @@ -128,8 +124,6 @@ var string = device.platform; - Android - Browser - iOS -- Windows -- OS X ### Quick Example @@ -138,8 +132,6 @@ var string = device.platform; // - "Android" // - "browser" // - "iOS" -// - "WinCE" -// - "Mac OS X" // var devicePlatform = device.platform; ``` @@ -160,8 +152,6 @@ The details of how a UUID is generated are determined by the device manufacturer - Android - iOS -- Windows -- OS X ### Quick Example @@ -171,9 +161,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; ``` @@ -214,8 +201,6 @@ Get the operating system version. - Android - Browser - iOS -- Windows -- OS X ### Quick Example @@ -228,10 +213,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; ``` @@ -245,7 +226,6 @@ Get the device's manufacturer. - Android - iOS -- Windows ### Quick Example diff --git a/package.json b/package.json index 700641fb..3921ec3b 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 9e5e44fb..aec9de97 100644 --- a/plugin.xml +++ b/plugin.xml @@ -68,13 +68,6 @@ - - - - - - - @@ -88,17 +81,4 @@ - - - - - - - - - - - - - diff --git a/src/osx/CDVDevice.h b/src/osx/CDVDevice.h deleted file mode 100644 index 46bde27d..00000000 --- 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 - -@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 dd6f811f..00000000 --- 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 - -#import - -#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 b3d095f5..00000000 --- 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);