Merge changes from topic "null_callback"

am: 5ce391b313

Change-Id: I0a956cd8b88d956102e912b5567732341faa78fc
This commit is contained in:
Jack Yu
2019-08-23 02:39:24 -07:00
committed by android-build-merger
2 changed files with 31 additions and 28 deletions

View File

@@ -24,7 +24,6 @@ import android.telephony.NetworkService.NetworkServiceProvider;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
/** /**
* Network service callback. Object of this class is passed to NetworkServiceProvider upon * Network service callback. Object of this class is passed to NetworkServiceProvider upon
@@ -61,11 +60,11 @@ public class NetworkServiceCallback {
/** Request failed */ /** Request failed */
public static final int RESULT_ERROR_FAILED = 5; public static final int RESULT_ERROR_FAILED = 5;
private final WeakReference<INetworkServiceCallback> mCallback; private final INetworkServiceCallback mCallback;
/** @hide */ /** @hide */
public NetworkServiceCallback(INetworkServiceCallback callback) { public NetworkServiceCallback(INetworkServiceCallback callback) {
mCallback = new WeakReference<>(callback); mCallback = callback;
} }
/** /**
@@ -78,15 +77,14 @@ public class NetworkServiceCallback {
*/ */
public void onRequestNetworkRegistrationInfoComplete(int result, public void onRequestNetworkRegistrationInfoComplete(int result,
@Nullable NetworkRegistrationInfo state) { @Nullable NetworkRegistrationInfo state) {
INetworkServiceCallback callback = mCallback.get(); if (mCallback != null) {
if (callback != null) {
try { try {
callback.onRequestNetworkRegistrationInfoComplete(result, state); mCallback.onRequestNetworkRegistrationInfoComplete(result, state);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(mTag, "Failed to onRequestNetworkRegistrationInfoComplete on the remote"); Rlog.e(mTag, "Failed to onRequestNetworkRegistrationInfoComplete on the remote");
} }
} else { } else {
Rlog.e(mTag, "Weak reference of callback is null."); Rlog.e(mTag, "onRequestNetworkRegistrationInfoComplete callback is null.");
} }
} }
} }

View File

@@ -27,7 +27,6 @@ import android.telephony.data.DataService.DataServiceProvider;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
/** /**
@@ -64,11 +63,11 @@ public class DataServiceCallback {
/** Request sent in illegal state */ /** Request sent in illegal state */
public static final int RESULT_ERROR_ILLEGAL_STATE = 4; public static final int RESULT_ERROR_ILLEGAL_STATE = 4;
private final WeakReference<IDataServiceCallback> mCallback; private final IDataServiceCallback mCallback;
/** @hide */ /** @hide */
public DataServiceCallback(IDataServiceCallback callback) { public DataServiceCallback(IDataServiceCallback callback) {
mCallback = new WeakReference<>(callback); mCallback = callback;
} }
/** /**
@@ -80,14 +79,15 @@ public class DataServiceCallback {
*/ */
public void onSetupDataCallComplete(@ResultCode int result, public void onSetupDataCallComplete(@ResultCode int result,
@Nullable DataCallResponse response) { @Nullable DataCallResponse response) {
IDataServiceCallback callback = mCallback.get(); if (mCallback != null) {
if (callback != null) {
try { try {
if (DBG) Rlog.d(TAG, "onSetupDataCallComplete"); if (DBG) Rlog.d(TAG, "onSetupDataCallComplete");
callback.onSetupDataCallComplete(result, response); mCallback.onSetupDataCallComplete(result, response);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(TAG, "Failed to onSetupDataCallComplete on the remote"); Rlog.e(TAG, "Failed to onSetupDataCallComplete on the remote");
} }
} else {
Rlog.e(TAG, "onSetupDataCallComplete: callback is null!");
} }
} }
@@ -98,14 +98,15 @@ public class DataServiceCallback {
* @param result The result code. Must be one of the {@link ResultCode}. * @param result The result code. Must be one of the {@link ResultCode}.
*/ */
public void onDeactivateDataCallComplete(@ResultCode int result) { public void onDeactivateDataCallComplete(@ResultCode int result) {
IDataServiceCallback callback = mCallback.get(); if (mCallback != null) {
if (callback != null) {
try { try {
if (DBG) Rlog.d(TAG, "onDeactivateDataCallComplete"); if (DBG) Rlog.d(TAG, "onDeactivateDataCallComplete");
callback.onDeactivateDataCallComplete(result); mCallback.onDeactivateDataCallComplete(result);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(TAG, "Failed to onDeactivateDataCallComplete on the remote"); Rlog.e(TAG, "Failed to onDeactivateDataCallComplete on the remote");
} }
} else {
Rlog.e(TAG, "onDeactivateDataCallComplete: callback is null!");
} }
} }
@@ -116,13 +117,14 @@ public class DataServiceCallback {
* @param result The result code. Must be one of the {@link ResultCode}. * @param result The result code. Must be one of the {@link ResultCode}.
*/ */
public void onSetInitialAttachApnComplete(@ResultCode int result) { public void onSetInitialAttachApnComplete(@ResultCode int result) {
IDataServiceCallback callback = mCallback.get(); if (mCallback != null) {
if (callback != null) {
try { try {
callback.onSetInitialAttachApnComplete(result); mCallback.onSetInitialAttachApnComplete(result);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(TAG, "Failed to onSetInitialAttachApnComplete on the remote"); Rlog.e(TAG, "Failed to onSetInitialAttachApnComplete on the remote");
} }
} else {
Rlog.e(TAG, "onSetInitialAttachApnComplete: callback is null!");
} }
} }
@@ -133,13 +135,14 @@ public class DataServiceCallback {
* @param result The result code. Must be one of the {@link ResultCode}. * @param result The result code. Must be one of the {@link ResultCode}.
*/ */
public void onSetDataProfileComplete(@ResultCode int result) { public void onSetDataProfileComplete(@ResultCode int result) {
IDataServiceCallback callback = mCallback.get(); if (mCallback != null) {
if (callback != null) {
try { try {
callback.onSetDataProfileComplete(result); mCallback.onSetDataProfileComplete(result);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(TAG, "Failed to onSetDataProfileComplete on the remote"); Rlog.e(TAG, "Failed to onSetDataProfileComplete on the remote");
} }
} else {
Rlog.e(TAG, "onSetDataProfileComplete: callback is null!");
} }
} }
@@ -153,13 +156,14 @@ public class DataServiceCallback {
*/ */
public void onRequestDataCallListComplete(@ResultCode int result, public void onRequestDataCallListComplete(@ResultCode int result,
@NonNull List<DataCallResponse> dataCallList) { @NonNull List<DataCallResponse> dataCallList) {
IDataServiceCallback callback = mCallback.get(); if (mCallback != null) {
if (callback != null) {
try { try {
callback.onRequestDataCallListComplete(result, dataCallList); mCallback.onRequestDataCallListComplete(result, dataCallList);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(TAG, "Failed to onRequestDataCallListComplete on the remote"); Rlog.e(TAG, "Failed to onRequestDataCallListComplete on the remote");
} }
} else {
Rlog.e(TAG, "onRequestDataCallListComplete: callback is null!");
} }
} }
@@ -170,14 +174,15 @@ public class DataServiceCallback {
* @param dataCallList List of the current active data connection. * @param dataCallList List of the current active data connection.
*/ */
public void onDataCallListChanged(@NonNull List<DataCallResponse> dataCallList) { public void onDataCallListChanged(@NonNull List<DataCallResponse> dataCallList) {
IDataServiceCallback callback = mCallback.get(); if (mCallback != null) {
if (callback != null) {
try { try {
if (DBG) Rlog.d(TAG, "onDataCallListChanged"); if (DBG) Rlog.d(TAG, "onDataCallListChanged");
callback.onDataCallListChanged(dataCallList); mCallback.onDataCallListChanged(dataCallList);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(TAG, "Failed to onDataCallListChanged on the remote"); Rlog.e(TAG, "Failed to onDataCallListChanged on the remote");
} }
} else {
Rlog.e(TAG, "onDataCallListChanged: callback is null!");
} }
} }
} }