Merge pull request #3533 from nextcloud/chore/noid/Android14

🤖Android 1️⃣4️⃣
This commit is contained in:
Marcel Hibbe 2024-01-31 12:01:00 +01:00 committed by GitHub
commit f75d98c573
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 120 additions and 12 deletions

View file

@ -43,7 +43,7 @@ android {
defaultConfig {
minSdkVersion 24
targetSdkVersion 33
targetSdkVersion 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// mayor.minor.hotfix.increment (for increment: 01-50=Alpha / 51-89=RC / 90-99=stable)

View file

@ -13,6 +13,12 @@
<issue id="UnusedResources">
<ignore path="**/values-**/strings.xml" />
</issue>
<issue id="MissingQuantity">
<ignore path="**/values-ka-rGE/strings.xml"/>
<ignore path="**/values-ar/strings.xml" />
<ignore path="**/values-ca/strings.xml" />
</issue>
<issue id="TypographyEllipsis">
<ignore path="**/values-**/strings.xml" />

View file

@ -23,6 +23,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<application
android:name=".application.NextcloudTalkApplication"
android:allowBackup="true"
@ -40,8 +42,7 @@
<service
android:name=".services.firebase.NCFirebaseMessagingService"
android:exported="false"
android:foregroundServiceType="phoneCall">
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>

View file

@ -113,6 +113,7 @@ import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.NotificationUtils.cancelExistingNotificationsForRoom
import com.nextcloud.talk.utils.NotificationUtils.getCallRingtoneUri
import com.nextcloud.talk.utils.ReceiverFlag
import com.nextcloud.talk.utils.VibrationUtils.vibrateShort
import com.nextcloud.talk.utils.animations.PulseAnimation
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CALL_VOICE_ONLY
@ -136,6 +137,7 @@ import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isCallRecordin
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
import com.nextcloud.talk.utils.power.PowerManagerUtils
import com.nextcloud.talk.utils.registerPermissionHandlerBroadcastReceiver
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
import com.nextcloud.talk.viewmodels.CallRecordingViewModel
import com.nextcloud.talk.viewmodels.CallRecordingViewModel.RecordingConfirmStopState
@ -3015,11 +3017,12 @@ class CallActivity : CallBaseActivity() {
}
}
}
registerReceiver(
registerPermissionHandlerBroadcastReceiver(
mReceiver,
IntentFilter(MICROPHONE_PIP_INTENT_NAME),
permissionUtil!!.privateBroadcastPermission,
null
null,
ReceiverFlag.NotExported
)
updateUiForPipMode()
} else {

View file

@ -0,0 +1,54 @@
/*
* Nextcloud Android client application
*
* @author Alper Ozturk
* Copyright (C) 2023 Alper Ozturk
* Copyright (C) 2023 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.utils
import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.os.Handler
@SuppressLint("UnspecifiedRegisterReceiverFlag")
fun Context.registerBroadcastReceiver(receiver: BroadcastReceiver?, filter: IntentFilter, flag: ReceiverFlag): Intent? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(receiver, filter, flag.getId())
} else {
registerReceiver(receiver, filter)
}
}
@SuppressLint("UnspecifiedRegisterReceiverFlag")
fun Context.registerPermissionHandlerBroadcastReceiver(
receiver: BroadcastReceiver?,
filter: IntentFilter,
broadcastPermission: String?,
scheduler: Handler?,
flag: ReceiverFlag
): Intent? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(receiver, filter, broadcastPermission, scheduler, flag.getId())
} else {
registerReceiver(receiver, filter, broadcastPermission, scheduler)
}
}

View file

@ -0,0 +1,35 @@
/*
* Nextcloud Android client application
*
* @author Alper Ozturk
* Copyright (C) 2023 Alper Ozturk
* Copyright (C) 2023 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.utils
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
enum class ReceiverFlag {
NotExported;
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
fun getId(): Int {
return Context.RECEIVER_NOT_EXPORTED
}
}

View file

@ -44,6 +44,8 @@ import android.media.AudioManager;
import android.util.Log;
import com.nextcloud.talk.events.ProximitySensorEvent;
import com.nextcloud.talk.utils.ContextExtensionsKt;
import com.nextcloud.talk.utils.ReceiverFlag;
import com.nextcloud.talk.utils.power.PowerManagerUtils;
import org.greenrobot.eventbus.EventBus;
@ -55,7 +57,7 @@ import java.util.Set;
public class WebRtcAudioManager {
private static final String TAG = WebRtcAudioManager.class.getSimpleName();
private final Context magicContext;
private final Context context;
private final WebRtcBluetoothManager bluetoothManager;
private final boolean useProximitySensor;
private final AudioManager audioManager;
@ -81,7 +83,7 @@ public class WebRtcAudioManager {
private WebRtcAudioManager(Context context, boolean useProximitySensor) {
Log.d(TAG, "ctor");
ThreadUtils.checkIsOnMainThread();
magicContext = context;
this.context = context;
audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
bluetoothManager = WebRtcBluetoothManager.create(context, this);
wiredHeadsetReceiver = new WiredHeadsetReceiver();
@ -339,14 +341,14 @@ public class WebRtcAudioManager {
* Helper method for receiver registration.
*/
private void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
magicContext.registerReceiver(receiver, filter);
ContextExtensionsKt.registerBroadcastReceiver(context, receiver, filter, ReceiverFlag.NotExported);
}
/**
* Helper method for unregistration of an existing receiver.
*/
private void unregisterReceiver(BroadcastReceiver receiver) {
magicContext.unregisterReceiver(receiver);
context.unregisterReceiver(receiver);
}
/**
@ -375,7 +377,7 @@ public class WebRtcAudioManager {
* Gets the current earpiece state.
*/
private boolean hasEarpiece() {
return magicContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
}
/**

View file

@ -51,6 +51,9 @@ import android.os.Looper;
import android.os.Process;
import android.util.Log;
import com.nextcloud.talk.utils.ContextExtensionsKt;
import com.nextcloud.talk.utils.ReceiverFlag;
import org.webrtc.ThreadUtils;
import java.util.List;
@ -300,7 +303,11 @@ public class WebRtcBluetoothManager {
}
protected void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
apprtcContext.registerReceiver(receiver, filter);
ContextExtensionsKt.registerBroadcastReceiver(
apprtcContext,
receiver,
filter,
ReceiverFlag.NotExported);
}
protected void unregisterReceiver(BroadcastReceiver receiver) {

View file

@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 8 errors and 83 warnings</span>
<span class="mdl-layout-title">Lint Report: 8 errors and 80 warnings</span>