Merge "(Re-Introduce locking)[TEMP] Re-Introduce synchronization locking"
This commit is contained in:
@@ -375,12 +375,16 @@ public abstract class ImsFeature {
|
|||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
public final void setFeatureState(@ImsState int state) {
|
public final void setFeatureState(@ImsState int state) {
|
||||||
|
boolean isNotify = false;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mState != state) {
|
if (mState != state) {
|
||||||
mState = state;
|
mState = state;
|
||||||
notifyFeatureState(state);
|
isNotify = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isNotify) {
|
||||||
|
notifyFeatureState(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -412,14 +416,16 @@ public abstract class ImsFeature {
|
|||||||
* Internal method called by ImsFeature when setFeatureState has changed.
|
* Internal method called by ImsFeature when setFeatureState has changed.
|
||||||
*/
|
*/
|
||||||
private void notifyFeatureState(@ImsState int state) {
|
private void notifyFeatureState(@ImsState int state) {
|
||||||
mStatusCallbacks.broadcastAction((c) -> {
|
synchronized (mStatusCallbacks) {
|
||||||
try {
|
mStatusCallbacks.broadcastAction((c) -> {
|
||||||
c.notifyImsFeatureStatus(state);
|
try {
|
||||||
} catch (RemoteException e) {
|
c.notifyImsFeatureStatus(state);
|
||||||
Log.w(LOG_TAG, e + " notifyFeatureState() - Skipping "
|
} catch (RemoteException e) {
|
||||||
+ "callback.");
|
Log.w(LOG_TAG, e + " notifyFeatureState() - Skipping "
|
||||||
}
|
+ "callback.");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -491,14 +497,19 @@ public abstract class ImsFeature {
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mCapabilityStatus = caps.copy();
|
mCapabilityStatus = caps.copy();
|
||||||
}
|
}
|
||||||
mCapabilityCallbacks.broadcastAction((callback) -> {
|
|
||||||
try {
|
synchronized (mCapabilityCallbacks) {
|
||||||
callback.onCapabilitiesStatusChanged(caps.mCapabilities);
|
mCapabilityCallbacks.broadcastAction((callback) -> {
|
||||||
} catch (RemoteException e) {
|
try {
|
||||||
Log.w(LOG_TAG, e + " notifyCapabilitiesStatusChanged() - Skipping "
|
Log.d(LOG_TAG, "ImsFeature notifyCapabilitiesStatusChanged Capabilities = "
|
||||||
+ "callback.");
|
+ caps.mCapabilities);
|
||||||
}
|
callback.onCapabilitiesStatusChanged(caps.mCapabilities);
|
||||||
});
|
} catch (RemoteException e) {
|
||||||
|
Log.w(LOG_TAG, e + " notifyCapabilitiesStatusChanged() - Skipping "
|
||||||
|
+ "callback.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -587,13 +587,15 @@ public class ImsConfigImplBase {
|
|||||||
if (mCallbacks == null) {
|
if (mCallbacks == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCallbacks.broadcastAction(c -> {
|
synchronized (mCallbacks) {
|
||||||
try {
|
mCallbacks.broadcastAction(c -> {
|
||||||
c.onIntConfigChanged(item, value);
|
try {
|
||||||
} catch (RemoteException e) {
|
c.onIntConfigChanged(item, value);
|
||||||
Log.w(TAG, "notifyConfigChanged(int): dead binder in notify, skipping.");
|
} catch (RemoteException e) {
|
||||||
}
|
Log.w(TAG, "notifyConfigChanged(int): dead binder in notify, skipping.");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyConfigChanged(int item, String value) {
|
private void notifyConfigChanged(int item, String value) {
|
||||||
@@ -601,13 +603,15 @@ public class ImsConfigImplBase {
|
|||||||
if (mCallbacks == null) {
|
if (mCallbacks == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCallbacks.broadcastAction(c -> {
|
synchronized (mCallbacks) {
|
||||||
try {
|
mCallbacks.broadcastAction(c -> {
|
||||||
c.onStringConfigChanged(item, value);
|
try {
|
||||||
} catch (RemoteException e) {
|
c.onStringConfigChanged(item, value);
|
||||||
Log.w(TAG, "notifyConfigChanged(string): dead binder in notify, skipping.");
|
} catch (RemoteException e) {
|
||||||
}
|
Log.w(TAG, "notifyConfigChanged(string): dead binder in notify, skipping.");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRcsConfigCallback(IRcsConfigCallback c) {
|
private void addRcsConfigCallback(IRcsConfigCallback c) {
|
||||||
@@ -635,13 +639,15 @@ public class ImsConfigImplBase {
|
|||||||
|
|
||||||
// can be null in testing
|
// can be null in testing
|
||||||
if (mRcsCallbacks != null) {
|
if (mRcsCallbacks != null) {
|
||||||
mRcsCallbacks.broadcastAction(c -> {
|
synchronized (mRcsCallbacks) {
|
||||||
try {
|
mRcsCallbacks.broadcastAction(c -> {
|
||||||
c.onConfigurationChanged(mRcsConfigData);
|
try {
|
||||||
} catch (RemoteException e) {
|
c.onConfigurationChanged(mRcsConfigData);
|
||||||
Log.w(TAG, "dead binder in notifyRcsAutoConfigurationReceived, skipping.");
|
} catch (RemoteException e) {
|
||||||
}
|
Log.w(TAG, "dead binder in notifyRcsAutoConfigurationReceived, skipping.");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
notifyRcsAutoConfigurationReceived(config, isCompressed);
|
notifyRcsAutoConfigurationReceived(config, isCompressed);
|
||||||
}
|
}
|
||||||
@@ -649,13 +655,15 @@ public class ImsConfigImplBase {
|
|||||||
private void onNotifyRcsAutoConfigurationRemoved() {
|
private void onNotifyRcsAutoConfigurationRemoved() {
|
||||||
mRcsConfigData = null;
|
mRcsConfigData = null;
|
||||||
if (mRcsCallbacks != null) {
|
if (mRcsCallbacks != null) {
|
||||||
mRcsCallbacks.broadcastAction(c -> {
|
synchronized (mRcsCallbacks) {
|
||||||
try {
|
mRcsCallbacks.broadcastAction(c -> {
|
||||||
c.onConfigurationReset();
|
try {
|
||||||
} catch (RemoteException e) {
|
c.onConfigurationReset();
|
||||||
Log.w(TAG, "dead binder in notifyRcsAutoConfigurationRemoved, skipping.");
|
} catch (RemoteException e) {
|
||||||
}
|
Log.w(TAG, "dead binder in notifyRcsAutoConfigurationRemoved, skipping.");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
notifyRcsAutoConfigurationRemoved();
|
notifyRcsAutoConfigurationRemoved();
|
||||||
}
|
}
|
||||||
@@ -801,13 +809,15 @@ public class ImsConfigImplBase {
|
|||||||
if (mRcsCallbacks == null) {
|
if (mRcsCallbacks == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mRcsCallbacks.broadcastAction(c -> {
|
synchronized (mRcsCallbacks) {
|
||||||
try {
|
mRcsCallbacks.broadcastAction(c -> {
|
||||||
c.onAutoConfigurationErrorReceived(errorCode, errorString);
|
try {
|
||||||
} catch (RemoteException e) {
|
c.onAutoConfigurationErrorReceived(errorCode, errorString);
|
||||||
Log.w(TAG, "dead binder in notifyAutoConfigurationErrorReceived, skipping.");
|
} catch (RemoteException e) {
|
||||||
}
|
Log.w(TAG, "dead binder in notifyAutoConfigurationErrorReceived, skipping.");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -825,13 +835,15 @@ public class ImsConfigImplBase {
|
|||||||
if (mRcsCallbacks == null) {
|
if (mRcsCallbacks == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mRcsCallbacks.broadcastAction(c -> {
|
synchronized (mRcsCallbacks) {
|
||||||
try {
|
mRcsCallbacks.broadcastAction(c -> {
|
||||||
c.onPreProvisioningReceived(configXml);
|
try {
|
||||||
} catch (RemoteException e) {
|
c.onPreProvisioningReceived(configXml);
|
||||||
Log.w(TAG, "dead binder in notifyPreProvisioningReceived, skipping.");
|
} catch (RemoteException e) {
|
||||||
}
|
Log.w(TAG, "dead binder in notifyPreProvisioningReceived, skipping.");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -219,22 +219,25 @@ public class ImsSmsImplBase {
|
|||||||
*/
|
*/
|
||||||
public final void onSmsReceived(int token, @SmsMessage.Format String format, byte[] pdu)
|
public final void onSmsReceived(int token, @SmsMessage.Format String format, byte[] pdu)
|
||||||
throws RuntimeException {
|
throws RuntimeException {
|
||||||
|
IImsSmsListener listener = null;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mListener == null) {
|
listener = mListener;
|
||||||
throw new RuntimeException("Feature not ready.");
|
}
|
||||||
}
|
|
||||||
try {
|
if (listener == null) {
|
||||||
mListener.onSmsReceived(token, format, pdu);
|
throw new RuntimeException("Feature not ready.");
|
||||||
} catch (RemoteException e) {
|
}
|
||||||
Log.e(LOG_TAG, "Can not deliver sms: " + e.getMessage());
|
try {
|
||||||
SmsMessage message = SmsMessage.createFromPdu(pdu, format);
|
listener.onSmsReceived(token, format, pdu);
|
||||||
if (message != null && message.mWrappedSmsMessage != null) {
|
} catch (RemoteException e) {
|
||||||
acknowledgeSms(token, message.mWrappedSmsMessage.mMessageRef,
|
Log.e(LOG_TAG, "Can not deliver sms: " + e.getMessage());
|
||||||
DELIVER_STATUS_ERROR_GENERIC);
|
SmsMessage message = SmsMessage.createFromPdu(pdu, format);
|
||||||
} else {
|
if (message != null && message.mWrappedSmsMessage != null) {
|
||||||
Log.w(LOG_TAG, "onSmsReceived: Invalid pdu entered.");
|
acknowledgeSms(token, message.mWrappedSmsMessage.mMessageRef,
|
||||||
acknowledgeSms(token, 0, DELIVER_STATUS_ERROR_GENERIC);
|
DELIVER_STATUS_ERROR_GENERIC);
|
||||||
}
|
} else {
|
||||||
|
Log.w(LOG_TAG, "onSmsReceived: Invalid pdu entered.");
|
||||||
|
acknowledgeSms(token, 0, DELIVER_STATUS_ERROR_GENERIC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,16 +257,19 @@ public class ImsSmsImplBase {
|
|||||||
*/
|
*/
|
||||||
public final void onSendSmsResultSuccess(int token,
|
public final void onSendSmsResultSuccess(int token,
|
||||||
@IntRange(from = 0, to = 65535) int messageRef) throws RuntimeException {
|
@IntRange(from = 0, to = 65535) int messageRef) throws RuntimeException {
|
||||||
|
IImsSmsListener listener = null;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mListener == null) {
|
listener = mListener;
|
||||||
throw new RuntimeException("Feature not ready.");
|
}
|
||||||
}
|
|
||||||
try {
|
if (listener == null) {
|
||||||
mListener.onSendSmsResult(token, messageRef, SEND_STATUS_OK,
|
throw new RuntimeException("Feature not ready.");
|
||||||
SmsManager.RESULT_ERROR_NONE, RESULT_NO_NETWORK_ERROR);
|
}
|
||||||
} catch (RemoteException e) {
|
try {
|
||||||
e.rethrowFromSystemServer();
|
listener.onSendSmsResult(token, messageRef, SEND_STATUS_OK,
|
||||||
}
|
SmsManager.RESULT_ERROR_NONE, RESULT_NO_NETWORK_ERROR);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,16 +294,19 @@ public class ImsSmsImplBase {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public final void onSendSmsResult(int token, @IntRange(from = 0, to = 65535) int messageRef,
|
public final void onSendSmsResult(int token, @IntRange(from = 0, to = 65535) int messageRef,
|
||||||
@SendStatusResult int status, @SmsManager.Result int reason) throws RuntimeException {
|
@SendStatusResult int status, @SmsManager.Result int reason) throws RuntimeException {
|
||||||
|
IImsSmsListener listener = null;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mListener == null) {
|
listener = mListener;
|
||||||
throw new RuntimeException("Feature not ready.");
|
}
|
||||||
}
|
|
||||||
try {
|
if (listener == null) {
|
||||||
mListener.onSendSmsResult(token, messageRef, status, reason,
|
throw new RuntimeException("Feature not ready.");
|
||||||
RESULT_NO_NETWORK_ERROR);
|
}
|
||||||
} catch (RemoteException e) {
|
try {
|
||||||
e.rethrowFromSystemServer();
|
listener.onSendSmsResult(token, messageRef, status, reason,
|
||||||
}
|
RESULT_NO_NETWORK_ERROR);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,15 +331,18 @@ public class ImsSmsImplBase {
|
|||||||
public final void onSendSmsResultError(int token,
|
public final void onSendSmsResultError(int token,
|
||||||
@IntRange(from = 0, to = 65535) int messageRef, @SendStatusResult int status,
|
@IntRange(from = 0, to = 65535) int messageRef, @SendStatusResult int status,
|
||||||
@SmsManager.Result int reason, int networkErrorCode) throws RuntimeException {
|
@SmsManager.Result int reason, int networkErrorCode) throws RuntimeException {
|
||||||
|
IImsSmsListener listener = null;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mListener == null) {
|
listener = mListener;
|
||||||
throw new RuntimeException("Feature not ready.");
|
}
|
||||||
}
|
|
||||||
try {
|
if (listener == null) {
|
||||||
mListener.onSendSmsResult(token, messageRef, status, reason, networkErrorCode);
|
throw new RuntimeException("Feature not ready.");
|
||||||
} catch (RemoteException e) {
|
}
|
||||||
e.rethrowFromSystemServer();
|
try {
|
||||||
}
|
listener.onSendSmsResult(token, messageRef, status, reason, networkErrorCode);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,16 +369,19 @@ public class ImsSmsImplBase {
|
|||||||
public final void onSmsStatusReportReceived(int token,
|
public final void onSmsStatusReportReceived(int token,
|
||||||
@IntRange(from = 0, to = 65535) int messageRef, @SmsMessage.Format String format,
|
@IntRange(from = 0, to = 65535) int messageRef, @SmsMessage.Format String format,
|
||||||
byte[] pdu) throws RuntimeException {
|
byte[] pdu) throws RuntimeException {
|
||||||
|
IImsSmsListener listener = null;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mListener == null) {
|
listener = mListener;
|
||||||
throw new RuntimeException("Feature not ready.");
|
}
|
||||||
}
|
|
||||||
try {
|
if (listener == null) {
|
||||||
mListener.onSmsStatusReportReceived(token, format, pdu);
|
throw new RuntimeException("Feature not ready.");
|
||||||
} catch (RemoteException e) {
|
}
|
||||||
Log.e(LOG_TAG, "Can not process sms status report: " + e.getMessage());
|
try {
|
||||||
acknowledgeSmsReport(token, messageRef, STATUS_REPORT_STATUS_ERROR);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,24 +401,27 @@ public class ImsSmsImplBase {
|
|||||||
*/
|
*/
|
||||||
public final void onSmsStatusReportReceived(int token, @SmsMessage.Format String format,
|
public final void onSmsStatusReportReceived(int token, @SmsMessage.Format String format,
|
||||||
byte[] pdu) throws RuntimeException {
|
byte[] pdu) throws RuntimeException {
|
||||||
|
IImsSmsListener listener = null;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mListener == null) {
|
listener = mListener;
|
||||||
throw new RuntimeException("Feature not ready.");
|
}
|
||||||
}
|
|
||||||
try {
|
if (listener == null) {
|
||||||
mListener.onSmsStatusReportReceived(token, format, pdu);
|
throw new RuntimeException("Feature not ready.");
|
||||||
} catch (RemoteException e) {
|
}
|
||||||
Log.e(LOG_TAG, "Can not process sms status report: " + e.getMessage());
|
try {
|
||||||
SmsMessage message = SmsMessage.createFromPdu(pdu, format);
|
listener.onSmsStatusReportReceived(token, format, pdu);
|
||||||
if (message != null && message.mWrappedSmsMessage != null) {
|
} catch (RemoteException e) {
|
||||||
acknowledgeSmsReport(
|
Log.e(LOG_TAG, "Can not process sms status report: " + e.getMessage());
|
||||||
token,
|
SmsMessage message = SmsMessage.createFromPdu(pdu, format);
|
||||||
message.mWrappedSmsMessage.mMessageRef,
|
if (message != null && message.mWrappedSmsMessage != null) {
|
||||||
STATUS_REPORT_STATUS_ERROR);
|
acknowledgeSmsReport(
|
||||||
} else {
|
token,
|
||||||
Log.w(LOG_TAG, "onSmsStatusReportReceived: Invalid pdu entered.");
|
message.mWrappedSmsMessage.mMessageRef,
|
||||||
acknowledgeSmsReport(token, 0, STATUS_REPORT_STATUS_ERROR);
|
STATUS_REPORT_STATUS_ERROR);
|
||||||
}
|
} else {
|
||||||
|
Log.w(LOG_TAG, "onSmsStatusReportReceived: Invalid pdu entered.");
|
||||||
|
acknowledgeSmsReport(token, 0, STATUS_REPORT_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user