Skip to content

Commit

Permalink
Android 14 support added
Browse files Browse the repository at this point in the history
  • Loading branch information
hatanvirIntele committed Apr 9, 2024
1 parent bdd0e14 commit ed582ab
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 27 deletions.
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<uses-permission
android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL"
android:minSdkVersion="34" />
<uses-permission
android:name="android.permission.MANAGE_OWN_CALLS"
android:minSdkVersion="34" />

<uses-feature
android:name="android.hardware.camera"
android:required="true" /> <!-- added support to lenova tab 2 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ private void catchFCMMessageData() {
intent.putExtra("visit_uuid", visitUUID);
intent.putExtra("connection_info", connectionInfoObject.toString());
intent.setComponent(new ComponentName(packageName, "org.intelehealth.app.services.firebase_services.RTCMessageReceiver"));
intent.setPackage(IntelehealthApplication.getInstance().getPackageName());
getApplicationContext().sendBroadcast(intent);

Intent chatIntent = new Intent(this, NASChatActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.widget.Button;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -213,15 +214,18 @@ public void onClick(DialogInterface dialogInterface, int i) {
}

private boolean checkAndRequestPermissions() {
List<String> listPermissionsNeeded = new ArrayList<>();
int cameraPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
int cameraPermission = ContextCompat.checkSelfPermission(this,
Manifest.permission.CAMERA);
int getAccountPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS);
int writeExternalStoragePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
int phoneStatePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
int bluetoothPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH);
int bluetoothAdminPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN);

int coarseLocationPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION);
int fineLocationPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION);
int writeExternalStoragePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);

List<String> listPermissionsNeeded = new ArrayList<>();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
writeExternalStoragePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_MEDIA_IMAGES);
int notificationPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS);
Expand All @@ -230,15 +234,13 @@ private boolean checkAndRequestPermissions() {
}
}

int phoneStatePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);


if (cameraPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.CAMERA);
}
if (getAccountPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.GET_ACCOUNTS);
}

if (writeExternalStoragePermission != PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
listPermissionsNeeded.add(Manifest.permission.READ_MEDIA_IMAGES);
Expand All @@ -250,8 +252,6 @@ private boolean checkAndRequestPermissions() {
if (phoneStatePermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.READ_PHONE_STATE);
}


if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
int bluetoothScanPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN);
int bluetoothConnectPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT);
Expand All @@ -269,16 +269,16 @@ private boolean checkAndRequestPermissions() {
listPermissionsNeeded.add(Manifest.permission.BLUETOOTH_ADMIN);
}
}


if (coarseLocationPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}
if (fineLocationPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);
}

if (!listPermissionsNeeded.isEmpty()) {
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[0]), GROUP_PERMISSION_REQUEST);
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),
GROUP_PERMISSION_REQUEST);
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;

public class VisitSummaryActivity extends BaseActivity /*implements PrinterObserver*/ {
public class VisitSummaryActivity extends AppCompatActivity /*implements PrinterObserver*/ {

private static final String TAG = VisitSummaryActivity.class.getSimpleName();
private WebView mWebView;
Expand Down Expand Up @@ -4788,7 +4788,7 @@ public void downloadPrescriptionDefault() {
protected void onStart() {
registerDownloadPrescription();
callBroadcastReceiver();
LocalBroadcastManager.getInstance(this).registerReceiver((mMessageReceiver), new IntentFilter(FILTER));
ContextCompat.registerReceiver(this,(mMessageReceiver), new IntentFilter(FILTER),ContextCompat.RECEIVER_NOT_EXPORTED);
super.onStart();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public void onError(Throwable e) {
}
sessionManager.setPullSyncFinished(true);
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PATIENT_PROFILE_IMAGE_PUSH_DONE));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PATIENT_PROFILE_IMAGE_PUSH_DONE)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
// AppConstants.notificationUtils.DownloadDone("Patient Profile", "Completed Uploading Patient Profile", 4, IntelehealthApplication.getAppContext());
return true;
}
Expand Down Expand Up @@ -134,7 +135,8 @@ public void onComplete() {
}
sessionManager.setPushSyncFinished(true);
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_OBS_IMAGE_PUSH_DONE));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_OBS_IMAGE_PUSH_DONE)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
// AppConstants.notificationUtils.DownloadDone("Patient Profile", "Completed Uploading Patient Profile", 4, IntelehealthApplication.getAppContext());
return true;
}
Expand Down
24 changes: 16 additions & 8 deletions app/src/main/java/org/intelehealth/app/database/dao/SyncDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public void onResponse(Call<ResponseDTO> call, Response<ResponseDTO> response) {
// AppConstants.notificationUtils.DownloadDone("Sync", "Successfully synced", 1, IntelehealthApplication.getAppContext());
else {
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}
//AppConstants.notificationUtils.DownloadDone("Sync", "Failed synced,You can try again", 1, IntelehealthApplication.getAppContext());

Expand Down Expand Up @@ -180,14 +181,16 @@ public void onResponse(Call<ResponseDTO> call, Response<ResponseDTO> response) {
/*Intent intent = new Intent(IntelehealthApplication.getAppContext(), LastSyncIntentService.class);
IntelehealthApplication.getAppContext().startService(intent);*/
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PULL_DATA_DONE));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PULL_DATA_DONE)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}

@Override
public void onFailure(Call<ResponseDTO> call, Throwable t) {
Logger.logD("pull data", "exception" + t.getMessage());
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}
});
sessionManager.setPullSyncFinished(true);
Expand Down Expand Up @@ -255,7 +258,8 @@ public void onResponse(Call<ResponseDTO> call, Response<ResponseDTO> response) {
// Toast.makeText(context, context.getString(R.string.failed_synced), Toast.LENGTH_LONG).show();
// }
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}

if (sessionManager.getTriggerNoti().equals("yes")) {
Expand Down Expand Up @@ -294,14 +298,16 @@ public void onResponse(Call<ResponseDTO> call, Response<ResponseDTO> response) {
/* Intent intent = new Intent(IntelehealthApplication.getAppContext(), LastSyncIntentService.class);
IntelehealthApplication.getAppContext().startService(intent);*/
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PULL_DATA_DONE));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PULL_DATA_DONE)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}

@Override
public void onFailure(Call<ResponseDTO> call, Throwable t) {
Logger.logD("pull data", "exception" + t.getMessage());
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}
});
sessionManager.setPullSyncFinished(true);
Expand Down Expand Up @@ -427,12 +433,14 @@ public void onError(Throwable e) {
Logger.logD(TAG, "Onerror " + e.getMessage());
isSucess[0] = false;
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_FAILED)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}
});
sessionManager.setPullSyncFinished(true);
IntelehealthApplication.getAppContext().sendBroadcast(new Intent(AppConstants.SYNC_INTENT_ACTION)
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PUSH_DATA_DONE));
.putExtra(AppConstants.SYNC_INTENT_DATA_KEY, AppConstants.SYNC_PUSH_DATA_DONE)
.setPackage(IntelehealthApplication.getInstance().getPackageName()));
}

return isSucess[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ private void sendIntent(Download download) {

Intent intent = new Intent(AppConstants.MESSAGE_PROGRESS);
intent.putExtra("download", download);
intent.setPackage(IntelehealthApplication.getInstance().getPackageName());
LocalBroadcastManager.getInstance(DownloadService.this).sendBroadcast(intent);


Intent i = new Intent();
i.setAction("MY_BROADCAST_IMAGE_DOWNLAOD");
i.setPackage(IntelehealthApplication.getInstance().getPackageName());
sendBroadcast(i);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.google.firebase.crashlytics.FirebaseCrashlytics;

import org.intelehealth.app.app.IntelehealthApplication;
import org.intelehealth.app.utilities.Logger;

public class LastSyncIntentService extends IntentService {
Expand All @@ -27,6 +28,7 @@ protected void onHandleIntent(Intent intent) {

Intent in = new Intent();
in.setAction("lasysync");
in.setPackage(IntelehealthApplication.getInstance().getPackageName());
sendBroadcast(in);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.google.firebase.crashlytics.FirebaseCrashlytics;

import org.intelehealth.app.app.IntelehealthApplication;
import org.intelehealth.app.utilities.Logger;

public class MyIntentService extends IntentService {
Expand All @@ -25,6 +26,7 @@ protected void onHandleIntent(Intent arg0) {

Intent in = new Intent();
in.setAction("OpenmrsID");
in.setPackage(IntelehealthApplication.getInstance().getPackageName());
sendBroadcast(in);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.google.firebase.crashlytics.FirebaseCrashlytics;

import org.intelehealth.app.app.IntelehealthApplication;
import org.intelehealth.app.utilities.Logger;

public class UpdateDownloadPrescriptionService extends IntentService {
Expand All @@ -22,6 +23,7 @@ protected void onHandleIntent(Intent intent) {
try {
Intent in = new Intent();
in.setAction("downloadprescription");
in.setPackage(IntelehealthApplication.getInstance().getPackageName());
sendBroadcast(in);
} catch (Exception e) {
FirebaseCrashlytics.getInstance().recordException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void onDestroy() {
instance = null;
Intent intent = new Intent(CallListenerBackgroundService.this, RestartServiceReceiver.class);
intent.setAction("org.intelehealth.app.RTC_SERVICE_START");
intent.setPackage(IntelehealthApplication.getInstance().getPackageName());
sendBroadcast(intent);
}

Expand Down Expand Up @@ -136,6 +137,7 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (value == null) return;
if (value.containsKey("callEnded") && (Boolean) value.get("callEnded")) {
Intent broadcast = new Intent();
intent.setPackage(IntelehealthApplication.getInstance().getPackageName());
//broadcast.setAction(CompleteActivity.CALL_END_FROM_WEB_INTENT_ACTION);
sendBroadcast(broadcast);
return;
Expand Down Expand Up @@ -166,6 +168,7 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Intent intent = new Intent(CallListenerBackgroundService.this, CallRTCNotifyReceiver.class);
intent.putExtras(bundle);
intent.setAction("org.intelehealth.app.RTC_MESSAGE_EVENT");
intent.setPackage(IntelehealthApplication.getInstance().getPackageName());
sendBroadcast(intent);
}

Expand Down Expand Up @@ -200,6 +203,7 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Intent intent = new Intent(CallListenerBackgroundService.this, CallRTCNotifyReceiver.class);
intent.putExtras(bundle);
intent.setAction("org.intelehealth.app.RTC_MESSAGE_EVENT");
intent.setPackage(IntelehealthApplication.getInstance().getPackageName());
sendBroadcast(intent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.intelehealth.app.R;
import org.intelehealth.app.activities.homeActivity.HomeActivity;
import org.intelehealth.app.app.IntelehealthApplication;
import org.intelehealth.app.utilities.OfflineLogin;
import org.intelehealth.app.webrtc.activity.NASChatActivity;
import org.intelehealth.klivekit.call.ui.activity.VideoCallActivity;
Expand Down Expand Up @@ -117,6 +118,7 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
intent.putExtra("connection_info", connectionInfoObject.toString());
intent.setComponent(new ComponentName(packageName,
"org.intelehealth.app.services.firebase_services.RTCMessageReceiver"));
intent.setPackage(IntelehealthApplication.getInstance().getPackageName());
getApplicationContext().sendBroadcast(intent);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public ListenableWorker.Result doWork() {
Logger.logD(TAG, "doWork");

Intent in = new Intent();
in.setPackage(IntelehealthApplication.getInstance().getPackageName());
in.setAction(AppConstants.SYNC_INTENT_ACTION);
in.setPackage(IntelehealthApplication.getInstance().getPackageName());
IntelehealthApplication.getAppContext().sendBroadcast(in);

return Result.success();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public ListenableWorker.Result doWork() {

Intent in = new Intent();
in.setAction("downloadprescription");
in.setPackage(IntelehealthApplication.getInstance().getPackageName());
IntelehealthApplication.getAppContext().sendBroadcast(in);

return Result.success();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
android:fontFamily="@font/lato_regular"
android:inputType="textUri"
android:focusable="true"
android:text="as.intelehealth.org"
android:text="astesting.intelehealth.org"
android:focusableInTouchMode="true"/>
</com.google.android.material.textfield.TextInputLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ abstract class CoreVideoCallActivity : AppCompatActivity() {
PreferenceHelper(applicationContext)
}

private val neededPermissions =
arrayOf(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)
private val neededPermissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) arrayOf(
Manifest.permission.MANAGE_OWN_CALLS,
Manifest.permission.RECORD_AUDIO,
Manifest.permission.CAMERA
) else arrayOf(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)


// initiate the incoming call ringtone
Expand Down

0 comments on commit ed582ab

Please sign in to comment.