diff --git a/OpenPods/app/build.gradle b/OpenPods/app/build.gradle
index 72a9e99..82acc0f 100644
--- a/OpenPods/app/build.gradle
+++ b/OpenPods/app/build.gradle
@@ -5,9 +5,9 @@ android {
defaultConfig {
applicationId "com.dosse.airpods"
minSdkVersion 23
- targetSdkVersion 28
- versionCode 8
- versionName '0.8'
+ targetSdkVersion 23
+ versionCode 9
+ versionName '0.9'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
diff --git a/OpenPods/app/src/main/AndroidManifest.xml b/OpenPods/app/src/main/AndroidManifest.xml
index fa0a6bf..dc772b7 100644
--- a/OpenPods/app/src/main/AndroidManifest.xml
+++ b/OpenPods/app/src/main/AndroidManifest.xml
@@ -7,6 +7,7 @@
+
=Build.VERSION_CODES.P){
+ LocationManager service = (LocationManager) getSystemService(getApplicationContext().LOCATION_SERVICE);
+ return service!=null&&service.isLocationEnabled();
+ }else{
+ try {
+ return Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE) != Settings.Secure.LOCATION_MODE_OFF;
+ }catch(Throwable t){
+ return true;
+ }
+ }
}
- public void run(){
- boolean notificationShowing=false;
- RemoteViews notificationBig=new RemoteViews(getPackageName(),R.layout.status_big);
- RemoteViews notificationSmall=new RemoteViews(getPackageName(),R.layout.status_small);
- RemoteViews locationDisabledBig=new RemoteViews(getPackageName(),R.layout.location_disabled_big);
- RemoteViews locationDisabledSmall=new RemoteViews(getPackageName(),R.layout.location_disabled_small);
- NotificationManager mNotifyManager=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- NotificationCompat.Builder mBuilder=new NotificationCompat.Builder(PodsService.this,TAG);
+ private NotificationManager mNotifyManager;
+ public NotificationThread(){
+ mNotifyManager=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { //on oreo and newer, create a notification channel
NotificationChannel channel = new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW);
channel.enableVibration(false);
@@ -220,6 +224,14 @@ public class PodsService extends Service {
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mNotifyManager.createNotificationChannel(channel);
}
+ }
+ public void run(){
+ boolean notificationShowing=false;
+ RemoteViews notificationBig=new RemoteViews(getPackageName(),R.layout.status_big);
+ RemoteViews notificationSmall=new RemoteViews(getPackageName(),R.layout.status_small);
+ RemoteViews locationDisabledBig=new RemoteViews(getPackageName(),R.layout.location_disabled_big);
+ RemoteViews locationDisabledSmall=new RemoteViews(getPackageName(),R.layout.location_disabled_small);
+ NotificationCompat.Builder mBuilder=new NotificationCompat.Builder(PodsService.this,TAG);
mBuilder.setShowWhen(false);
mBuilder.setOngoing(true);
mBuilder.setSmallIcon(R.mipmap.notification_icon);
@@ -321,6 +333,9 @@ public class PodsService extends Service {
intentFilter.addAction("android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED");
intentFilter.addAction("android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED");
intentFilter.addCategory("android.bluetooth.headset.intent.category.companyid.76");
+ try{
+ unregisterReceiver(btReceiver);
+ }catch (Throwable t){}
btReceiver=new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -352,9 +367,6 @@ public class PodsService extends Service {
}
}
};
- try{
- unregisterReceiver(btReceiver);
- }catch (Throwable t){}
try{
registerReceiver(btReceiver,intentFilter);
}catch(Throwable t){}
@@ -418,5 +430,4 @@ public class PodsService extends Service {
return START_STICKY;
}
-
}
diff --git a/OpenPods/app/src/main/java/com/dosse/airpods/Starter.java b/OpenPods/app/src/main/java/com/dosse/airpods/Starter.java
index 7536b5d..9348696 100644
--- a/OpenPods/app/src/main/java/com/dosse/airpods/Starter.java
+++ b/OpenPods/app/src/main/java/com/dosse/airpods/Starter.java
@@ -3,6 +3,7 @@ package com.dosse.airpods;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.os.Build;
import android.util.Log;
/**
@@ -11,6 +12,10 @@ import android.util.Log;
public class Starter extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- context.startService(new Intent(context,PodsService.class));
+ startPodsService(context);
+ }
+
+ public static final void startPodsService(Context context){
+ context.startService(new Intent(context, PodsService.class));
}
}