7 changed files with 202 additions and 0 deletions
@ -0,0 +1,25 @@
|
||||
/* |
||||
* SPDX-FileCopyrightText: 2013, microG Project Team |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
|
||||
apply plugin: 'com.android.application' |
||||
|
||||
dependencies { |
||||
implementation project(':api') |
||||
} |
||||
|
||||
android { |
||||
compileSdkVersion androidCompileSdk |
||||
buildToolsVersion "$androidBuildVersionTools" |
||||
|
||||
defaultConfig { |
||||
minSdkVersion androidMinSdk |
||||
targetSdkVersion androidTargetSdk |
||||
} |
||||
|
||||
compileOptions { |
||||
sourceCompatibility JavaVersion.VERSION_1_8 |
||||
targetCompatibility JavaVersion.VERSION_1_8 |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- |
||||
~ SPDX-FileCopyrightText: 2013, microG Project Team |
||||
~ SPDX-License-Identifier: Apache-2.0 |
||||
--> |
||||
|
||||
<manifest |
||||
package="org.microg.nlp.api.sample" |
||||
android:versionCode="1" |
||||
android:versionName="0.0.1" |
||||
xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
|
||||
<application |
||||
android:allowBackup="false" |
||||
android:label="@string/app_name"> |
||||
|
||||
<service |
||||
android:name=".SampleBackendService" |
||||
android:exported="true" |
||||
android:permission="android.permission.ACCESS_COARSE_LOCATION" |
||||
android:label="NLPV2-Sample"> |
||||
<intent-filter> |
||||
<action android:name="org.microg.nlp.LOCATION_BACKEND" /> |
||||
</intent-filter> |
||||
</service> |
||||
|
||||
<service |
||||
android:name=".SecondSampleService" |
||||
android:exported="true" |
||||
android:permission="android.permission.ACCESS_COARSE_LOCATION" |
||||
android:label="NLPV2-Second"> |
||||
<intent-filter> |
||||
<action android:name="org.microg.nlp.LOCATION_BACKEND" /> |
||||
</intent-filter> |
||||
<meta-data |
||||
android:name="org.microg.nlp.BACKEND_SETTINGS_ACTIVITY" |
||||
android:value="org.microg.nlp.api.sample.SecondSettings" /> |
||||
</service> |
||||
|
||||
<activity |
||||
android:name=".SecondSettings" |
||||
android:exported="true" |
||||
android:label="Second Settings Activity" /> |
||||
|
||||
<service |
||||
android:name=".ThirdSampleService" |
||||
android:exported="true" |
||||
android:permission="android.permission.ACCESS_COARSE_LOCATION" |
||||
android:label="NLPV2-Random"> |
||||
<intent-filter> |
||||
<action android:name="org.microg.nlp.LOCATION_BACKEND" /> |
||||
</intent-filter> |
||||
</service> |
||||
</application> |
||||
</manifest> |
@ -0,0 +1,26 @@
|
||||
/* |
||||
* SPDX-FileCopyrightText: 2013, microG Project Team |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
|
||||
package org.microg.nlp.api.sample; |
||||
|
||||
import android.location.Location; |
||||
import android.util.Log; |
||||
import org.microg.nlp.api.LocationBackendService; |
||||
import org.microg.nlp.api.LocationHelper; |
||||
|
||||
public class SampleBackendService extends LocationBackendService { |
||||
private static final String TAG = SampleBackendService.class.getName(); |
||||
|
||||
@Override |
||||
protected Location update() { |
||||
if (System.currentTimeMillis() % 60000 > 2000) { |
||||
Log.d(TAG, "I decided not to answer now..."); |
||||
return null; |
||||
} |
||||
Location location = LocationHelper.create("sample", 42, 42, 42); |
||||
Log.d(TAG, "I was asked for location and I answer: " + location); |
||||
return location; |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
/* |
||||
* SPDX-FileCopyrightText: 2013, microG Project Team |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
|
||||
package org.microg.nlp.api.sample; |
||||
|
||||
import android.location.Location; |
||||
import android.util.Log; |
||||
import org.microg.nlp.api.LocationBackendService; |
||||
import org.microg.nlp.api.LocationHelper; |
||||
|
||||
public class SecondSampleService extends LocationBackendService { |
||||
private static final String TAG = SecondSampleService.class.getName(); |
||||
|
||||
@Override |
||||
protected Location update() { |
||||
Location location = LocationHelper.create("second-sample", 13, 13, (System.currentTimeMillis() / 1000) % 100); |
||||
Log.d(TAG, "I was asked for location and I answer: " + location); |
||||
return location; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
/* |
||||
* SPDX-FileCopyrightText: 2013, microG Project Team |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
|
||||
package org.microg.nlp.api.sample; |
||||
|
||||
import android.app.Activity; |
||||
import android.os.Bundle; |
||||
|
||||
public class SecondSettings extends Activity { |
||||
public void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
/* |
||||
* SPDX-FileCopyrightText: 2013, microG Project Team |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
|
||||
package org.microg.nlp.api.sample; |
||||
|
||||
import android.location.Location; |
||||
import android.util.Log; |
||||
import org.microg.nlp.api.LocationBackendService; |
||||
import org.microg.nlp.api.LocationHelper; |
||||
|
||||
import java.util.Random; |
||||
|
||||
public class ThirdSampleService extends LocationBackendService { |
||||
private static final String TAG = ThirdSampleService.class.getName(); |
||||
|
||||
private Thread regular; |
||||
private final Random random = new Random(); |
||||
|
||||
@Override |
||||
protected void onOpen() { |
||||
super.onOpen(); |
||||
regular = new Thread(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
synchronized (regular) { |
||||
while (!regular.isInterrupted()) { |
||||
try { |
||||
regular.wait(60000); |
||||
} catch (InterruptedException e) { |
||||
return; |
||||
} |
||||
Location location = LocationHelper.create("random", random.nextDouble() * 90, random.nextDouble() * 90, random.nextFloat() * 90); |
||||
Log.d(TAG, "Just reported: " + location); |
||||
report(location); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
regular.start(); |
||||
} |
||||
|
||||
@Override |
||||
protected void onClose() { |
||||
if (regular != null && regular.isAlive()) { |
||||
regular.interrupt(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- |
||||
~ SPDX-FileCopyrightText: 2013, microG Project Team |
||||
~ SPDX-License-Identifier: Apache-2.0 |
||||
--> |
||||
|
||||
<resources> |
||||
<string name="app_name">NetworkLocationV2-SamplePlugin</string> |
||||
</resources> |
Loading…
Reference in new issue