2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 21:55:10 +00:00

Remove gui counters logic

It had bugs and was never used. I've left in the Discovery Mode logic
because we might want to expose that somehow like GSConnect does.
This commit is contained in:
Albert Vaca
2019-06-27 10:40:10 -04:00
parent 5659812428
commit 47c2483d53
11 changed files with 4 additions and 100 deletions

View File

@@ -100,24 +100,9 @@ public class BackgroundService extends Service {
}
}
public static void addGuiInUseCounter(Context activity) {
addGuiInUseCounter(activity, false);
}
public static void addGuiInUseCounter(final Context activity, final boolean forceNetworkRefresh) {
BackgroundService.RunCommand(activity, service -> {
boolean refreshed = service.acquireDiscoveryMode(activity);
if (!refreshed && forceNetworkRefresh) {
service.onNetworkChange();
}
});
}
public static void removeGuiInUseCounter(final Context activity) {
BackgroundService.RunCommand(activity, service -> {
//If no user interface is open, close the connections open to other devices
service.releaseDiscoveryMode(activity);
});
private boolean isInDiscoveryMode() {
//return !discoveryModeAcquisitions.isEmpty();
return true; // Keep it always on for now
}
private final Device.PairingCallback devicePairingCallback = new Device.PairingCallback() {
@@ -209,7 +194,7 @@ public class BackgroundService extends Service {
device = new Device(BackgroundService.this, identityPacket, link);
if (device.isPaired() || device.isPairRequested() || device.isPairRequestedByPeer()
|| link.linkShouldBeKeptAlive()
|| !discoveryModeAcquisitions.isEmpty()) {
|| isInDiscoveryMode()) {
devices.put(deviceId, device);
device.addPairingCallback(devicePairingCallback);
} else {

View File

@@ -401,14 +401,11 @@ public class Device implements BaseLink.PacketReceiver {
.build();
NotificationHelper.notifyCompat(notificationManager, notificationId, noti);
BackgroundService.addGuiInUseCounter(context);
}
public void hidePairingNotification() {
final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(notificationId);
BackgroundService.removeGuiInUseCounter(context);
}
//

View File

@@ -373,17 +373,5 @@ public class MousePadActivity extends AppCompatActivity implements GestureDetect
imm.toggleSoftInputFromWindow(keyListenerView.getWindowToken(), 0, 0);
}
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
}
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
}
}

View File

@@ -445,16 +445,4 @@ public class MprisActivity extends AppCompatActivity {
nowPlayingText.setSelected(true);
}
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
}
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
}
}

View File

@@ -218,18 +218,6 @@ public class NotificationFilterActivity extends AppCompatActivity {
}
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
}
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
}
private Drawable resizeIcon(Drawable icon, int maxSize) {
Resources res = getResources();

View File

@@ -82,7 +82,6 @@ public class PresenterActivity extends AppCompatActivity {
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
if (mMediaSession != null) {
mMediaSession.setActive(true);
return;
@@ -93,7 +92,6 @@ public class PresenterActivity extends AppCompatActivity {
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
if (mMediaSession != null) {
PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);

View File

@@ -153,7 +153,6 @@ public class ShareActivity extends AppCompatActivity {
});
} else {
BackgroundService.addGuiInUseCounter(this);
BackgroundService.RunCommand(this, service -> {
service.onNetworkChange();
service.addDeviceListChangedCallback("ShareActivity", this::updateComputerList);
@@ -166,7 +165,6 @@ public class ShareActivity extends AppCompatActivity {
@Override
protected void onStop() {
BackgroundService.RunCommand(this, service -> service.removeDeviceListChangedCallback("ShareActivity"));
BackgroundService.removeGuiInUseCounter(this);
super.onStop();
}

View File

@@ -127,18 +127,5 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
return mDelegate;
}
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
}
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
getDelegate().onStop();
}
}

View File

@@ -167,18 +167,6 @@ public class CustomDevicesActivity extends AppCompatActivity implements CustomDe
return deserializeIpList(deviceListPrefs);
}
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
}
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
}
@Override
public void onCustomDeviceClicked(String customDevice) {
editingDeviceAtPosition = customDeviceList.indexOf(customDevice);

View File

@@ -284,14 +284,12 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this, true);
BackgroundService.RunCommand(this, service -> service.addDeviceListChangedCallback("MainActivity", this::updateDeviceList));
updateDeviceList();
}
@Override
protected void onStop() {
BackgroundService.removeGuiInUseCounter(this);
BackgroundService.RunCommand(this, service -> service.removeDeviceListChangedCallback("MainActivity"));
super.onStop();
}

View File

@@ -96,17 +96,6 @@ public class PluginSettingsActivity
return super.onOptionsItemSelected(item);
}
@Override
protected void onStart() {
super.onStart();
BackgroundService.addGuiInUseCounter(this);
}
@Override
protected void onStop() {
super.onStop();
BackgroundService.removeGuiInUseCounter(this);
}
@Override
public void onStartPluginSettingsFragment(Plugin plugin) {