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

Commit 9f62497f authored by Virkumar Karavate's avatar Virkumar Karavate Committed by Automerger Merge Worker
Browse files

Merge "(Re-Introduce locking)[TEMP] Re-Introduce synchronization locking" am:...

Merge "(Re-Introduce locking)[TEMP] Re-Introduce synchronization locking" am: 14087b39 am: b646fcd6 am: 9723c613 am: 1283caac

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2036103

Change-Id: I400171202859f4c2d8c16b975624313b8e4b3ff2
parents 75ffad31 1283caac
Loading
Loading
Loading
Loading
+28 −17
Original line number Diff line number Diff line
@@ -375,11 +375,15 @@ public abstract class ImsFeature {
     */
    @SystemApi
    public final void setFeatureState(@ImsState int state) {
        boolean isNotify = false;
        synchronized (mLock) {
            if (mState != state) {
                mState = state;
                notifyFeatureState(state);
                isNotify = true;
            }
        }
        if (isNotify) {
            notifyFeatureState(state);
        }
    }

@@ -412,6 +416,7 @@ public abstract class ImsFeature {
     * Internal method called by ImsFeature when setFeatureState has changed.
     */
    private void notifyFeatureState(@ImsState int state) {
        synchronized (mStatusCallbacks) {
            mStatusCallbacks.broadcastAction((c) -> {
                try {
                    c.notifyImsFeatureStatus(state);
@@ -421,6 +426,7 @@ public abstract class ImsFeature {
                }
            });
        }
    }

    /**
     * @hide
@@ -491,8 +497,12 @@ public abstract class ImsFeature {
        synchronized (mLock) {
            mCapabilityStatus = caps.copy();
        }

        synchronized (mCapabilityCallbacks) {
            mCapabilityCallbacks.broadcastAction((callback) -> {
                try {
                    Log.d(LOG_TAG, "ImsFeature notifyCapabilitiesStatusChanged Capabilities = "
                            + caps.mCapabilities);
                    callback.onCapabilitiesStatusChanged(caps.mCapabilities);
                } catch (RemoteException e) {
                    Log.w(LOG_TAG, e + " notifyCapabilitiesStatusChanged() - Skipping "
@@ -500,6 +510,7 @@ public abstract class ImsFeature {
                }
            });
        }
    }

    /**
     * Provides the ImsFeature with the ability to return the framework Capability Configuration
+54 −42
Original line number Diff line number Diff line
@@ -587,6 +587,7 @@ public class ImsConfigImplBase {
        if (mCallbacks == null) {
            return;
        }
        synchronized (mCallbacks) {
            mCallbacks.broadcastAction(c -> {
                try {
                    c.onIntConfigChanged(item, value);
@@ -595,12 +596,14 @@ public class ImsConfigImplBase {
                }
            });
        }
    }

    private void notifyConfigChanged(int item, String value) {
        // can be null in testing
        if (mCallbacks == null) {
            return;
        }
        synchronized (mCallbacks) {
            mCallbacks.broadcastAction(c -> {
                try {
                    c.onStringConfigChanged(item, value);
@@ -609,6 +612,7 @@ public class ImsConfigImplBase {
                }
            });
        }
    }

    private void addRcsConfigCallback(IRcsConfigCallback c) {
        mRcsCallbacks.register(c);
@@ -635,6 +639,7 @@ public class ImsConfigImplBase {

        // can be null in testing
        if (mRcsCallbacks != null) {
            synchronized (mRcsCallbacks) {
                mRcsCallbacks.broadcastAction(c -> {
                    try {
                        c.onConfigurationChanged(mRcsConfigData);
@@ -643,12 +648,14 @@ public class ImsConfigImplBase {
                    }
                });
            }
        }
        notifyRcsAutoConfigurationReceived(config, isCompressed);
    }

    private void onNotifyRcsAutoConfigurationRemoved() {
        mRcsConfigData = null;
        if (mRcsCallbacks != null) {
            synchronized (mRcsCallbacks) {
                mRcsCallbacks.broadcastAction(c -> {
                    try {
                        c.onConfigurationReset();
@@ -657,6 +664,7 @@ public class ImsConfigImplBase {
                    }
                });
            }
        }
        notifyRcsAutoConfigurationRemoved();
    }

@@ -801,6 +809,7 @@ public class ImsConfigImplBase {
        if (mRcsCallbacks == null) {
            return;
        }
        synchronized (mRcsCallbacks) {
            mRcsCallbacks.broadcastAction(c -> {
                try {
                    c.onAutoConfigurationErrorReceived(errorCode, errorString);
@@ -809,6 +818,7 @@ public class ImsConfigImplBase {
                }
            });
        }
    }

    /**
     * Notifies application that pre-provisioning config is received.
@@ -825,6 +835,7 @@ public class ImsConfigImplBase {
        if (mRcsCallbacks == null) {
            return;
        }
        synchronized (mRcsCallbacks) {
            mRcsCallbacks.broadcastAction(c -> {
                try {
                    c.onPreProvisioningReceived(configXml);
@@ -833,6 +844,7 @@ public class ImsConfigImplBase {
                }
            });
        }
    }

    /**
     * Set default Executor from ImsService.
+85 −67
Original line number Diff line number Diff line
@@ -219,12 +219,16 @@ public class ImsSmsImplBase {
     */
    public final void onSmsReceived(int token, @SmsMessage.Format String format, byte[] pdu)
            throws RuntimeException {
        IImsSmsListener listener = null;
        synchronized (mLock) {
            if (mListener == null) {
            listener = mListener;
        }

        if (listener == null) {
            throw new RuntimeException("Feature not ready.");
        }
        try {
                mListener.onSmsReceived(token, format, pdu);
            listener.onSmsReceived(token, format, pdu);
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "Can not deliver sms: " + e.getMessage());
            SmsMessage message = SmsMessage.createFromPdu(pdu, format);
@@ -237,7 +241,6 @@ public class ImsSmsImplBase {
            }
        }
    }
    }

    /**
     * This method should be triggered by the IMS providers when an outgoing SMS message has been
@@ -254,18 +257,21 @@ public class ImsSmsImplBase {
     */
    public final void onSendSmsResultSuccess(int token,
            @IntRange(from = 0, to = 65535) int messageRef) throws RuntimeException {
        IImsSmsListener listener = null;
        synchronized (mLock) {
            if (mListener == null) {
            listener = mListener;
        }

        if (listener == null) {
            throw new RuntimeException("Feature not ready.");
        }
        try {
                mListener.onSendSmsResult(token, messageRef, SEND_STATUS_OK,
            listener.onSendSmsResult(token, messageRef, SEND_STATUS_OK,
                    SmsManager.RESULT_ERROR_NONE, RESULT_NO_NETWORK_ERROR);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * This method should be triggered by the IMS providers to pass the result of the sent message
@@ -288,18 +294,21 @@ public class ImsSmsImplBase {
    @Deprecated
    public final void onSendSmsResult(int token, @IntRange(from = 0, to = 65535) int messageRef,
            @SendStatusResult int status, @SmsManager.Result int reason) throws RuntimeException {
        IImsSmsListener listener = null;
        synchronized (mLock) {
            if (mListener == null) {
            listener = mListener;
        }

        if (listener == null) {
            throw new RuntimeException("Feature not ready.");
        }
        try {
                mListener.onSendSmsResult(token, messageRef, status, reason,
            listener.onSendSmsResult(token, messageRef, status, reason,
                    RESULT_NO_NETWORK_ERROR);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * This method should be triggered by the IMS providers when an outgoing message fails to be
@@ -322,17 +331,20 @@ public class ImsSmsImplBase {
    public final void onSendSmsResultError(int token,
            @IntRange(from = 0, to = 65535) int messageRef, @SendStatusResult int status,
            @SmsManager.Result int reason, int networkErrorCode) throws RuntimeException {
        IImsSmsListener listener = null;
        synchronized (mLock) {
            if (mListener == null) {
            listener = mListener;
        }

        if (listener == null) {
            throw new RuntimeException("Feature not ready.");
        }
        try {
                mListener.onSendSmsResult(token, messageRef, status, reason, networkErrorCode);
            listener.onSendSmsResult(token, messageRef, status, reason, networkErrorCode);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * This method should be triggered by the IMS providers when the status report of the sent
@@ -357,18 +369,21 @@ public class ImsSmsImplBase {
    public final void onSmsStatusReportReceived(int token,
            @IntRange(from = 0, to = 65535) int messageRef, @SmsMessage.Format String format,
            byte[] pdu) throws RuntimeException {
        IImsSmsListener listener = null;
        synchronized (mLock) {
            if (mListener == null) {
            listener = mListener;
        }

        if (listener == null) {
            throw new RuntimeException("Feature not ready.");
        }
        try {
                mListener.onSmsStatusReportReceived(token, format, pdu);
            listener.onSmsStatusReportReceived(token, format, pdu);
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "Can not process sms status report: " + e.getMessage());
            acknowledgeSmsReport(token, messageRef, STATUS_REPORT_STATUS_ERROR);
        }
    }
    }

    /**
     * This method should be triggered by the IMS providers when the status report of the sent
@@ -386,12 +401,16 @@ public class ImsSmsImplBase {
     */
    public final void onSmsStatusReportReceived(int token, @SmsMessage.Format String format,
            byte[] pdu) throws RuntimeException {
        IImsSmsListener listener = null;
        synchronized (mLock) {
            if (mListener == null) {
            listener = mListener;
        }

        if (listener == null) {
            throw new RuntimeException("Feature not ready.");
        }
        try {
                mListener.onSmsStatusReportReceived(token, format, pdu);
            listener.onSmsStatusReportReceived(token, format, pdu);
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "Can not process sms status report: " + e.getMessage());
            SmsMessage message = SmsMessage.createFromPdu(pdu, format);
@@ -406,7 +425,6 @@ public class ImsSmsImplBase {
            }
        }
    }
    }

    /**
     * Returns the SMS format that the ImsService expects.