Skip to content

Commit

Permalink
fix(android): explicitly define Ti.Android.currentService to be null …
Browse files Browse the repository at this point in the history
…when not a service
  • Loading branch information
sgtcoolguy committed Jan 13, 2021
1 parent 46842aa commit 7ce713c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions common/Resources/ti.internal/kernel/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,20 @@ function bootstrap (global, kroll) {
// On iOS, we don't yet pass in the value, but we do set Ti.App.currentService property beforehand!
// Can we remove the preload stuff in KrollBridge.m to pass along the service instance into this like we do on Andorid?
module.isService = OS_ANDROID ? (activityOrService instanceof Titanium.Service) : Ti.App.currentService !== null;
if (OS_ANDROID && module.isService) {
Object.defineProperty(Ti.Android, 'currentService', {
value: activityOrService,
writable: false,
configurable: true
});
if (OS_ANDROID) {
if (module.isService) {
Object.defineProperty(Ti.Android, 'currentService', {
value: activityOrService,
writable: false,
configurable: true
});
} else {
Object.defineProperty(Ti.Android, 'currentService', {
value: null,
writable: false,
configurable: true
});
}
}

if (!Module.main) {
Expand All @@ -612,9 +620,9 @@ function bootstrap (global, kroll) {
filename = filename.replace('Resources/', '/'); // normalize back to absolute paths (which really are relative to Resources under the hood)
module.load(filename, source);

if (OS_ANDROID && module.isService) {
if (OS_ANDROID) {
Object.defineProperty(Ti.Android, 'currentService', {
value: undefined,
value: null,
writable: false,
configurable: true
});
Expand Down

0 comments on commit 7ce713c

Please sign in to comment.