Change progress values during incremental installation to follow the same convention that standard installations follow (#451)

Change progress values during incremental installation to follow the same convention that standard installations follow, i.e. 50% is doing during transfer and the other 50% during installation phases.

Moves the specialized incremental callback logic into it's own method that calls the non-incremental callbacks for shared logic.
diff --git a/src/ios-deploy/ios-deploy.m b/src/ios-deploy/ios-deploy.m
index 3bb9b62..36a6762 100644
--- a/src/ios-deploy/ios-deploy.m
+++ b/src/ios-deploy/ios-deploy.m
@@ -663,35 +663,38 @@
     CFNumberGetValue(CFDictionaryGetValue(dict, CFSTR("PercentComplete")), kCFNumberSInt32Type, &percent);
 
     int overall_percent = (percent / 2) + 50;
-
-    // During standard install, the "Status" value contains the actual status,
-    // such as "Copying" or "CreatingStagingDirectory", as well as any
-    // applicable paths. The incremental install version, includes only the
-    // status and a seperate value in "Path" for any applicable paths. This
-    // merges the status and path during incremental installs so the output is
-    // similar between both installation types.
-    CFStringRef path = CFDictionaryGetValue(dict, CFSTR("Path"));
-    NSString *status_with_path = (path != NULL && app_deltas != NULL) ?
-      [NSString stringWithFormat:@"%@ %@", status, path] :
-      (__bridge NSString *)status;
-
-    NSLogOut(@"[%3d%%] %@", overall_percent, status_with_path);
-
-    NSMutableDictionary *jsonOutput = [@{
-      @"Event": @"BundleInstall",
-      @"OverallPercent": @(overall_percent),
-      @"Percent": @(percent),
-      @"Status": (__bridge NSString *)status
-    } mutableCopy];
-    if (path != NULL) {
-      [jsonOutput setValue:(__bridge NSString *)path forKey:@"Path"];
-    }
-
-    NSLogJSON(jsonOutput);
-    [jsonOutput release];
+    NSLogOut(@"[%3d%%] %@", overall_percent, status);
+    NSLogJSON(@{@"Event": @"BundleInstall",
+                @"OverallPercent": @(overall_percent),
+                @"Percent": @(percent),
+                @"Status": (__bridge NSString *)status
+                });
     return 0;
 }
 
+// During standard installation transferring and installation takes place
+// in distinct function that can be passed distinct callbacks. Incremental
+// installation performs both transfer and installation in a single function so
+// use this callback to determine which step is occuring and call the proper
+// callback.
+mach_error_t incremental_install_callback(CFDictionaryRef dict, int arg) {
+  CFStringRef status = CFDictionaryGetValue(dict, CFSTR("Status"));
+  if (CFEqual(status, CFSTR("TransferringPackage"))) {
+    int percent;
+    CFNumberGetValue(CFDictionaryGetValue(dict, CFSTR("PercentComplete")), kCFNumberSInt32Type, &percent);
+    int overall_percent = (percent / 2);
+    NSLogOut(@"[%3d%%] %@", overall_percent, status);
+    NSLogJSON(@{@"Event": @"TransferringPackage",
+                @"OverallPercent": @(overall_percent),
+    });
+    return 0;
+  } else if (CFEqual(status, CFSTR("CopyingFile"))) {
+    return transfer_callback(dict, arg);
+  } else {
+    return install_callback(dict, arg);
+  }
+}
+
 CFURLRef copy_device_app_url(AMDeviceRef device, CFStringRef identifier) {
     CFDictionaryRef result = nil;
 
@@ -1932,7 +1935,7 @@
           assert(AMDeviceIsPaired(device));
           check_error(AMDeviceValidatePairing(device));
           check_error(AMDeviceStartSession(device));
-          check_error(AMDeviceSecureInstallApplicationBundle(device, url, options, install_callback, 0));
+          check_error(AMDeviceSecureInstallApplicationBundle(device, url, options, incremental_install_callback, 0));
           CFRelease(extracted_bundle_id);
           CFRelease(deltas_path);
           CFRelease(deltas_relative_url);