13 Commits
21 changed files with 97 additions and 21 deletions
+2 -2
View File
@@ -6,8 +6,8 @@ android {
applicationId "com.dosse.airpods" applicationId "com.dosse.airpods"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 23 targetSdkVersion 23
versionCode 11 versionCode 13
versionName '1.0' versionName '1.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
@@ -37,7 +37,7 @@ import java.util.List;
/** /**
* This is the class that does most of the work. It has 3 functions: * This is the class that does most of the work. It has 3 functions:
* - Detect when AirPods are detected * - Detect when AirPods are detected
* - Receive beacons from AirPods and decode them (easier said than done thanks do google's autism) * - Receive beacons from AirPods and decode them (easier said than done thanks to google's autism)
* - Display the notification with the status * - Display the notification with the status
* *
*/ */
@@ -47,6 +47,8 @@ public class PodsService extends Service {
private static BluetoothLeScanner btScanner; private static BluetoothLeScanner btScanner;
private static int leftStatus=15, rightStatus=15, caseStatus=15; private static int leftStatus=15, rightStatus=15, caseStatus=15;
private static boolean chargeL=false, chargeR=false, chargeCase=false; private static boolean chargeL=false, chargeR=false, chargeCase=false;
private static final String MODEL_AIRPODS_NORMAL="airpods12", MODEL_AIRPODS_PRO="airpodspro";
private static String model=MODEL_AIRPODS_NORMAL;
/** /**
* The following method (startAirPodsScanner) creates a bluetoth LE scanner. * The following method (startAirPodsScanner) creates a bluetoth LE scanner.
@@ -70,6 +72,7 @@ public class PodsService extends Service {
* - The 12th and 13th characters in the string represent the charge of the left and right pods. Under unknown circumstances, they are right and left instead (see isFlipped). Values between 0 and 10 are battery 0-100%; Value 15 means it's disconnected * - The 12th and 13th characters in the string represent the charge of the left and right pods. Under unknown circumstances, they are right and left instead (see isFlipped). Values between 0 and 10 are battery 0-100%; Value 15 means it's disconnected
* - The 15th character in the string represents the charge of the case. Values between 0 and 10 are battery 0-100%; Value 15 means it's disconnected * - The 15th character in the string represents the charge of the case. Values between 0 and 10 are battery 0-100%; Value 15 means it's disconnected
* - The 14th character in the string represents the "in charge" status. Bit 0 (LSB) is the left pod; Bit 1 is the right pod; Bit 2 is the case. Bit 3 might be case open/closed but I'm not sure and it's not used * - The 14th character in the string represents the "in charge" status. Bit 0 (LSB) is the left pod; Bit 1 is the right pod; Bit 2 is the case. Bit 3 might be case open/closed but I'm not sure and it's not used
* - The 7th character in the string represents the AirPods model (E=AirPods pro)
* *
* After decoding a beacon, the status is written to leftStatus, rightStatus, caseStatus, chargeL, chargeR, chargeCase so that the NotificationThread can use the information * After decoding a beacon, the status is written to leftStatus, rightStatus, caseStatus, chargeL, chargeR, chargeCase so that the NotificationThread can use the information
* *
@@ -151,6 +154,7 @@ public class PodsService extends Service {
chargeL = (chargeStatus & 0b00000001) != 0; chargeL = (chargeStatus & 0b00000001) != 0;
chargeR = (chargeStatus & 0b00000010) != 0; chargeR = (chargeStatus & 0b00000010) != 0;
chargeCase = (chargeStatus & 0b00000100) != 0; chargeCase = (chargeStatus & 0b00000100) != 0;
if(a.charAt(7)=='E') model = MODEL_AIRPODS_PRO; else model = MODEL_AIRPODS_NORMAL; //detect if these are AirPods pro or regular ones
lastSeenConnected = System.currentTimeMillis(); lastSeenConnected = System.currentTimeMillis();
} catch (Throwable t) { } catch (Throwable t) {
if(ENABLE_LOGGING) Log.d(TAG, "" + t); if(ENABLE_LOGGING) Log.d(TAG, "" + t);
@@ -276,10 +280,22 @@ public class PodsService extends Service {
mBuilder.setCustomBigContentView(locationDisabledBig); mBuilder.setCustomBigContentView(locationDisabledBig);
} }
if(notificationShowing){ if(notificationShowing){
if(ENABLE_LOGGING) Log.d(TAG,"Left: "+leftStatus+(chargeL?"+":"")+" "+"Right: "+rightStatus+(chargeR?"+":"")+" "+"Case: "+caseStatus+(chargeCase?"+":"")); if(ENABLE_LOGGING) Log.d(TAG,"Left: "+leftStatus+(chargeL?"+":"")+" "+"Right: "+rightStatus+(chargeR?"+":"")+" "+"Case: "+caseStatus+(chargeCase?"+":"")+" "+"Model: "+model);
notificationBig.setImageViewResource(R.id.leftPodImg,leftStatus<=10?R.drawable.left_pod:R.drawable.left_pod_disconnected); if(model.equals(MODEL_AIRPODS_NORMAL)){
notificationBig.setImageViewResource(R.id.rightPodImg,rightStatus<=10?R.drawable.right_pod:R.drawable.right_pod_disconnected); notificationBig.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_pod : R.drawable.left_pod_disconnected);
notificationBig.setImageViewResource(R.id.podCaseImg,caseStatus<=10?R.drawable.pod_case:R.drawable.pod_case_disconnected); notificationBig.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_pod : R.drawable.right_pod_disconnected);
notificationBig.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.pod_case : R.drawable.pod_case_disconnected);
notificationSmall.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_pod : R.drawable.left_pod_disconnected);
notificationSmall.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_pod : R.drawable.right_pod_disconnected);
notificationSmall.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.pod_case : R.drawable.pod_case_disconnected);
}else if(model.equals(MODEL_AIRPODS_PRO)){
notificationBig.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_podpro : R.drawable.left_podpro_disconnected);
notificationBig.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_podpro : R.drawable.right_podpro_disconnected);
notificationBig.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.podpro_case : R.drawable.podpro_case_disconnected);
notificationSmall.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_podpro : R.drawable.left_podpro_disconnected);
notificationSmall.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_podpro : R.drawable.right_podpro_disconnected);
notificationSmall.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.podpro_case : R.drawable.podpro_case_disconnected);
}
if(System.currentTimeMillis()-lastSeenConnected<TIMEOUT_CONNECTED) { if(System.currentTimeMillis()-lastSeenConnected<TIMEOUT_CONNECTED) {
notificationBig.setViewVisibility(R.id.leftPodText, View.VISIBLE); notificationBig.setViewVisibility(R.id.leftPodText, View.VISIBLE);
notificationBig.setViewVisibility(R.id.rightPodText, View.VISIBLE); notificationBig.setViewVisibility(R.id.rightPodText, View.VISIBLE);
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@@ -4,6 +4,7 @@
android:layout_height="120dp" android:layout_height="120dp"
android:padding="12dp" android:padding="12dp"
android:gravity="center" android:gravity="center"
android:background="@color/white"
> >
<TextView <TextView
@@ -11,6 +12,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:text="@string/locationDisabledText" android:text="@string/locationDisabledText"
android:textColor="@color/black"
/> />
</RelativeLayout> </RelativeLayout>
@@ -4,6 +4,7 @@
android:layout_height="70dp" android:layout_height="70dp"
android:padding="12dp" android:padding="12dp"
android:gravity="center" android:gravity="center"
android:background="@color/white"
> >
<TextView <TextView
@@ -11,6 +12,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:text="@string/locationDisabledText" android:text="@string/locationDisabledText"
android:textColor="@color/black"
/> />
</RelativeLayout> </RelativeLayout>
@@ -17,11 +17,12 @@
> >
<ImageView <ImageView
android:layout_width="30dp" android:layout_width="40dp"
android:layout_height="90dp" android:layout_height="90dp"
android:src="@drawable/left_pod" android:src="@drawable/left_pod"
android:id="@+id/leftPodImg" android:id="@+id/leftPodImg"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginBottom="6dp"
/> />
<TextView <TextView
@@ -55,10 +56,12 @@
<ImageView <ImageView
android:id="@+id/rightPodImg" android:id="@+id/rightPodImg"
android:layout_width="30dp" android:layout_width="40dp"
android:layout_height="90dp" android:layout_height="90dp"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:src="@drawable/right_pod" /> android:src="@drawable/right_pod"
android:layout_marginBottom="6dp"
/>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -91,10 +94,12 @@
<ImageView <ImageView
android:id="@+id/podCaseImg" android:id="@+id/podCaseImg"
android:layout_width="60dp" android:layout_width="80dp"
android:layout_height="90dp" android:layout_height="90dp"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:src="@drawable/pod_case" /> android:src="@drawable/pod_case"
android:layout_marginBottom="6dp"
/>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -16,7 +16,7 @@
> >
<ImageView <ImageView
android:layout_width="15dp" android:layout_width="18dp"
android:layout_height="30dp" android:layout_height="30dp"
android:src="@drawable/left_pod" android:src="@drawable/left_pod"
android:id="@+id/leftPodImg" android:id="@+id/leftPodImg"
@@ -53,7 +53,7 @@
> >
<ImageView <ImageView
android:layout_width="15dp" android:layout_width="18dp"
android:layout_height="30dp" android:layout_height="30dp"
android:src="@drawable/right_pod" android:src="@drawable/right_pod"
android:id="@+id/rightPodImg" android:id="@+id/rightPodImg"
@@ -90,7 +90,7 @@
> >
<ImageView <ImageView
android:layout_width="20dp" android:layout_width="25dp"
android:layout_height="30dp" android:layout_height="30dp"
android:src="@drawable/pod_case" android:src="@drawable/pod_case"
android:id="@+id/podCaseImg" android:id="@+id/podCaseImg"
@@ -9,7 +9,7 @@
<string name="noBtText">Es sieht so aus als hätte dieses Gerät kein Bluetooth LE</string> <string name="noBtText">Es sieht so aus als hätte dieses Gerät kein Bluetooth LE</string>
<string name="locationDisabledText">Du musst Standortinformationen aktivieren, damit OpenPods den Status deiner AirPods auslesen kann</string> <string name="locationDisabledText">Du musst Standortinformationen aktivieren, damit OpenPods den Status deiner AirPods auslesen kann</string>
<string name="supportedDevices">Unterstützte Geräte:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen</string> <string name="supportedDevices">Unterstützte Geräte:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen\n&#8226; Apple AirPods Pro</string>
<string name="hide">App verstecken</string> <string name="hide">App verstecken</string>
<string name="hideClicked">Das Icon wird bald verschwinden</string> <string name="hideClicked">Das Icon wird bald verschwinden</string>
@@ -8,7 +8,7 @@
<string name="noBtText">Parece que éste dispositivo no tiene Bluetooth LE.</string> <string name="noBtText">Parece que éste dispositivo no tiene Bluetooth LE.</string>
<string name="locationDisabledText">Necesitas activar la Localización para permitir que OpenPods lea el estado.</string> <string name="locationDisabledText">Necesitas activar la Localización para permitir que OpenPods lea el estado.</string>
<string name="supportedDevices">Dispositivos compatibles:\n&#8226; Apple AirPods 1ª generación\n&#8226; Apple AirPods 2ª generación</string> <string name="supportedDevices">Dispositivos compatibles:\n&#8226; Apple AirPods 1ª generación\n&#8226; Apple AirPods 2ª generación\n&#8226; Apple AirPods Pro</string>
<string name="hide">Ocultar app</string> <string name="hide">Ocultar app</string>
<string name="hideClicked">El icono desaparecerá pronto</string> <string name="hideClicked">El icono desaparecerá pronto</string>
@@ -9,7 +9,7 @@
<string name="noBtText">Questo dispositivo non supporta Bluetooth LE</string> <string name="noBtText">Questo dispositivo non supporta Bluetooth LE</string>
<string name="locationDisabledText">Attiva la posizione per permttere a OpenPods di leggere lo stato</string> <string name="locationDisabledText">Attiva la posizione per permttere a OpenPods di leggere lo stato</string>
<string name="supportedDevices">Dispositivi supportati:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen</string> <string name="supportedDevices">Dispositivi supportati:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen\n&#8226; Apple AirPods Pro</string>
<string name="hide">Nascondi app</string> <string name="hide">Nascondi app</string>
<string name="hideClicked">L\'icona sarà rimossa presto</string> <string name="hideClicked">L\'icona sarà rimossa presto</string>
@@ -0,0 +1,24 @@
<resources>
<string name="intro1">Это приложение позволяет Вам проверить статус ваших AirPods на любом Android-устройстве</string>
<string name="intro2">Для работы нам нужно Bluetooth LE(местоположение) и разрешение на запуск в фоновом режиме</string>
<string name="introAllow">Разрешить</string>
<string name="main1">Приложение покажет уведомление, когда будет установлено соединение с AirPods</string>
<string name="main2">Вы можете скрыть это приложение, если хотите</string>
<string name="settings">Настройки</string>
<string name="noBtText">Похоже, что Bluetooth LE не поддерживается на Вашем устройстве</string>
<string name="locationDisabledText">Вам нужно включить местоположение, чтобы разрешить OpenPods читать статус</string>
<string name="supportedDevices">Поддерживаемые устройства:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen\n&#8226; Apple AirPods Pro</string>
<string name="hide">Скрыть приложение</string>
<string name="hideClicked">Иконка скоро исчезнет</string>
<string name="batterySaver">Режим энергосбережения (Не рекомендуется)</string>
<string name="batterySaver_desc">Включите, если Bluetooth использует слишком много ресурсов</string>
<string name="about">О приложении</string>
<string name="about1">Разработано Federico Dossena</string>
<string name="website">Сайт</string>
<string name="github">Github</string>
<string name="donate">Поддержать</string>
</resources>
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">OpenPods</string>
<string name="intro1">Цей додаток дозволяє Вам перевірити статус ваших AirPods на будь-якому Android-пристрої</string>
<string name="intro2">Для роботи ми використовуємо Bluetooth LE (місцезнаходження) та дозвіл на роботу додатку в фоновому режимі</string>
<string name="introAllow">Дозволити</string>
<string name="main1">Цей додаток покаже сповіщення, коли Ваші AirPods будуть підключені</string>
<string name="main2">Ви можете сховати цей додаток, якщо бажаєте</string>
<string name="settings">Налаштування</string>
<string name="noBtText">Схоже, що цей пристрій не підтримує Bluetooth LE</string>
<string name="locationDisabledText">Вам потрібно ввімкнути місцезнаходження, для того, щоб дозволити OpenPods читати статус</string>
<string name="supportedDevices">Supported devices:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen\n&#8226; Apple AirPods Pro</string>
<string name="hide">Сховати додаток</string>
<string name="hideClicked">Іконка скоро зникне</string>
<string name="batterySaver">Режим збереження енергії (Не рекомендовано)</string>
<string name="batterySaver_desc">Увімкніть, якщо Bluetooth використовує багато ресурсів</string>
<string name="about">Про програму</string>
<string name="about1">Розроблено Federico Dossena</string>
<string name="website">Сайт</string>
<string name="github">Github</string>
<string name="donate">Підтримати</string>
</resources>
@@ -9,7 +9,7 @@
<string name="noBtText">看起来您的设备并不支持蓝牙</string> <string name="noBtText">看起来您的设备并不支持蓝牙</string>
<string name="locationDisabledText">您需要开启定位来让 OpenPods 读取状态</string> <string name="locationDisabledText">您需要开启定位来让 OpenPods 读取状态</string>
<string name="supportedDevices">支持的设备:\n&#8226; Apple AirPods 一代\n&#8226; Apple AirPods 二代</string> <string name="supportedDevices">支持的设备:\n&#8226; Apple AirPods 一代\n&#8226; Apple AirPods 二代\n&#8226; Apple AirPods Pro</string>
<string name="hide">隐藏</string> <string name="hide">隐藏</string>
<string name="hideClicked">桌面图标很快就会被隐藏掉</string> <string name="hideClicked">桌面图标很快就会被隐藏掉</string>
+1 -1
View File
@@ -9,7 +9,7 @@
<string name="noBtText">It looks like this device doesn\'t have Bluetooth LE</string> <string name="noBtText">It looks like this device doesn\'t have Bluetooth LE</string>
<string name="locationDisabledText">You need to turn on Location to allow OpenPods to read the status</string> <string name="locationDisabledText">You need to turn on Location to allow OpenPods to read the status</string>
<string name="supportedDevices">Supported devices:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen</string> <string name="supportedDevices">Supported devices:\n&#8226; Apple AirPods 1st gen\n&#8226; Apple AirPods 2nd gen\n&#8226; Apple AirPods Pro</string>
<string name="hide">Hide app</string> <string name="hide">Hide app</string>
<string name="hideClicked">The icon will disappear soon</string> <string name="hideClicked">The icon will disappear soon</string>
+1 -1
View File
@@ -7,7 +7,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.1' classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
+1
View File
@@ -15,6 +15,7 @@ The Free and Open Source app for monitoring your AirPods on Android
## Supported devices ## Supported devices
* Apple AirPods 1st gen * Apple AirPods 1st gen
* Apple AirPods 2nd gen * Apple AirPods 2nd gen
* Apple AirPods Pro
## DO NOT REUPLOAD TO GOOGLE PLAY ## DO NOT REUPLOAD TO GOOGLE PLAY
**This app violates Google Play policies and is designed to break if you try to fix that unless you really know what you're doing.** You have been warned. I do NOT want this app to be on Google Play. **This app violates Google Play policies and is designed to break if you try to fix that unless you really know what you're doing.** You have been warned. I do NOT want this app to be on Google Play.