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

Commit e32c7c48 authored by Aaron Huang's avatar Aaron Huang Committed by Gerrit Code Review
Browse files

Merge "Remove PersistableBundle(Bundle) usage from ConnectivityService"

parents 1297f901 121267c6
Loading
Loading
Loading
Loading
+13 −19
Original line number Original line Diff line number Diff line
@@ -3194,16 +3194,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
            // Invoke ConnectivityReport generation for this Network test event.
            // Invoke ConnectivityReport generation for this Network test event.
            final NetworkAgentInfo nai = getNetworkAgentInfoForNetId(mNetId);
            final NetworkAgentInfo nai = getNetworkAgentInfoForNetId(mNetId);
            if (nai == null) return;
            if (nai == null) return;
            final Message m = mConnectivityDiagnosticsHandler.obtainMessage(
                    ConnectivityDiagnosticsHandler.EVENT_NETWORK_TESTED,
                    new ConnectivityReportEvent(p.timestampMillis, nai));


            final PersistableBundle extras = new PersistableBundle();
            final PersistableBundle extras = new PersistableBundle();
            extras.putInt(KEY_NETWORK_VALIDATION_RESULT, p.result);
            extras.putInt(KEY_NETWORK_VALIDATION_RESULT, p.result);
            extras.putInt(KEY_NETWORK_PROBES_SUCCEEDED_BITMASK, p.probesSucceeded);
            extras.putInt(KEY_NETWORK_PROBES_SUCCEEDED_BITMASK, p.probesSucceeded);
            extras.putInt(KEY_NETWORK_PROBES_ATTEMPTED_BITMASK, p.probesAttempted);
            extras.putInt(KEY_NETWORK_PROBES_ATTEMPTED_BITMASK, p.probesAttempted);


            m.setData(new Bundle(extras));
            ConnectivityReportEvent reportEvent =
                    new ConnectivityReportEvent(p.timestampMillis, nai, extras);
            final Message m = mConnectivityDiagnosticsHandler.obtainMessage(
                    ConnectivityDiagnosticsHandler.EVENT_NETWORK_TESTED, reportEvent);
            mConnectivityDiagnosticsHandler.sendMessage(m);
            mConnectivityDiagnosticsHandler.sendMessage(m);
        }
        }


@@ -3290,8 +3290,7 @@ public class ConnectivityService extends IConnectivityManager.Stub


        final Message msg = mConnectivityDiagnosticsHandler.obtainMessage(
        final Message msg = mConnectivityDiagnosticsHandler.obtainMessage(
                ConnectivityDiagnosticsHandler.EVENT_DATA_STALL_SUSPECTED, detectionMethod, netId,
                ConnectivityDiagnosticsHandler.EVENT_DATA_STALL_SUSPECTED, detectionMethod, netId,
                p.timestampMillis);
                new Pair<>(p.timestampMillis, extras));
        msg.setData(new Bundle(extras));


        // NetworkStateTrackerHandler currently doesn't take any actions based on data
        // NetworkStateTrackerHandler currently doesn't take any actions based on data
        // stalls so send the message directly to ConnectivityDiagnosticsHandler and avoid
        // stalls so send the message directly to ConnectivityDiagnosticsHandler and avoid
@@ -8267,24 +8266,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
                    final ConnectivityReportEvent reportEvent =
                    final ConnectivityReportEvent reportEvent =
                            (ConnectivityReportEvent) msg.obj;
                            (ConnectivityReportEvent) msg.obj;


                    // This is safe because {@link
                    handleNetworkTestedWithExtras(reportEvent, reportEvent.mExtras);
                    // NetworkMonitorCallbacks#notifyNetworkTestedWithExtras} receives a
                    // PersistableBundle and converts it to the Bundle in the incoming Message. If
                    // {@link NetworkMonitorCallbacks#notifyNetworkTested} is called, msg.data will
                    // not be set. This is also safe, as msg.getData() will return an empty Bundle.
                    final PersistableBundle extras = new PersistableBundle(msg.getData());
                    handleNetworkTestedWithExtras(reportEvent, extras);
                    break;
                    break;
                }
                }
                case EVENT_DATA_STALL_SUSPECTED: {
                case EVENT_DATA_STALL_SUSPECTED: {
                    final NetworkAgentInfo nai = getNetworkAgentInfoForNetId(msg.arg2);
                    final NetworkAgentInfo nai = getNetworkAgentInfoForNetId(msg.arg2);
                    final Pair<Long, PersistableBundle> arg =
                            (Pair<Long, PersistableBundle>) msg.obj;
                    if (nai == null) break;
                    if (nai == null) break;


                    // This is safe because NetworkMonitorCallbacks#notifyDataStallSuspected
                    handleDataStallSuspected(nai, arg.first, msg.arg1, arg.second);
                    // receives a PersistableBundle and converts it to the Bundle in the incoming
                    // Message.
                    final PersistableBundle extras = new PersistableBundle(msg.getData());
                    handleDataStallSuspected(nai, (long) msg.obj, msg.arg1, extras);
                    break;
                    break;
                }
                }
                case EVENT_NETWORK_CONNECTIVITY_REPORTED: {
                case EVENT_NETWORK_CONNECTIVITY_REPORTED: {
@@ -8348,10 +8339,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
    private static class ConnectivityReportEvent {
    private static class ConnectivityReportEvent {
        private final long mTimestampMillis;
        private final long mTimestampMillis;
        @NonNull private final NetworkAgentInfo mNai;
        @NonNull private final NetworkAgentInfo mNai;
        private final PersistableBundle mExtras;


        private ConnectivityReportEvent(long timestampMillis, @NonNull NetworkAgentInfo nai) {
        private ConnectivityReportEvent(long timestampMillis, @NonNull NetworkAgentInfo nai,
                PersistableBundle p) {
            mTimestampMillis = timestampMillis;
            mTimestampMillis = timestampMillis;
            mNai = nai;
            mNai = nai;
            mExtras = p;
        }
        }
    }
    }