From cf2001154e6131abd812182af9e7ec7058533b03 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Fri, 5 Apr 2024 20:17:35 +0300 Subject: [PATCH] Removed OpenUDID completely --- Ports/iOSPort/nativeSources/IOSNative.m | 3 +- Ports/iOSPort/nativeSources/OpenUDID.h | 65 ------ Ports/iOSPort/nativeSources/OpenUDID.m | 284 ------------------------ 3 files changed, 1 insertion(+), 351 deletions(-) delete mode 100644 Ports/iOSPort/nativeSources/OpenUDID.h delete mode 100644 Ports/iOSPort/nativeSources/OpenUDID.m diff --git a/Ports/iOSPort/nativeSources/IOSNative.m b/Ports/iOSPort/nativeSources/IOSNative.m index 5dbb157998..13beda8113 100644 --- a/Ports/iOSPort/nativeSources/IOSNative.m +++ b/Ports/iOSPort/nativeSources/IOSNative.m @@ -55,7 +55,6 @@ #import #import "UIWebViewEventDelegate.h" #include -#include "OpenUDID.h" #ifdef CN1_USE_STOREKIT #import "StoreKit/StoreKit.h" #endif @@ -4356,7 +4355,7 @@ int popoverSupported() } JAVA_OBJECT com_codename1_impl_ios_IOSNative_getUDID__(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT instanceObject) { - return fromNSString(CN1_THREAD_STATE_PASS_ARG [OpenUDID value]); + return JAVA_NULL; } JAVA_OBJECT com_codename1_impl_ios_IOSNative_getOSVersion__(CN1_THREAD_STATE_MULTI_ARG JAVA_OBJECT instanceObject) { diff --git a/Ports/iOSPort/nativeSources/OpenUDID.h b/Ports/iOSPort/nativeSources/OpenUDID.h deleted file mode 100644 index a09e31331c..0000000000 --- a/Ports/iOSPort/nativeSources/OpenUDID.h +++ /dev/null @@ -1,65 +0,0 @@ -// -// OpenUDID.h -// openudid -// -// initiated by Yann Lechelle (cofounder @Appsfire) on 8/28/11. -// Copyright 2011 OpenUDID.org -// -// Main branches -// iOS code: https://github.com/ylechelle/OpenUDID -// - -/* - !!! IMPORTANT !!! - - IF YOU ARE GOING TO INTEGRATE OpenUDID INSIDE A (STATIC) LIBRARY, - PLEASE MAKE SURE YOU REFACTOR THE OpenUDID CLASS WITH A PREFIX OF YOUR OWN, - E.G. ACME_OpenUDID. THIS WILL AVOID CONFUSION BY DEVELOPERS WHO ARE ALSO - USING OpenUDID IN THEIR OWN CODE. - - !!! IMPORTANT !!! - -*/ - -/* - http://en.wikipedia.org/wiki/Zlib_License - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -#import - -// -// Usage: -// #include "OpenUDID.h" -// NSString* openUDID = [OpenUDID value]; -// - -#define kOpenUDIDErrorNone 0 -#define kOpenUDIDErrorOptedOut 1 -#define kOpenUDIDErrorCompromised 2 - -@interface OpenUDID : NSObject { -} -+ (NSString*) value; -+ (NSString*) valueWithError:(NSError**)error; -+ (void) setOptOut:(BOOL)optOutValue; - -@end diff --git a/Ports/iOSPort/nativeSources/OpenUDID.m b/Ports/iOSPort/nativeSources/OpenUDID.m deleted file mode 100644 index bc455aea33..0000000000 --- a/Ports/iOSPort/nativeSources/OpenUDID.m +++ /dev/null @@ -1,284 +0,0 @@ -// -// OpenUDID.m -// openudid -// -// initiated by Yann Lechelle (cofounder @Appsfire) on 8/28/11. -// Copyright 2011 OpenUDID.org -// -// Initiators/root branches -// iOS code: https://github.com/ylechelle/OpenUDID -// Android code: https://github.com/vieux/OpenUDID -// -// Contributors: -// https://github.com/ylechelle/OpenUDID/contributors -// - -/* - http://en.wikipedia.org/wiki/Zlib_License - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ - -/*#if __has_feature(objc_arc) -#error This file uses the classic non-ARC retain/release model; hints below... - // to selectively compile this file as non-ARC, do as follows: - // https://img.skitch.com/20120717-g3ag5h9a6ehkgpmpjiuen3qpwp.png -#endif*/ - -#import "OpenUDID.h" -#import // Need to import for CC_MD5 access -#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR -#import -#import -#else -#import -#endif - -#define OpenUDIDLog(fmt, ...) -//#define OpenUDIDLog(fmt, ...) CN1Log((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); -//#define OpenUDIDLog(fmt, ...) CN1Log((@"[Line %d] " fmt), __LINE__, ##__VA_ARGS__); - -static NSString * kOpenUDIDSessionCache = nil; -static NSString * const kOpenUDIDKey = @"OpenUDID"; -static NSString * const kOpenUDIDSlotKey = @"OpenUDID_slot"; -static NSString * const kOpenUDIDAppUIDKey = @"OpenUDID_appUID"; -static NSString * const kOpenUDIDTSKey = @"OpenUDID_createdTS"; -static NSString * const kOpenUDIDOOTSKey = @"OpenUDID_optOutTS"; -static NSString * const kOpenUDIDDomain = @"org.OpenUDID"; -static NSString * const kOpenUDIDSlotPBPrefix = @"org.OpenUDID.slot."; -static int const kOpenUDIDRedundancySlots = 100; - -@interface OpenUDID (Private) -+ (void) _setDict:(id)dict forPasteboard:(id)pboard; -+ (NSMutableDictionary*) _getDictFromPasteboard:(id)pboard; -+ (NSString*) _generateFreshOpenUDID; -@end - -@implementation OpenUDID - -// Archive a NSDictionary inside a pasteboard of a given type -// Convenience method to support iOS & Mac OS X -// -+ (void) _setDict:(id)dict forPasteboard:(id)pboard { -#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR - [pboard setData:[NSKeyedArchiver archivedDataWithRootObject:dict] forPasteboardType:kOpenUDIDDomain]; -#else - [pboard setData:[NSKeyedArchiver archivedDataWithRootObject:dict] forType:kOpenUDIDDomain]; -#endif -} - -// Retrieve an NSDictionary from a pasteboard of a given type -// Convenience method to support iOS & Mac OS X -// -+ (NSMutableDictionary*) _getDictFromPasteboard:(id)pboard { -#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR - id item = [pboard dataForPasteboardType:kOpenUDIDDomain]; -#else - id item = [pboard dataForType:kOpenUDIDDomain]; -#endif - if (item) { - @try{ - item = [NSKeyedUnarchiver unarchiveObjectWithData:item]; - } @catch(NSException* e) { - OpenUDIDLog(@"Unable to unarchive item %@ on pasteboard!", [pboard name]); - item = nil; - } - } - - // return an instance of a MutableDictionary - return [NSMutableDictionary dictionaryWithDictionary:(item == nil || [item isKindOfClass:[NSDictionary class]]) ? item : nil]; -} - -// Private method to create and return a new OpenUDID -// Theoretically, this function is called once ever per application when calling [OpenUDID value] for the first time. -// After that, the caching/pasteboard/redundancy mechanism inside [OpenUDID value] returns a persistent and cross application OpenUDID -// -+ (NSString*) _generateFreshOpenUDID { - - NSString* _openUDID = nil; - - // August 2011: One day, this may no longer be allowed in iOS. When that is, just comment this line out. - // March 25th 2012: this day has come, let's remove this "outlawed" call... -#if TARGET_OS_IPHONE -// if([UIDevice instancesRespondToSelector:@selector(uniqueIdentifier)]){ -// _openUDID = [[UIDevice currentDevice] uniqueIdentifier]; -// } -#endif - // Next we generate a UUID. - // UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs - // (Interface Identifiers), are 128-bit values guaranteed to be unique. A UUID is made unique over - // both space and time by combining a value unique to the computer on which it was generated�usually the - // Ethernet hardware address�and a value representing the number of 100-nanosecond intervals since - // October 15, 1582 at 00:00:00. - // We then hash this UUID with md5 to get 32 bytes, and then add 4 extra random bytes - // Collision is possible of course, but unlikely and suitable for most industry needs (e.g. aggregate tracking) - // - if (_openUDID==nil) { - CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); - CFStringRef cfstring = CFUUIDCreateString(kCFAllocatorDefault, uuid); - const char *cStr = CFStringGetCStringPtr(cfstring,CFStringGetFastestEncoding(cfstring)); - unsigned char result[16]; - CC_MD5( cStr, (unsigned int)strlen(cStr), result ); - CFRelease(uuid); - - _openUDID = [NSString stringWithFormat: - @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%08x", - result[0], result[1], result[2], result[3], - result[4], result[5], result[6], result[7], - result[8], result[9], result[10], result[11], - result[12], result[13], result[14], result[15], - (unsigned long)(arc4random() % NSUIntegerMax)]; - } - - // Call to other developers in the Open Source community: - // - // feel free to suggest better or alternative "UDID" generation code above. - // NOTE that the goal is NOT to find a better hash method, but rather, find a decentralized (i.e. not web-based) - // 160 bits / 20 bytes random string generator with the fewest possible collisions. - // - - return _openUDID; -} - - -// Main public method that returns the OpenUDID -// This method will generate and store the OpenUDID if it doesn't exist, typically the first time it is called -// It will return the null udid (forty zeros) if the user has somehow opted this app out (this is subject to 3rd party implementation) -// Otherwise, it will register the current app and return the OpenUDID -// -+ (NSString*) value { - return [OpenUDID valueWithError:nil]; -} - -+ (NSString*) valueWithError:(NSError **)error { - - if (kOpenUDIDSessionCache!=nil) { - return kOpenUDIDSessionCache; - } - - - NSString* openUDID = nil; - NSString* myRedundancySlotPBid = nil; - NSDate* optedOutDate = nil; - BOOL optedOut = NO; - BOOL saveLocalDictToDefaults = NO; - BOOL isCompromised = NO; - - - // Here we go through a sequence of slots, each of which being a UIPasteboard created by each participating app - // The idea behind this is to both multiple and redundant representations of OpenUDIDs, as well as serve as placeholder for potential opt-out - // - NSString* availableSlotPBid = nil; - NSMutableDictionary* frequencyDict = [NSMutableDictionary dictionaryWithCapacity:kOpenUDIDRedundancySlots]; - for (int n=0; n0)? [arrayOfUDIDs lastObject] : nil; - OpenUDIDLog(@"Freq Dict = %@\nMost reliable %@",frequencyDict,mostReliableOpenUDID); - - // if openUDID was not retrieved from the local preferences, then let's try to get it from the frequency dictionary above - // - if (openUDID==nil) { - if (mostReliableOpenUDID==nil) { - // this is the case where this app instance is likely to be the first one to use OpenUDID on this device - // we create the OpenUDID, legacy or semi-random (i.e. most certainly unique) - // - openUDID = [OpenUDID _generateFreshOpenUDID]; - } else { - // or we leverage the OpenUDID shared by other apps that have already gone through the process - // - openUDID = mostReliableOpenUDID; - } - } - else { - // Sanity/tampering check - // - if (mostReliableOpenUDID!=nil && ![mostReliableOpenUDID isEqualToString:openUDID]) - isCompromised = YES; - } - - // Here we store in the available PB slot, if applicable - // - OpenUDIDLog(@"Available Slot %@ Existing Slot %@",availableSlotPBid,myRedundancySlotPBid); - if (availableSlotPBid!=nil && (myRedundancySlotPBid==nil || [availableSlotPBid isEqualToString:myRedundancySlotPBid])) { -#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR - UIPasteboard* slotPB = [UIPasteboard pasteboardWithName:availableSlotPBid create:YES]; - [slotPB setPersistent:YES]; -#else - NSPasteboard* slotPB = [NSPasteboard pasteboardWithName:availableSlotPBid]; -#endif - - // save slotPBid to the defaults, and remember to save later - // - if (localDict) { - [localDict setObject:availableSlotPBid forKey:kOpenUDIDSlotKey]; - saveLocalDictToDefaults = YES; - } - } - - // If the UIPasteboard external representation marks this app as opted-out, then to respect privacy, we return the ZERO OpenUDID, a sequence of 40 zeros... - // This is a *new* case that developers have to deal with. Unlikely, statistically low, but still. - // To circumvent this and maintain good tracking (conversion ratios, etc.), developers are invited to calculate how many of their users have opted-out from the full set of users. - // This ratio will let them extrapolate convertion ratios more accurately. - // - if (optedOut) { - kOpenUDIDSessionCache = [[NSString stringWithFormat:@"%040x",0] retain]; - return kOpenUDIDSessionCache; - } - - // return the well earned openUDID! - // - kOpenUDIDSessionCache = [openUDID retain]; - return kOpenUDIDSessionCache; -} - -+ (void) setOptOut:(BOOL)optOutValue { - - -} - -@end