Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/KdeConnectBroadcastReceiver.java
Show All 37 Lines | 33 | public void onReceive(Context context, Intent intent) { | |||
---|---|---|---|---|---|
38 | 38 | | |||
39 | switch (action) { | 39 | switch (action) { | ||
40 | case Intent.ACTION_PACKAGE_REPLACED: | 40 | case Intent.ACTION_PACKAGE_REPLACED: | ||
41 | Log.i("KdeConnect", "UpdateReceiver"); | 41 | Log.i("KdeConnect", "UpdateReceiver"); | ||
42 | if (!intent.getData().getSchemeSpecificPart().equals(context.getPackageName())) { | 42 | if (!intent.getData().getSchemeSpecificPart().equals(context.getPackageName())) { | ||
43 | Log.i("KdeConnect", "Ignoring, it's not me!"); | 43 | Log.i("KdeConnect", "Ignoring, it's not me!"); | ||
44 | return; | 44 | return; | ||
45 | } | 45 | } | ||
46 | BackgroundService.RunCommand(context, new BackgroundService.InstanceCallback() { | 46 | BackgroundService.RunCommand(context, service -> { | ||
47 | @Override | | |||
48 | public void onServiceStart(BackgroundService service) { | | |||
49 | 47 | | |||
50 | } | | |||
51 | }); | 48 | }); | ||
52 | break; | 49 | break; | ||
53 | case Intent.ACTION_BOOT_COMPLETED: | 50 | case Intent.ACTION_BOOT_COMPLETED: | ||
54 | Log.i("KdeConnect", "KdeConnectBroadcastReceiver"); | 51 | Log.i("KdeConnect", "KdeConnectBroadcastReceiver"); | ||
55 | BackgroundService.RunCommand(context, new BackgroundService.InstanceCallback() { | 52 | BackgroundService.RunCommand(context, service -> { | ||
56 | @Override | | |||
57 | public void onServiceStart(BackgroundService service) { | | |||
58 | 53 | | |||
59 | } | | |||
60 | }); | 54 | }); | ||
61 | break; | 55 | break; | ||
62 | case WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION: | 56 | case WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION: | ||
63 | case WifiManager.WIFI_STATE_CHANGED_ACTION: | 57 | case WifiManager.WIFI_STATE_CHANGED_ACTION: | ||
64 | case ConnectivityManager.CONNECTIVITY_ACTION: | 58 | case ConnectivityManager.CONNECTIVITY_ACTION: | ||
65 | Log.i("KdeConnect", "Connection state changed, trying to connect"); | 59 | Log.i("KdeConnect", "Connection state changed, trying to connect"); | ||
66 | BackgroundService.RunCommand(context, new BackgroundService.InstanceCallback() { | 60 | BackgroundService.RunCommand(context, service -> { | ||
67 | @Override | | |||
68 | public void onServiceStart(BackgroundService service) { | | |||
69 | service.onDeviceListChanged(); | 61 | service.onDeviceListChanged(); | ||
70 | service.onNetworkChange(); | 62 | service.onNetworkChange(); | ||
71 | } | | |||
72 | }); | 63 | }); | ||
73 | break; | 64 | break; | ||
74 | case Intent.ACTION_SCREEN_ON: | 65 | case Intent.ACTION_SCREEN_ON: | ||
75 | BackgroundService.RunCommand(context, new BackgroundService.InstanceCallback() { | 66 | BackgroundService.RunCommand(context, BackgroundService::onNetworkChange); | ||
76 | @Override | | |||
77 | public void onServiceStart(BackgroundService service) { | | |||
78 | service.onNetworkChange(); | | |||
79 | } | | |||
80 | }); | | |||
81 | break; | 67 | break; | ||
82 | default: | 68 | default: | ||
83 | Log.i("BroadcastReceiver", "Ignoring broadcast event: " + intent.getAction()); | 69 | Log.i("BroadcastReceiver", "Ignoring broadcast event: " + intent.getAction()); | ||
84 | break; | 70 | break; | ||
85 | } | 71 | } | ||
86 | 72 | | |||
87 | } | 73 | } | ||
88 | 74 | | |||
89 | 75 | | |||
90 | } | 76 | } |