Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions mobile/android/android-application-manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {EOL} from "os";
import {ApplicationManagerBase} from "../application-manager-base";
import { EOL } from "os";
import { ApplicationManagerBase } from "../application-manager-base";
import { LiveSyncConstants, TARGET_FRAMEWORK_IDENTIFIERS } from "../../constants";
import Future = require("fibers/future");
import { hook } from "../../helpers";

export class AndroidApplicationManager extends ApplicationManagerBase {

Expand All @@ -12,8 +13,9 @@ export class AndroidApplicationManager extends ApplicationManagerBase {
private $logcatHelper: Mobile.ILogcatHelper,
private $androidProcessService: Mobile.IAndroidProcessService,
private $httpClient: Server.IHttpClient,
$logger: ILogger) {
super($logger);
$logger: ILogger,
$hooksService: IHooksService) {
super($logger, $hooksService);
}

public getInstalledApplications(): IFuture<string[]> {
Expand All @@ -30,6 +32,7 @@ export class AndroidApplicationManager extends ApplicationManagerBase {
}).future<string[]>()();
}

@hook('install')
public installApplication(packageFilePath: string): IFuture<void> {
return this.adb.executeCommand(["install", "-r", `${packageFilePath}`]);
}
Expand Down
5 changes: 3 additions & 2 deletions mobile/application-manager-base.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { EventEmitter } from "events";
import {TARGET_FRAMEWORK_IDENTIFIERS} from "../constants";
import { TARGET_FRAMEWORK_IDENTIFIERS } from "../constants";

export abstract class ApplicationManagerBase extends EventEmitter implements Mobile.IDeviceApplicationManager {
private lastInstalledAppIdentifiers: string[];
private lastAvailableDebuggableApps: Mobile.IDeviceApplicationInformation[];
private lastAvailableDebuggableAppViews: IDictionary<Mobile.IDebugWebViewInfo[]> = {};

constructor(protected $logger: ILogger) {
constructor(protected $logger: ILogger,
protected $hooksService: IHooksService) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$hooksService seems unused. Why inject it all over the place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out the hook decorator needs that. It looks like we need to kill this decorator and move this feature to a method of the hook service (outside of scope for this PR).

super();
}

Expand Down
15 changes: 9 additions & 6 deletions mobile/ios/device/ios-application-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import * as net from "net";
import * as ref from "ref";
import * as os from "os";
import * as iOSProxyServices from "./ios-proxy-services";
import {ApplicationManagerBase} from "../../application-manager-base";
import {CoreTypes, GDBServer} from "./ios-core";
import { hook } from "../../../helpers";
import { ApplicationManagerBase } from "../../application-manager-base";
import { CoreTypes, GDBServer } from "./ios-core";
import Future = require("fibers/future");

export class IOSApplicationManager extends ApplicationManagerBase {
Expand All @@ -12,6 +13,7 @@ export class IOSApplicationManager extends ApplicationManagerBase {
private applicationsLiveSyncInfos: Mobile.ILiveSyncApplicationInfo[];

constructor(protected $logger: ILogger,
protected $hooksService: IHooksService,
private device: Mobile.IiOSDevice,
private devicePointer: NodeBuffer,
private $childProcess: IChildProcess,
Expand All @@ -24,7 +26,7 @@ export class IOSApplicationManager extends ApplicationManagerBase {
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $processService: IProcessService,
private $options: ICommonOptions) {
super($logger);
super($logger, $hooksService);
this.uninstallApplicationCallbackPtr = CoreTypes.am_device_mount_image_callback.toPointer(IOSApplicationManager.uninstallCallback);
}

Expand All @@ -43,6 +45,7 @@ export class IOSApplicationManager extends ApplicationManagerBase {
}).future<string[]>()();
}

@hook('install')
public installApplication(packageFilePath: string): IFuture<void> {
return (() => {
let installationProxy = this.getInstallationProxy();
Expand Down Expand Up @@ -74,8 +77,8 @@ export class IOSApplicationManager extends ApplicationManagerBase {
"ApplicationType": "User",
"ReturnAttributes": [
"CFBundleIdentifier",
"IceniumLiveSyncEnabled",
"configuration"
"IceniumLiveSyncEnabled",
"configuration"
]
}
}).wait();
Expand Down Expand Up @@ -158,7 +161,7 @@ export class IOSApplicationManager extends ApplicationManagerBase {
isLiveSyncSupported: app.IceniumLiveSyncEnabled,
configuration: app.configuration,
deviceIdentifier: this.device.deviceInfo.identifier
}));
}));
this.applicationsLiveSyncInfos = this.applicationsLiveSyncInfos.concat(currentList);
});

Expand Down
7 changes: 5 additions & 2 deletions mobile/ios/simulator/ios-simulator-application-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ApplicationManagerBase} from "../../application-manager-base";
import Future = require("fibers/future");
import * as path from "path";
import * as temp from "temp";
import { hook } from "../../../helpers";

export class IOSSimulatorApplicationManager extends ApplicationManagerBase {
constructor(private iosSim: any,
Expand All @@ -11,14 +12,16 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase {
private $bplistParser: IBinaryPlistParser,
private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider,
private $deviceLogProvider: Mobile.IDeviceLogProvider,
$logger: ILogger) {
super($logger);
$logger: ILogger,
$hooksService: IHooksService) {
super($logger, $hooksService);
}

public getInstalledApplications(): IFuture<string[]> {
return Future.fromResult(this.iosSim.getInstalledApplications(this.identifier));
}

@hook('install')
public installApplication(packageFilePath: string): IFuture<void> {
return (() => {
if (this.$fs.exists(packageFilePath).wait() && path.extname(packageFilePath) === ".zip") {
Expand Down
11 changes: 6 additions & 5 deletions test/unit-tests/mobile/application-manager-base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Yok} from "../../../yok";
import {assert} from "chai";
import { CommonLoggerStub } from "../stubs";
import { Yok } from "../../../yok";
import { assert } from "chai";
import { CommonLoggerStub, HooksServiceStub } from "../stubs";
import { ApplicationManagerBase } from "../../../mobile/application-manager-base";
import Future = require("fibers/future");

Expand All @@ -9,8 +9,8 @@ let currentlyAvailableAppsForDebugging: Mobile.IDeviceApplicationInformation[],
currentlyAvailableAppWebViewsForDebugging: IDictionary<Mobile.IDebugWebViewInfo[]>;

class ApplicationManager extends ApplicationManagerBase {
constructor($logger: ILogger) {
super($logger);
constructor($logger: ILogger, $hooksService: IHooksService) {
super($logger, $hooksService);
}

public isLiveSyncSupported(appIdentifier: string): IFuture<boolean> {
Expand Down Expand Up @@ -57,6 +57,7 @@ class ApplicationManager extends ApplicationManagerBase {
function createTestInjector(): IInjector {
let testInjector = new Yok();
testInjector.register("logger", CommonLoggerStub);
testInjector.register("hooksService", HooksServiceStub);
testInjector.register("applicationManager", ApplicationManager);
return testInjector;
}
Expand Down
12 changes: 12 additions & 0 deletions test/unit-tests/stubs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* tslint:disable:no-empty */

import * as util from "util";
import Future = require("fibers/future");

export class CommonLoggerStub implements ILogger {
setLevel(level: string): void { }
Expand Down Expand Up @@ -64,3 +65,14 @@ export class ErrorsStub implements IErrors {

verifyHeap(message: string): void { }
}

export class HooksServiceStub implements IHooksService {
executeBeforeHooks(commandName: string): IFuture<void> {
return Future.fromResult();
}
executeAfterHooks(commandName: string): IFuture<void> {
return Future.fromResult();
}

hookArgsName = "hookArgs";
}