Skip to content

Commit

Permalink
feat: target Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Feb 18, 2024
1 parent 937ec8b commit ea7b5e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
defaultConfig {
applicationId "xtr.keymapper"
minSdk 28
targetSdk 33
targetSdk 34
versionCode 11
versionName '2.1.1'

Expand Down
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.INTERNET" />


<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -49,7 +51,8 @@

<service
android:name="TouchPointer"
android:enabled="true" />
android:enabled="true"
android:foregroundServiceType="specialUse"/>

<!-- Declares the input method service. -->
<service android:name=".service.InputListenerService"
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/xtr/keymapper/TouchPointer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package xtr.keymapper;

import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
Expand All @@ -10,6 +12,7 @@
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
Expand Down Expand Up @@ -102,7 +105,11 @@ public int onStartCommand(Intent i, int flags, int startId) {
.setSmallIcon(R.mipmap.ic_launcher_foreground)
.setCategory(Notification.CATEGORY_SERVICE)
.build();
startForeground(2, notification);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(2, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
} else {
startForeground(2, notification);
}

if (cursorView == null) showCursor();

Expand Down

0 comments on commit ea7b5e3

Please sign in to comment.