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

Commit f4fe4e38 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8269650 from cb948e37 to tm-d1-release

Change-Id: I18331e5c39babf5e2a07f20e83ec68302f63f271
parents 976b0f64 cb948e37
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -71,7 +71,13 @@ public class DataResponse extends IRadioDataResponse.Stub {
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void deactivateDataCallResponse(RadioResponseInfo responseInfo) {
        RadioResponse.responseVoid(RIL.DATA_SERVICE, mRil, responseInfo);
        RILRequest rr = mRil.processResponse(RIL.DATA_SERVICE, responseInfo);

        if (rr != null) {
            int response = responseInfo.error;
            RadioResponse.sendMessageResponse(rr.mResult, response);
            mRil.processResponseDone(rr, responseInfo, response);
        }
    }

    /**
+32 −17
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.telephony.RadioAccessFamily;
import android.telephony.RadioAccessSpecifier;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
@@ -829,12 +830,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                ar = (AsyncResult) msg.obj;
                if (ar.exception == null) {
                    try {
                        int mUsageSettingFromModem = ((int[]) ar.result)[0];
                        mUsageSettingFromModem = ((int[]) ar.result)[0];
                    } catch (NullPointerException | ClassCastException e) {
                        Rlog.e(LOG_TAG, "Invalid response for usage setting " + ar.result);
                        break;
                    }

                    logd("Received mUsageSettingFromModem=" + mUsageSettingFromModem);
                    if (mUsageSettingFromModem != mPreferredUsageSetting) {
                        mCi.setUsageSetting(obtainMessage(EVENT_SET_USAGE_SETTING_DONE),
                                mPreferredUsageSetting);
@@ -4512,17 +4514,27 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        updateUsageSetting();
    }

    // Need a magic little helper function to avoid a static call via SubscriptionManager
    private int getPreferredUsageSetting() {
        String result = SubscriptionController.getInstance().getSubscriptionProperty(
                getSubId(), SubscriptionManager.USAGE_SETTING);
        try {
            return Integer.parseInt(result);
        } catch (NumberFormatException nfe) {
        }
    private int getResolvedUsageSetting(int subId) {
        SubscriptionInfo subInfo = SubscriptionController.getInstance().getSubscriptionInfo(subId);

        if (subInfo == null
                || subInfo.getUsageSetting() == SubscriptionManager.USAGE_SETTING_UNKNOWN) {
            loge("Failed to get SubscriptionInfo for subId=" + subId);
            return SubscriptionManager.USAGE_SETTING_UNKNOWN;
        }

        if (subInfo.getUsageSetting() != SubscriptionManager.USAGE_SETTING_DEFAULT) {
            return subInfo.getUsageSetting();
        }

        if (subInfo.isOpportunistic()) {
            return SubscriptionManager.USAGE_SETTING_DATA_CENTRIC;
        } else {
            return mContext.getResources().getInteger(
                    com.android.internal.R.integer.config_default_cellular_usage_setting);
        }
    }

    /**
     * Attempt to update the usage setting.
     *
@@ -4534,20 +4546,23 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        final int subId = getSubId();
        if (!SubscriptionManager.isValidSubscriptionId(subId)) return false;

        int lastPreferredUsageSetting = mPreferredUsageSetting;
        final int lastPreferredUsageSetting = mPreferredUsageSetting;

        int mPreferredUsageSetting = getPreferredUsageSetting();
        mPreferredUsageSetting = getResolvedUsageSetting(subId);
        if (mPreferredUsageSetting == SubscriptionManager.USAGE_SETTING_UNKNOWN) {
            loge("Usage Setting is Supported but Preferred Setting Unknown!");
            return false;
        }

        // We might get a lot of requests to update, so definitely we don't want to hammer
        // the modem with multiple duplicate requests for usage setting updates
        if (mPreferredUsageSetting == lastPreferredUsageSetting) return false;

        // If the user prefers the default setting, we now need to resolve that into a concrete
        // value, since the modem will have a "concrete" value.
        if (mPreferredUsageSetting == SubscriptionManager.USAGE_SETTING_DEFAULT) {
            mPreferredUsageSetting = mContext.getResources().getInteger(
                    com.android.internal.R.integer.config_default_cellular_usage_setting);
        }
        String logStr = "mPreferredUsageSetting=" + mPreferredUsageSetting
                + ", lastPreferredUsageSetting=" + lastPreferredUsageSetting
                + ", mUsageSettingFromModem=" + mUsageSettingFromModem;
        logd(logStr);
        mLocalLog.log(logStr);

        // If the modem value hasn't been updated, request it.
        if (mUsageSettingFromModem == SubscriptionManager.USAGE_SETTING_UNKNOWN) {
+16 −1
Original line number Diff line number Diff line
@@ -5662,7 +5662,22 @@ public class RIL extends BaseCommands implements CommandsInterface {
            }
            s = sb.toString();
        } else {
            // Check if toString() was overridden. Java classes created from HIDL have a built-in
            // toString() method, but AIDL classes only have it if the parcelable contains a
            // @JavaDerive annotation. Manually convert to String as a backup for AIDL parcelables
            // missing the annotation.
            boolean toStringExists = false;
            try {
                toStringExists = ret.getClass().getMethod("toString").getDeclaringClass()
                        != Object.class;
            } catch (NoSuchMethodException e) {
                Rlog.e(RILJ_LOG_TAG, e.getMessage());
            }
            if (toStringExists) {
                s = ret.toString();
            } else {
                s = RILUtils.convertToString(ret) + " [convertToString]";
            }
        }
        return s;
    }
+96 −0
Original line number Diff line number Diff line
@@ -349,6 +349,10 @@ import com.android.telephony.Rlog;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -356,6 +360,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -379,6 +384,10 @@ public class RILUtils {
    public static final String RADIO_POWER_FAILURE_NO_RF_CALIBRATION_UUID =
            "316f3801-fa21-4954-a42f-0041eada3b33";

    private static final Set<Class> WRAPPER_CLASSES = new HashSet(Arrays.asList(
            Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class,
            Float.class, Double.class));

    /**
     * Convert to PersoSubstate defined in radio/1.5/types.hal
     * @param persoType PersoSubState type
@@ -5156,6 +5165,93 @@ public class RILUtils {
        return caps;
    }

    private static boolean isPrimitiveOrWrapper(Class c) {
        return c.isPrimitive() || WRAPPER_CLASSES.contains(c);
    }

    /**
     * Return a general String representation of a class
     * @param o The object to convert to String
     * @return A string containing all public non-static local variables of a class
     */
    public static String convertToString(Object o) {
        if (isPrimitiveOrWrapper(o.getClass()) || o.getClass() == String.class) return o.toString();
        if (o.getClass().isArray()) {
            // Special handling for arrays
            StringBuilder sb = new StringBuilder("[");
            boolean added = false;
            for (Object element : (Object[]) o) {
                sb.append(convertToString(element)).append(", ");
                added = true;
            }
            if (added) {
                // Remove extra ,
                sb.delete(sb.length() - 2, sb.length());
            }
            sb.append("]");
            return sb.toString();
        }
        StringBuilder sb = new StringBuilder(o.getClass().getSimpleName());
        sb.append("{");
        Field[] fields = o.getClass().getDeclaredFields();
        int tag = -1;
        try {
            tag = (int) o.getClass().getDeclaredMethod("getTag").invoke(o);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            loge(e.getMessage());
        }
        if (tag != -1) {
            // Special handling for unions
            String tagName = null;
            try {
                Method method = o.getClass().getDeclaredMethod("_tagString", int.class);
                method.setAccessible(true);
                tagName = (String) method.invoke(o, tag);
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                loge(e.getMessage());
            }
            if (tagName != null) {
                sb.append(tagName);
                sb.append("=");
                // From tag, create method name getTag
                String getTagMethod = "get" + tagName.substring(0, 1).toUpperCase(Locale.ROOT)
                        + tagName.substring(1);
                Object val = null;
                try {
                    val = o.getClass().getDeclaredMethod(getTagMethod).invoke(o);
                } catch (NoSuchMethodException | IllegalAccessException
                        | InvocationTargetException e) {
                    loge(e.getMessage());
                }
                if (val != null) {
                    sb.append(convertToString(val));
                }
            }
        } else {
            boolean added = false;
            for (Field field : fields) {
                // Ignore static variables
                if (Modifier.isStatic(field.getModifiers())) continue;
                sb.append(field.getName()).append("=");
                Object val = null;
                try {
                    val = field.get(o);
                } catch (IllegalAccessException e) {
                    loge(e.getMessage());
                }
                if (val == null) continue;
                sb.append(convertToString(val)).append(", ");
                added = true;
            }
            if (added) {
                // Remove extra ,
                sb.delete(sb.length() - 2, sb.length());
            }
        }
        sb.append("}");
        return sb.toString();
    }

    private static void logd(String log) {
        Rlog.d("RILUtils", log);
    }
+7 −1
Original line number Diff line number Diff line
@@ -740,7 +740,13 @@ public class RadioResponse extends IRadioResponse.Stub {
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void deactivateDataCallResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RILRequest rr = mRil.processResponse(responseInfo);

        if (rr != null) {
            int response = responseInfo.error;
            sendMessageResponse(rr.mResult, response);
            mRil.processResponseDone(rr, responseInfo, response);
        }
    }

    /**
Loading