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

Commit 3f90e4a6 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6282804 from 302183b6 to rvc-release

Change-Id: Iae0d4074ebefd80e12d4e3c3f6e15459769a6de0
parents 7aa242bb 302183b6
Loading
Loading
Loading
Loading
+14 −41
Original line number Diff line number Diff line
@@ -328,71 +328,44 @@ public class DeviceStateMonitor extends Handler {
     * trigger the network update unsolicited response.
     */
    private boolean shouldTurnOffFullNetworkUpdate() {
        // We should not turn off full network update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off full network state update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if data dormancy status update should be turned off.
     */
    private boolean shouldTurnOffDormancyUpdate() {
        // We should not turn off data dormancy update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off data dormancy update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if link capacity estimate update should be turned off.
     */
    private boolean shouldTurnOffLinkCapacityEstimate() {
        // We should not turn off link capacity update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off link capacity update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if physical channel config update should be turned off.
     */
    private boolean shouldTurnOffPhysicalChannelConfig() {
        // We should not turn off physical channel update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off physical channel config update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if BarryingInfo update should be turned off.
     */
    private boolean shouldTurnOffBarringInfo() {
        // We should not turn off BarringInfo update if one of the following condition is true.
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * A common policy to determine if we should turn off unnecessary indications for power saving.
     *
     * @return True if the response filter update should be turned off.
     */
    private boolean shouldTurnOffHighPowerConsumptionIndications() {
        // We should not turn off update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When the tethering is on.
+2 −8
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -265,13 +264,7 @@ public class DcTracker extends Handler {

    /** kept in sync with mApnContexts
     * Higher numbers are higher priority and sorted so highest priority is first */
    private final PriorityQueue<ApnContext>mPrioritySortedApnContexts =
            new PriorityQueue<ApnContext>(5,
            new Comparator<ApnContext>() {
                public int compare(ApnContext c1, ApnContext c2) {
                    return c2.getPriority() - c1.getPriority();
                }
            } );
    private final ArrayList<ApnContext> mPrioritySortedApnContexts = new ArrayList<>();

    /** all APN settings applicable to the current carrier */
    private ArrayList<ApnSetting> mAllApnSettings = new ArrayList<>();
@@ -1071,6 +1064,7 @@ public class DcTracker extends Handler {
            log("initApnContexts: apnContext=" + ApnSetting.getApnTypeString(
                    apnConfigType.getType()));
        }
        mPrioritySortedApnContexts.sort((c1, c2) -> c2.getPriority() - c1.getPriority());
        if (VDBG) log("initApnContexts: X mApnContexts=" + mApnContexts);
    }

+43 −29
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.AsyncResult;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.SystemProperties;
import android.telephony.CarrierConfigManager;
@@ -57,6 +58,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
@@ -77,8 +79,7 @@ public class EmergencyNumberTracker extends Handler {
    private static final String EMERGENCY_NUMBER_DB_OTA_FILE_NAME = "emergency_number_db";
    private static final String EMERGENCY_NUMBER_DB_OTA_FILE_PATH =
            "misc/emergencynumberdb/" + EMERGENCY_NUMBER_DB_OTA_FILE_NAME;
    private File mEmergencyNumberDbOtaFilePath = new File(Environment.getDataDirectory(),
            EMERGENCY_NUMBER_DB_OTA_FILE_PATH);
    private FileInputStream mEmergencyNumberDbOtaFileInputStream = null;

    /** @hide */
    public static boolean DBG = false;
@@ -128,7 +129,7 @@ public class EmergencyNumberTracker extends Handler {
    /** Event indicating the update for the OTA emergency number database. */
    private static final int EVENT_UPDATE_OTA_EMERGENCY_NUMBER_DB = 5;
    /** Event indicating the override for the test OTA emergency number database. */
    private static final int EVENT_OVERRIDE_TEST_OTA_EMERGENCY_NUMBER_DB_FILE_PATH = 6;
    private static final int EVENT_OVERRIDE_OTA_EMERGENCY_NUMBER_DB_FILE_PATH = 6;

    private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
        @Override
@@ -175,6 +176,14 @@ public class EmergencyNumberTracker extends Handler {
    public EmergencyNumberTracker(Phone phone, CommandsInterface ci) {
        mPhone = phone;
        mCi = ci;

        try {
            mEmergencyNumberDbOtaFileInputStream = new FileInputStream(
                    new File(Environment.getDataDirectory(), EMERGENCY_NUMBER_DB_OTA_FILE_PATH));
        } catch (FileNotFoundException ex) {
            loge("Initialize ota emergency database file input failure: " + ex);
        }

        if (mPhone != null) {
            CarrierConfigManager configMgr = (CarrierConfigManager)
                    mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
@@ -252,12 +261,11 @@ public class EmergencyNumberTracker extends Handler {
            case EVENT_UPDATE_OTA_EMERGENCY_NUMBER_DB:
                updateOtaEmergencyNumberListDatabaseAndNotify();
                break;
            case EVENT_OVERRIDE_TEST_OTA_EMERGENCY_NUMBER_DB_FILE_PATH:
            case EVENT_OVERRIDE_OTA_EMERGENCY_NUMBER_DB_FILE_PATH:
                if (msg.obj == null) {
                    loge("EVENT_OVERRIDE_TEST_OTA_EMERGENCY_NUMBER_DB_FILE_PATH:"
                            + " Result from otaFilePath is null.");
                    overrideOtaEmergencyNumberDbFilePath(null);
                } else {
                    overrideTestOtaEmergencyNumberDbFilePath((String) msg.obj);
                    overrideOtaEmergencyNumberDbFilePath((ParcelFileDescriptor) msg.obj);
                }
                break;
        }
@@ -358,13 +366,24 @@ public class EmergencyNumberTracker extends Handler {
    }

    /**
     * Override the test OTA Emergency Number database file path.
     * Override the OTA Emergency Number database file path.
     *
     * @hide
     */
    public void updateOtaEmergencyNumberDbFilePath(ParcelFileDescriptor otaParcelFileDescriptor) {
        this.obtainMessage(
                EVENT_OVERRIDE_OTA_EMERGENCY_NUMBER_DB_FILE_PATH,
                        otaParcelFileDescriptor).sendToTarget();
    }

    /**
     * Override the OTA Emergency Number database file path.
     *
     * @hide
     */
    public void updateTestOtaEmergencyNumberDbFilePath(String otaFilePath) {
    public void resetOtaEmergencyNumberDbFilePath() {
        this.obtainMessage(
                EVENT_OVERRIDE_TEST_OTA_EMERGENCY_NUMBER_DB_FILE_PATH, otaFilePath).sendToTarget();
                EVENT_OVERRIDE_OTA_EMERGENCY_NUMBER_DB_FILE_PATH, null).sendToTarget();
    }

    private EmergencyNumber convertEmergencyNumberFromEccInfo(EccInfo eccInfo, String countryIso) {
@@ -466,8 +485,7 @@ public class EmergencyNumberTracker extends Handler {
        // Read the OTA emergency number database
        List<EmergencyNumber> updatedOtaEmergencyNumberList = new ArrayList<>();
        try {
            inputStream = new BufferedInputStream(
                    new FileInputStream(mEmergencyNumberDbOtaFilePath));
            inputStream = new BufferedInputStream(mEmergencyNumberDbOtaFileInputStream);
            allEccMessages = ProtobufEccData.AllInfo.parseFrom(readInputStreamToByteArray(
                    new GZIPInputStream(inputStream)));
            logd(mCountryIso + " ota emergency database is loaded. Ver: " + otaDatabaseVersion);
@@ -564,23 +582,19 @@ public class EmergencyNumberTracker extends Handler {
        notifyEmergencyNumberList();
    }

    private void overrideTestOtaEmergencyNumberDbFilePath(String otaFilePath) {
        logd("overrideTestOtaEmergencyNumberDbFilePath:" + otaFilePath);
        if (otaFilePath.equals("RESET")) {
            mEmergencyNumberDbOtaFilePath = new File(Environment.getDataDirectory(),
                    EMERGENCY_NUMBER_DB_OTA_FILE_PATH);
            return;
        }
        String[] otaFilePathParts = otaFilePath.split("@");
        if (otaFilePathParts.length != 2) {
            loge("overrideTestOtaEmergencyNumberDbFilePath: otaFilePath length error");
            return;
        }
        if (otaFilePathParts[0].equals("sdcard")) {
            mEmergencyNumberDbOtaFilePath = new File(
                    Environment.getExternalStorageDirectory(), otaFilePathParts[1]);
    private void overrideOtaEmergencyNumberDbFilePath(
            ParcelFileDescriptor otaParcelableFileDescriptor) {
        logd("overrideOtaEmergencyNumberDbFilePath:" + otaParcelableFileDescriptor);
        try {
            if (otaParcelableFileDescriptor == null) {
                mEmergencyNumberDbOtaFileInputStream = new FileInputStream(
                    new File(Environment.getDataDirectory(), EMERGENCY_NUMBER_DB_OTA_FILE_PATH));
            } else {
            loge("overrideTestOtaEmergencyNumberDbFilePath: otaFilePath prefix error");
                mEmergencyNumberDbOtaFileInputStream = new FileInputStream(
                    otaParcelableFileDescriptor.getFileDescriptor());
            }
        } catch (FileNotFoundException ex) {
            loge("Override ota emergency database failure: " + ex);
        }
    }