Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25672] (7_0_X) iOS: Fix core-SDK warnings, leaks and possible crashes #9734

Merged
merged 15 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apidoc/Titanium/Media/VideoPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ methods:
- name: thumbnailImageAtTime
deprecated:
since: '3.4.2'
notes: Use <Titanium.Media.VideoPlayer.mediaControlStyle> instead.
notes: Use <Titanium.Media.VideoPlayer.requestThumbnailImagesAtTimes> instead.
removed: '3.6.0'
summary: Returns a thumbnail image for the video at the specified time.
platforms: [iphone, ipad]
Expand Down
17 changes: 11 additions & 6 deletions iphone/Classes/APSAnalytics/APSAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
@import Foundation;
@import CoreLocation;


/** Constant indicating development deployment */
extern NSString * const APSDeployTypeDevelopment;

/** Constant indicating production deployment */
extern NSString * const APSDeployTypeProduction;


/**
* The APSAnalytics class configures the application to use the APS analytic services
* to send analytic data that can be viewed on the Appcelerator Dashboard.
Expand All @@ -28,7 +26,7 @@ extern NSString * const APSDeployTypeProduction;
/**
* Return the singleton instance to the real-time analytics service.
*/
+(instancetype) sharedInstance;
+ (instancetype) sharedInstance;

/**
* The session timeout in seconds. If the application has been in the background
Expand All @@ -49,7 +47,7 @@ extern NSString * const APSDeployTypeProduction;
* @param location A CLLocation object containing the location data.
*/

-(void)sendAppGeoEvent:(CLLocation *) location;
- (void)sendAppGeoEvent:(CLLocation *) location;

/**
* Sends a navigation event
Expand All @@ -58,7 +56,7 @@ extern NSString * const APSDeployTypeProduction;
* @param eventName String describing the event.
* @param payload Extra data to send. You can only send strings and numbers.
*/
-(void)sendAppNavEventFromView:(NSString *)firstView
- (void)sendAppNavEventFromView:(NSString *)firstView
toView:(NSString *)secondView
withName:(NSString *)eventName
payload:(NSDictionary *)payload;
Expand All @@ -68,7 +66,14 @@ extern NSString * const APSDeployTypeProduction;
* @param eventName String describing the event.
* @param payload Extra data to send. You can only send strings and numbers.
*/
-(void)sendAppFeatureEvent:(NSString *)eventName
- (void)sendAppFeatureEvent:(NSString *)eventName
payload:(NSDictionary *)payload;

/**
* Enables Analytics with a given app-key and deploy-type.
* @param appKey The APSAnalytics app-key.
* @param deployTime The deploy-type of the application.
*/
-(void)enableWithAppKey:(NSString *)appKey andDeployType:(NSString *)deployType;

@end
Binary file modified iphone/Classes/APSAnalytics/libAPSAnalytics.a
Binary file not shown.
25 changes: 0 additions & 25 deletions iphone/Classes/CalendarModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,6 @@
#import "CalendarModule.h"
#import "TiCalendarCalendar.h"

#pragma mark - Backwards compatibility for pre-iOS 6.0

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_6_0
//TODO: Should we warn that they need to update to the latest XCode if this is happening?
#define EKAuthorizationStatusNotDetermined 0
#define EKAuthorizationStatusRestricted 1
#define EKAuthorizationStatusDenied 2
#define EKAuthorizationStatusAuthorized 3

enum {
EKEntityTypeEvent,
EKEntityTypeReminder
};
typedef NSUInteger EKEntityType;

typedef void (^EKEventStoreRequestAccessCompletionHandler)(BOOL granted, NSError *error);

@protocol EKEventStoreIOS6Support <NSObject>
@optional
+ (NSInteger)authorizationStatusForEntityType:(EKEntityType)entityType;
- (void)requestAccessToEntityType:(EKEntityType)entityType completion:(EKEventStoreRequestAccessCompletionHandler)completion;
@end

#endif

@implementation CalendarModule

#pragma mark - internal methods
Expand Down
10 changes: 0 additions & 10 deletions iphone/Classes/ContactsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
#import "TiContactsPerson.h"
#import <AddressBookUI/AddressBookUI.h>

#pragma Backwards compatibility for pre - iOS 6.0

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_6_0
//TODO: Should we warn that they need to update to the latest XCode is this is happening?
#define kABAuthorizationStatusNotDetermined 0
#define kABAuthorizationStatusRestricted 1
#define kABAuthorizationStatusDenied 2
#define kABAuthorizationStatusAuthorized 3
#endif

#define appleUndocumentedBirthdayProperty 999
#define appleUndocumentedToneProperty 16
#define appleUndocumentedRingToneIdentifier -1
Expand Down
20 changes: 7 additions & 13 deletions iphone/Classes/GeolocationModule.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-2018 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -34,10 +34,8 @@ NSString *const kTiGeolocationUsageDescriptionAlwaysAndWhenInUse = @"NSLocationA
KrollCallback *authorizationCallback;
CLAuthorizationStatus requestedAuthorizationStatus;

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
CLActivityType activityType;
BOOL pauseLocationUpdateAutomatically;
#endif
NSDictionary *lastLocationDict;
NSRecursiveLock *lock;
}
Expand All @@ -51,9 +49,7 @@ NSString *const kTiGeolocationUsageDescriptionAlwaysAndWhenInUse = @"NSLocationA
@property (nonatomic, readonly) NSNumber *locationServicesEnabled;
@property (nonatomic, readonly) NSNumber *locationServicesAuthorization;

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
@property (nonatomic, readwrite, assign) NSNumber *activityType;
#endif

// Error codes
@property (nonatomic, readonly) NSNumber *ERROR_LOCATION_UNKNOWN;
Expand All @@ -65,7 +61,7 @@ NSString *const kTiGeolocationUsageDescriptionAlwaysAndWhenInUse = @"NSLocationA
@property (nonatomic, readonly) NSNumber *ERROR_REGION_MONITORING_FAILURE;
@property (nonatomic, readonly) NSNumber *ERROR_REGION_MONITORING_DELAYED;

// the reason for using Location services - now required in 3.2+
// the reason for using Location services
@property (nonatomic, readwrite, assign) NSString *purpose;

@property (nonatomic, readonly) NSNumber *ACCURACY_BEST;
Expand All @@ -75,23 +71,21 @@ NSString *const kTiGeolocationUsageDescriptionAlwaysAndWhenInUse = @"NSLocationA
@property (nonatomic, readonly) NSNumber *ACCURACY_KILOMETER;
@property (nonatomic, readonly) NSNumber *ACCURACY_LOW;
@property (nonatomic, readonly) NSNumber *ACCURACY_THREE_KILOMETERS;
@property (nonatomic, readonly) NSNumber *ACCURACY_BEST_FOR_NAVIGATION; //Since 3.1.0
@property (nonatomic, readonly) NSNumber *ACCURACY_BEST_FOR_NAVIGATION;

// Authorization to use location, 4.2+ only
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_2
// Authorization to use location
@property (nonatomic, readonly) NSNumber *AUTHORIZATION_UNKNOWN;
@property (nonatomic, readonly) NSNumber *AUTHORIZATION_AUTHORIZED;
@property (nonatomic, readonly) NSNumber *AUTHORIZATION_WHEN_IN_USE;
@property (nonatomic, readonly) NSNumber *AUTHORIZATION_ALWAYS;
@property (nonatomic, readonly) NSNumber *AUTHORIZATION_DENIED;
@property (nonatomic, readonly) NSNumber *AUTHORIZATION_RESTRICTED;
#endif
@property (nonatomic, readonly) NSNumber *AUTHORIZATION_UNKNOWN; // We still need the 'authorization unknown' constant, though.

// To specify the geolocation activity type
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
@property (nonatomic, readonly) NSNumber *ACTIVITYTYPE_OTHER; // default
@property (nonatomic, readonly) NSNumber *ACTIVITYTYPE_AUTOMOTIVE_NAVIGATION; // for automotive navigation
@property (nonatomic, readonly) NSNumber *ACTIVITYTYPE_FITNESS; // includes any pedestrian activities
@property (nonatomic, readonly) NSNumber *ACTIVITYTYPE_OTHER_NAVIGATION; // for other navigation cases (excluding pedestrian navigation), e.g. navigation for boats, trains or planes.
#endif

@end

Expand Down
29 changes: 4 additions & 25 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,6 @@ - (void)setTrackSignificantLocationChange:(id)value
}
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
// Activity Type for CLlocationManager.
- (NSNumber *)activityType
{
Expand Down Expand Up @@ -706,7 +705,6 @@ - (void)setPauseLocationUpdateAutomatically:(id)value
},
NO);
}
#endif

- (void)restart:(id)arg
{
Expand All @@ -731,15 +729,12 @@ - (void)restart:(id)arg
MAKE_SYSTEM_PROP_DBL(ACCURACY_LOW, kCLLocationAccuracyThreeKilometers);
MAKE_SYSTEM_PROP(ACCURACY_BEST_FOR_NAVIGATION, kCLLocationAccuracyBestForNavigation); //Since 2.1.3

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_2
MAKE_SYSTEM_PROP(AUTHORIZATION_UNKNOWN, kCLAuthorizationStatusNotDetermined);
MAKE_SYSTEM_PROP(AUTHORIZATION_AUTHORIZED, kCLAuthorizationStatusAuthorized);
MAKE_SYSTEM_PROP(AUTHORIZATION_AUTHORIZED, kCLAuthorizationStatusAuthorizedAlways);
MAKE_SYSTEM_PROP(AUTHORIZATION_WHEN_IN_USE, kCLAuthorizationStatusAuthorizedWhenInUse);
MAKE_SYSTEM_PROP(AUTHORIZATION_ALWAYS, kCLAuthorizationStatusAuthorizedAlways);
MAKE_SYSTEM_PROP(AUTHORIZATION_DENIED, kCLAuthorizationStatusDenied);
MAKE_SYSTEM_PROP(AUTHORIZATION_RESTRICTED, kCLAuthorizationStatusRestricted);
#else
// We only need auth unknown, because that's all the system will return.
MAKE_SYSTEM_PROP(AUTHORIZATION_UNKNOWN, 0);
#endif

MAKE_SYSTEM_PROP(ERROR_LOCATION_UNKNOWN, kCLErrorLocationUnknown);
MAKE_SYSTEM_PROP(ERROR_DENIED, kCLErrorDenied);
Expand All @@ -750,22 +745,10 @@ - (void)restart:(id)arg
MAKE_SYSTEM_PROP(ERROR_REGION_MONITORING_FAILURE, kCLErrorRegionMonitoringFailure);
MAKE_SYSTEM_PROP(ERROR_REGION_MONITORING_DELAYED, kCLErrorRegionMonitoringSetupDelayed);

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
MAKE_SYSTEM_PROP(ACTIVITYTYPE_OTHER, CLActivityTypeOther);
MAKE_SYSTEM_PROP(ACTIVITYTYPE_AUTOMOTIVE_NAVIGATION, CLActivityTypeAutomotiveNavigation);
MAKE_SYSTEM_PROP(ACTIVITYTYPE_FITNESS, CLActivityTypeFitness);
MAKE_SYSTEM_PROP(ACTIVITYTYPE_OTHER_NAVIGATION, CLActivityTypeOtherNavigation);
#endif

- (NSNumber *)AUTHORIZATION_ALWAYS
{
return NUMINT(kCLAuthorizationStatusAuthorizedAlways);
}

- (NSNumber *)AUTHORIZATION_WHEN_IN_USE
{
return NUMINT(kCLAuthorizationStatusAuthorizedWhenInUse);
}

- (CLLocationManager *)locationPermissionManager
{
Expand Down Expand Up @@ -823,7 +806,7 @@ - (void)requestLocationPermissions:(id)args

if (requestedAuthorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse) {
if ([GeolocationModule hasWhenInUsePermissionKeys]) {
if ((currentPermissionLevel == kCLAuthorizationStatusAuthorizedAlways) || (currentPermissionLevel == kCLAuthorizationStatusAuthorized)) {
if (currentPermissionLevel == kCLAuthorizationStatusAuthorizedAlways) {
errorMessage = @"Cannot change already granted permission from AUTHORIZATION_ALWAYS to the lower permission-level AUTHORIZATION_WHEN_IN_USE";
} else {
TiThreadPerformOnMainThread(^{
Expand Down Expand Up @@ -1020,8 +1003,6 @@ - (void)fireApplicationAnalyticsIfNeeded:(NSArray *)locations

#pragma mark Delegates

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0

- (void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager
{
if ([self _hasListeners:@"locationupdatepaused"]) {
Expand All @@ -1036,8 +1017,6 @@ - (void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager
}
}

#endif

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:
Expand Down
18 changes: 1 addition & 17 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,7 @@
static NSDictionary *TI_filterableItemProperties;
#endif

#pragma mark - Backwards compatibility for pre-iOS 7.0

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0

@protocol AVAudioSessionIOS7Support <NSObject>
@optional
- (void)requestRecordPermission:(PermissionBlock)response;
typedef void (^PermissionBlock)(BOOL granted)
@end

#endif

@interface TiImagePickerController : UIImagePickerController
{
@interface TiImagePickerController : UIImagePickerController {
@private
BOOL autoRotate;
}
Expand Down Expand Up @@ -604,9 +591,6 @@ - (NSNumber *)isCameraSupported
}
#endif

/**
Check if camera is authorized, only available for >= iOS 7
**/
#if defined(USE_TI_MEDIACAMERAAUTHORIZATION) || defined(USE_TI_MEDIACAMERAAUTHORIZATIONSTATUS)
- (NSNumber *)cameraAuthorizationStatus
{
Expand Down
8 changes: 3 additions & 5 deletions iphone/Classes/TiApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
return YES;
}

#pragma mark
#pragma mark Background Fetch iOS 7
#pragma mark Background Fetch

#ifdef USE_TI_FETCH

Expand Down Expand Up @@ -482,7 +481,7 @@ - (void)application:(UIApplication *)application performFetchWithCompletionHandl

#endif

#pragma mark Remote and Local Notifications iOS 8
#pragma mark Remote and Local Notifications

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
Expand Down Expand Up @@ -695,8 +694,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N

#endif

#pragma mark
#pragma mark Background Transfer Service iOS 7
#pragma mark Background Transfer Service

//Delegate callback for Background Transfer completes.
- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler
Expand Down
4 changes: 0 additions & 4 deletions iphone/Classes/TiMediaVideoPlayerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ typedef NS_ENUM(NSInteger, TiVideoPlayerPlaybackState) {
// We need some internal way whether or not to check if it's OK to create a view - this is it.
BOOL reallyAttached;

// Need to preserve status bar frame information when entering/exiting fullscreen to properly re-render
// views when exiting it.
BOOL statusBarWasHidden;

// Have to track loading in the proxy in addition to the view, in case we load before the view should be rendered
BOOL loaded;

Expand Down