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

Commit af769cbd authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-20.0' into v1-t

parents 23798ac2 5602538f
Loading
Loading
Loading
Loading
+8 −20
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import com.android.systemui.util.asIndenting
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.withIncreasedIndent
import java.io.PrintWriter
import java.lang.ref.WeakReference
import javax.inject.Inject

@SysUISingleton
@@ -50,7 +49,7 @@ class PrivacyConfig @Inject constructor(
        private const val DEFAULT_MEDIA_PROJECTION = true
    }

    private val callbacks = mutableListOf<WeakReference<Callback>>()
    private val callbacks = mutableListOf<Callback>()

    var micCameraAvailable = isMicCameraEnabled()
        private set
@@ -65,19 +64,19 @@ class PrivacyConfig @Inject constructor(
                    // Running on the ui executor so can iterate on callbacks
                    if (properties.keyset.contains(MIC_CAMERA)) {
                        micCameraAvailable = properties.getBoolean(MIC_CAMERA, DEFAULT_MIC_CAMERA)
                        callbacks.forEach { it.get()?.onFlagMicCameraChanged(micCameraAvailable) }
                        callbacks.forEach { it.onFlagMicCameraChanged(micCameraAvailable) }
                    }

                    if (properties.keyset.contains(LOCATION)) {
                        locationAvailable = properties.getBoolean(LOCATION, DEFAULT_LOCATION)
                        callbacks.forEach { it.get()?.onFlagLocationChanged(locationAvailable) }
                        callbacks.forEach { it.onFlagLocationChanged(locationAvailable) }
                    }

                    if (properties.keyset.contains(MEDIA_PROJECTION)) {
                        mediaProjectionAvailable =
                                properties.getBoolean(MEDIA_PROJECTION, DEFAULT_MEDIA_PROJECTION)
                        callbacks.forEach {
                            it.get()?.onFlagMediaProjectionChanged(mediaProjectionAvailable)
                            it.onFlagMediaProjectionChanged(mediaProjectionAvailable)
                        }
                    }
                }
@@ -107,23 +106,14 @@ class PrivacyConfig @Inject constructor(
    }

    fun addCallback(callback: Callback) {
        addCallback(WeakReference(callback))
    }

    fun removeCallback(callback: Callback) {
        removeCallback(WeakReference(callback))
    }

    private fun addCallback(callback: WeakReference<Callback>) {
        uiExecutor.execute {
            callbacks.add(callback)
        }
    }

    private fun removeCallback(callback: WeakReference<Callback>) {
    fun removeCallback(callback: Callback) {
        uiExecutor.execute {
            // Removes also if the callback is null
            callbacks.removeIf { it.get()?.equals(callback.get()) ?: true }
            callbacks.remove(callback)
        }
    }

@@ -136,9 +126,7 @@ class PrivacyConfig @Inject constructor(
            ipw.println("mediaProjectionAvailable: $mediaProjectionAvailable")
            ipw.println("Callbacks:")
            ipw.withIncreasedIndent {
                callbacks.forEach { callback ->
                    callback.get()?.let { ipw.println(it) }
                }
                callbacks.forEach { ipw.println(it) }
            }
        }
        ipw.flush()
+18 −8
Original line number Diff line number Diff line
@@ -574,7 +574,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
    private void onNetworkAvailable() {
        mNtpTimeHelper.onNetworkAvailable();
        // Download only if supported, (prevents an unnecessary on-boot download)
        if (mSupportsPsds) {
        if (mSupportsPsds && isAssistedGpsEnabled()) {
            synchronized (mLock) {
                for (int psdsType : mPendingDownloadPsdsTypes) {
                    postWithWakeLockHeld(() -> handleDownloadPsdsData(psdsType));
@@ -669,6 +669,11 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            Log.d(TAG, "handleDownloadPsdsData() called when PSDS not supported");
            return;
        }
        if (!isAssistedGpsEnabled()) {
            // PSDS download disabled by system setting, don't try
            Log.d(TAG, "handleDownloadPsdsData() called when PSDS disabled by system setting");
            return;
        }
        if (!mNetworkConnectivityHandler.isDataNetworkConnected()) {
            // try again when network is up
            synchronized (mLock) {
@@ -1055,7 +1060,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
        } else if ("force_time_injection".equals(command)) {
            requestUtcTime();
        } else if ("force_psds_injection".equals(command)) {
            if (mSupportsPsds) {
            if (mSupportsPsds && isAssistedGpsEnabled()) {
                postWithWakeLockHeld(() -> handleDownloadPsdsData(
                        GnssPsdsDownloader.LONG_TERM_PSDS_SERVER_INDEX));
            }
@@ -1099,12 +1104,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
            mTimeToFirstFix = 0;
            mLastFixTime = 0;
            setStarted(true);
            mPositionMode = GNSS_POSITION_MODE_STANDALONE;

            boolean agpsEnabled =
                    (Settings.Global.getInt(mContext.getContentResolver(),
                            Settings.Global.ASSISTED_GPS_ENABLED, 1) != 0);
            mPositionMode = getSuplMode(agpsEnabled);
            mPositionMode = getSuplMode(isAssistedGpsEnabled());

            if (DEBUG) {
                String mode;
@@ -1605,6 +1605,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                    "PsdsServerConfigured=" + mGnssConfiguration.isLongTermPsdsServerConfigured());
            pw.println("native internal state: ");
            pw.println("  " + mGnssNative.getInternalState());
            pw.println("isAssistedGpsEnabled=" + isAssistedGpsEnabled());
        }
    }

@@ -1786,4 +1787,13 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
                otherProtocolStackName, requestor, requestorId, responseType, inEmergencyMode,
                isCachedLocation);
    }

    private boolean isAssistedGpsEnabled() {
        final Boolean isEmergency = mNIHandler.getInEmergency();
        if (isEmergency) {
            Log.i(TAG, "Forcing Assisted GPS due to emergency");
        }
        return (Settings.Global.getInt(mContext.getContentResolver(),
                        Settings.Global.ASSISTED_GPS_ENABLED, 0) != 0) || isEmergency;
    }
}