use of im.actor.runtime.power.WakeLock in project actor-platform by actorapp.
the class CallManagerActor method doCall.
//
// Outgoing call
//
private void doCall(final Peer peer, final CommandCallback<Long> callback, boolean isVideoEnabled) {
Log.d(TAG, "doCall (" + peer + ")");
//
if (currentCall != null) {
terminalCall(currentCall);
currentCall = null;
}
//
// Spawning new Actor for call
//
final WakeLock wakeLock = Runtime.makeWakeLock();
system().actorOf("actor/master/" + RandomUtils.nextRid(), () -> {
return new CallActor(peer, callback, wakeLock, isVideoEnabled, context());
});
}
use of im.actor.runtime.power.WakeLock in project actor-platform by actorapp.
the class SenderActor method performSendContent.
// Sending content
private void performSendContent(final Peer peer, final long rid, AbsContent content) {
WakeLock wakeLock = im.actor.runtime.Runtime.makeWakeLock();
ApiMessage message;
if (content instanceof TextContent) {
message = new ApiTextMessage(((TextContent) content).getText(), ((TextContent) content).getMentions(), ((TextContent) content).getTextMessageEx());
} else if (content instanceof DocumentContent) {
DocumentContent documentContent = (DocumentContent) content;
FileRemoteSource source = (FileRemoteSource) documentContent.getSource();
ApiDocumentEx documentEx = null;
if (content instanceof PhotoContent) {
PhotoContent photoContent = (PhotoContent) content;
documentEx = new ApiDocumentExPhoto(photoContent.getW(), photoContent.getH());
} else if (content instanceof VideoContent) {
VideoContent videoContent = (VideoContent) content;
documentEx = new ApiDocumentExVideo(videoContent.getW(), videoContent.getH(), videoContent.getDuration());
} else if (content instanceof AnimationContent) {
AnimationContent animationContent = (AnimationContent) content;
documentEx = new ApiDocumentExAnimation(animationContent.getW(), animationContent.getH());
} else if (content instanceof VoiceContent) {
VoiceContent voiceContent = (VoiceContent) content;
documentEx = new ApiDocumentExVoice(voiceContent.getDuration());
}
ApiFastThumb fastThumb = null;
if (documentContent.getFastThumb() != null) {
fastThumb = new ApiFastThumb(documentContent.getFastThumb().getW(), documentContent.getFastThumb().getH(), documentContent.getFastThumb().getImage());
}
message = new ApiDocumentMessage(source.getFileReference().getFileId(), source.getFileReference().getAccessHash(), source.getFileReference().getFileSize(), source.getFileReference().getFileName(), documentContent.getMimeType(), fastThumb, documentEx);
} else if (content instanceof LocationContent) {
message = new ApiJsonMessage(((LocationContent) content).getRawJson());
} else if (content instanceof ContactContent) {
message = new ApiJsonMessage(((ContactContent) content).getRawJson());
} else if (content instanceof JsonContent) {
message = new ApiJsonMessage(((JsonContent) content).getRawJson());
} else if (content instanceof StickerContent) {
message = ((ContentRemoteContainer) content.getContentContainer()).getMessage();
} else {
return;
}
performSendApiContent(peer, rid, message, wakeLock);
}
use of im.actor.runtime.power.WakeLock in project actor-platform by actorapp.
the class CallManagerActor method onIncomingCall.
//
// Incoming call
//
private void onIncomingCall(final long callId, final int attempt, WakeLock wakeLock) {
Log.d(TAG, "onIncomingCall (" + callId + ")");
//
if (handledCalls.contains(callId)) {
if (handledCallAttempts.get(callId) >= attempt) {
if (wakeLock != null) {
wakeLock.releaseLock();
}
return;
}
}
//
if (runningCalls.containsKey(callId)) {
if (wakeLock != null) {
wakeLock.releaseLock();
}
return;
}
//
// Marking handled calls as handled
//
handledCalls.add(callId);
handledCallAttempts.put(callId, attempt);
//
if (wakeLock == null) {
wakeLock = Runtime.makeWakeLock();
}
//
// Spawning new Actor for call
//
final WakeLock finalWakeLock = wakeLock;
system().actorOf("actor/call" + RandomUtils.nextRid(), () -> {
return new CallActor(callId, finalWakeLock, context());
});
}
Aggregations