Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ba7e778 authored by /e/ robot's avatar /e/ robot
Browse files

Merge remote-tracking branch 'origin/lineage-17.1' into v1-q

parents 85543d87 ba6f3695
Loading
Loading
Loading
Loading
+14 −25
Original line number Diff line number Diff line
@@ -169,11 +169,6 @@ public class ScreencastService extends Service implements MediaProviderHelper.On

        mMediaProjectionManager = getSystemService(MediaProjectionManager.class);

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_USER_BACKGROUND);
        filter.addAction(Intent.ACTION_SHUTDOWN);
        registerReceiver(mBroadcastReceiver, filter);

        mNotificationManager = getSystemService(NotificationManager.class);

        if (mNotificationManager == null || mNotificationManager.getNotificationChannel(
@@ -190,13 +185,6 @@ public class ScreencastService extends Service implements MediaProviderHelper.On
        mNotificationManager.createNotificationChannel(notificationChannel);
    }

    @Override
    public void onDestroy() {
        stopCasting();
        unregisterReceiver(mBroadcastReceiver);
        super.onDestroy();
    }

    @Override
    public void onContentWritten(@Nullable String uri) {
        stopForeground(true);
@@ -229,9 +217,14 @@ public class ScreencastService extends Service implements MediaProviderHelper.On
        int resultCode = intent.getIntExtra(EXTRA_RESULT_CODE, Activity.RESULT_CANCELED);
        mUseAudio = intent.getBooleanExtra(EXTRA_USE_AUDIO, false);
        Intent data = intent.getParcelableExtra(EXTRA_DATA);
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_USER_BACKGROUND);
        filter.addAction(Intent.ACTION_SHUTDOWN);

        if (data != null) {
            mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, data);
            new Thread(this::startRecording).start();
            startRecording();
            registerReceiver(mBroadcastReceiver, filter);
        }
        return START_STICKY;
    }
@@ -303,7 +296,9 @@ public class ScreencastService extends Service implements MediaProviderHelper.On
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }

    private void stopRecording() {
    private void stopCasting() {
        Utils.setStatus(getApplicationContext(), Utils.PREF_RECORDING_NOTHING);

        mMediaRecorder.stop();
        mMediaRecorder.release();
        mMediaRecorder = null;
@@ -311,22 +306,16 @@ public class ScreencastService extends Service implements MediaProviderHelper.On
        mMediaProjection = null;
        mInputSurface.release();
        mVirtualDisplay.release();

        if (mTimer != null) {
        mTimer.cancel();
        mTimer = null;
        }

        MediaProviderHelper.addVideoToContentProvider(getContentResolver(), mPath, this);
    }

    private void stopCasting() {
        Utils.setStatus(getApplicationContext(), Utils.PREF_RECORDING_NOTHING);
        stopRecording();

        if (hasNoAvailableSpace()) {
            Toast.makeText(this, R.string.screen_not_enough_storage, Toast.LENGTH_LONG).show();
        }

        unregisterReceiver(mBroadcastReceiver);
        stopSelf();
    }

    private NotificationCompat.Builder createNotificationBuilder() {
+3 −3
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The LineageOS Project
 * Copyright (C) 2019-2020 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -124,12 +124,12 @@ public final class MediaProviderHelper {
                if (pfd == null) {
                    return null;
                }

                final FileOutputStream oStream = new FileOutputStream(pfd.getFileDescriptor());
                oStream.write(Files.readAllBytes(file.toPath()));
                Files.copy(file.toPath(), oStream);
                oStream.close();
                pfd.close();


                final ContentValues values = new ContentValues();
                values.put(MediaStore.MediaColumns.IS_PENDING, 0);
                cr.update(uri, values, null, null);
+0 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<!-- Copyright (c) 2017 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
+0 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<!-- Copyright (c) 2017 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
+0 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<!-- Copyright (c) 2017 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
Loading