Skip to content

Commit

Permalink
Fix crash when starting collector on Android 13+ without proper permi…
Browse files Browse the repository at this point in the history
…ssions.
  • Loading branch information
zamojski committed Nov 27, 2024
1 parent 5f232e3 commit 9b3f4d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
10 changes: 7 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand Down Expand Up @@ -89,7 +90,8 @@
android:exported="true"
android:icon="@drawable/ic_quicksettings_collector_start"
android:label="@string/quicksettings_collecting_start"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
tools:targetApi="n">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
Expand All @@ -103,7 +105,8 @@
android:exported="true"
android:icon="@drawable/ic_quicksettings_uploader_start"
android:label="@string/quicksettings_upload_start"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
tools:targetApi="n">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
Expand All @@ -117,7 +120,8 @@
android:exported="true"
android:icon="@drawable/ic_quicksettings_export_start"
android:label="@string/quicksettings_export_start"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
tools:targetApi="n">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ private void startCollectorServiceWithCheck() {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@NeedsPermission({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE})
@NeedsPermission({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void startCollectorServiceApi33() {
startCollectorServiceInternal();
}
Expand Down Expand Up @@ -921,7 +921,7 @@ private void startCollectorServiceInternal() {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@OnShowRationale({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE})
@OnShowRationale({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void onStartCollectorShowRationaleApi33(PermissionRequest request) {
onStartCollectorShowRationaleInternal(request);
}
Expand All @@ -936,7 +936,7 @@ private void onStartCollectorShowRationaleInternal(PermissionRequest request) {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@OnPermissionDenied({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE})
@OnPermissionDenied({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void onStartCollectorPermissionDeniedApi33() {
onStartCollectorPermissionDeniedInternal();
}
Expand All @@ -951,7 +951,7 @@ private void onStartCollectorPermissionDeniedInternal() {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@OnNeverAskAgain({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE})
@OnNeverAskAgain({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void onStartCollectorNeverAskAgainApi33() {
onStartCollectorNeverAskAgainInternal();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void setupCollectorKeepScreenOnDialog() {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@NeedsPermission({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.READ_PHONE_STATE})
@NeedsPermission({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void requestStartAtBootApi33() {
requestStartAtBootInternal();
}
Expand All @@ -184,7 +184,7 @@ private void requestStartAtBootInternal() {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@OnShowRationale({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.READ_PHONE_STATE})
@OnShowRationale({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void onStartAtBootRationaleApi33(final PermissionRequest request) {
onStartAtBootRationaleInternal(request);
}
Expand Down Expand Up @@ -227,7 +227,7 @@ public void onClick(DialogInterface dialog, int which) {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@OnPermissionDenied({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.READ_PHONE_STATE})
@OnPermissionDenied({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void onStartAtBootPermissionDeniedApi33() {
onStartAtBootPermissionDeniedInternal();
}
Expand All @@ -249,7 +249,7 @@ private void onStartAtBootPermissionDeniedInternal() {
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
@OnNeverAskAgain({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.READ_PHONE_STATE})
@OnNeverAskAgain({Manifest.permission.POST_NOTIFICATIONS, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.FOREGROUND_SERVICE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void onStartAtBootNeverAskAgainApi33() {
onStartAtBootNeverAskAgainInternal();
}
Expand Down

0 comments on commit 9b3f4d6

Please sign in to comment.