File indexing completed on 2024-12-22 04:41:38
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Albert Vaca Cintora <albertvaka@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 package org.kde.kdeconnect.Backends.LoopbackBackend; 0008 0009 import android.content.Context; 0010 0011 import androidx.annotation.NonNull; 0012 import androidx.annotation.WorkerThread; 0013 0014 import org.kde.kdeconnect.Backends.BaseLink; 0015 import org.kde.kdeconnect.Backends.BaseLinkProvider; 0016 import org.kde.kdeconnect.Device; 0017 import org.kde.kdeconnect.DeviceInfo; 0018 import org.kde.kdeconnect.Helpers.DeviceHelper; 0019 import org.kde.kdeconnect.NetworkPacket; 0020 0021 public class LoopbackLink extends BaseLink { 0022 0023 public LoopbackLink(Context context, BaseLinkProvider linkProvider) { 0024 super(context, linkProvider); 0025 } 0026 0027 @Override 0028 public String getName() { 0029 return "LoopbackLink"; 0030 } 0031 0032 @WorkerThread 0033 @Override 0034 public boolean sendPacket(@NonNull NetworkPacket in, @NonNull Device.SendPacketStatusCallback callback, boolean sendPayloadFromSameThread) { 0035 packetReceived(in); 0036 if (in.hasPayload()) { 0037 callback.onPayloadProgressChanged(0); 0038 in.setPayload(in.getPayload()); 0039 callback.onPayloadProgressChanged(100); 0040 } 0041 callback.onSuccess(); 0042 return true; 0043 } 0044 0045 @Override 0046 public DeviceInfo getDeviceInfo() { 0047 return DeviceHelper.getDeviceInfo(context); 0048 } 0049 0050 }