Skip to content
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
38 changes: 30 additions & 8 deletions bolt/src/RemotePackageManager.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,52 @@ class RemotePackageManager {

isPackageInstalled(id, version) {
try {
return this.remote.makeThunderRequest({
method: `${config.PACKAGE_MANAGER_CALLSIGN}.packageState`,
params: { packageId: id, version },
}) === "INSTALLED";
return this.makeRequest("packageState", { packageId: id, version }) === "INSTALLED";
} catch (e) {
return false;
}
}

isActive() {
return this.getCallsign() !== null;
}

install(id, version, fileLocator) {
return this.makeRequest("install", { packageId: id, version, fileLocator });
}

callsignIsActive(callsign) {
try {
const status = this.remote.makeThunderRequest({
method: `Controller.status@${config.PACKAGE_MANAGER_CALLSIGN}`,
method: `Controller.status@${callsign}`,
});
return status[0].state === "activated";
} catch (e) {
return false;
}
}

install(id, version, fileLocator) {
getCallsign() {
if (this.callsign === undefined) {
this.callsign = null;
for (const callsign of config.PACKAGE_MANAGER_CALLSIGNS) {
if (this.callsignIsActive(callsign)) {
this.callsign = callsign;
break;
}
}
Comment thread
astolcenburg marked this conversation as resolved.
}
return this.callsign;
}

makeRequest(method, params) {
const callsign = this.getCallsign();
if (!callsign) {
throw new Error("No package manager is active on the device");
}
return this.remote.makeThunderRequest({
method: `${config.PACKAGE_MANAGER_CALLSIGN}.install`,
params: { packageId: id, version, fileLocator },
method: `${callsign}.${method}`,
params,
});
}
}
Expand Down
5 changes: 4 additions & 1 deletion bolt/src/config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ exports.AI2_MANAGERS_ENABLED_FILE = "/opt/ai2managers";
exports.DEFAULT_UID = 34567;
exports.DEFAULT_GID = 34567;
exports.PROCESS_HOME_DIR = "/home";
exports.PACKAGE_MANAGER_CALLSIGN = "org.rdk.PackageManagerRDKEMS";
exports.PACKAGE_MANAGER_CALLSIGNS = [
"org.rdk.AppPackageManager",
"org.rdk.PackageManagerRDKEMS",
];
exports.APP_MANAGER_CALLSIGN = "org.rdk.AppManager";
exports.STDOUT_TARGET = "-";
exports.TEMP_FILE_SUFFIX = "~";
Expand Down