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

Commit 11ef265c authored by Sarah Chin's avatar Sarah Chin Committed by Automerger Merge Worker
Browse files

DisplayInfoController and NetworkTypeController skeleton implementation am: 870a1ae5

Change-Id: I9f75be9078e7cba9f4e3ef97dab746826f0ec28d
parents c3f5658c 870a1ae5
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ import android.os.BatteryManager;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.os.Registrant;
import android.os.RegistrantList;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CarrierConfigManager;
import android.telephony.SignalThresholdInfo;
@@ -83,6 +85,8 @@ public class DeviceStateMonitor extends Handler {

    private final LocalLog mLocalLog = new LocalLog(100);

    private final RegistrantList mPhysicalChannelConfigRegistrants = new RegistrantList();

    private final NetworkRequest mWifiNetworkRequest =
            new NetworkRequest.Builder()
            .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
@@ -492,6 +496,13 @@ public class DeviceStateMonitor extends Handler {
            newFilter |= IndicationFilter.BARRING_INFO;
        }

        // notify PhysicalChannelConfig registrants if state changes
        if ((newFilter & IndicationFilter.PHYSICAL_CHANNEL_CONFIG)
                != (mUnsolicitedResponseFilter & IndicationFilter.PHYSICAL_CHANNEL_CONFIG)) {
            mPhysicalChannelConfigRegistrants.notifyResult(
                    (newFilter & IndicationFilter.PHYSICAL_CHANNEL_CONFIG) != 0);
        }

        setUnsolResponseFilter(newFilter, false);

        // Pull barring info AFTER setting filter, the order matters
@@ -655,6 +666,28 @@ public class DeviceStateMonitor extends Handler {
        return false;
    }

    /**
     * Register for PhysicalChannelConfig notifications changed. On change, msg.obj will be an
     * AsyncResult with a boolean result. AsyncResult.result is true if notifications are enabled
     * and false if they are disabled.
     *
     * @param h Handler to notify
     * @param what msg.what when the message is delivered
     * @param obj AsyncResult.userObj when the message is delivered
     */
    public void registerForPhysicalChannelConfigNotifChanged(Handler h, int what, Object obj) {
        Registrant r = new Registrant(h, what, obj);
        mPhysicalChannelConfigRegistrants.add(r);
    }

    /**
     * Unregister for PhysicalChannelConfig notifications changed.
     * @param h Handler to notify
     */
    public void unregisterForPhysicalChannelConfigNotifChanged(Handler h) {
        mPhysicalChannelConfigRegistrants.remove(h);
    }

    /**
     * @param msg Debug message
     * @param logIntoLocalLog True if log into the local log
+103 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import android.os.Handler;
import android.os.Registrant;
import android.os.RegistrantList;
import android.telephony.TelephonyDisplayInfo;

import com.android.telephony.Rlog;

import java.io.FileDescriptor;
import java.io.PrintWriter;

/**
 * The DisplayInfoController updates and broadcasts all changes to {@link TelephonyDisplayInfo}.
 * It manages all the information necessary for display purposes. Clients can register for display
 * info changes via {@link #registerForTelephonyDisplayInfoChanged} and obtain the current
 * TelephonyDisplayInfo via {@link #getTelephonyDisplayInfo}.
 */
public class DisplayInfoController extends Handler {
    private static final String TAG = "DisplayInfoController";
    private final Phone mPhone;
    private final NetworkTypeController mNetworkTypeController;
    private final RegistrantList mTelephonyDisplayInfoChangedRegistrants = new RegistrantList();
    private TelephonyDisplayInfo mTelephonyDisplayInfo;

    public DisplayInfoController(Phone phone) {
        mPhone = phone;
        mNetworkTypeController = new NetworkTypeController(phone, this);
        mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);
    }

    /**
     * @return the current TelephonyDisplayInfo
     */
    public TelephonyDisplayInfo getTelephonyDisplayInfo() {
        return mTelephonyDisplayInfo;
    }

    /**
     * Update TelephonyDisplayInfo based on network type and override network type, received from
     * NetworkTypeController.
     */
    public void updateTelephonyDisplayInfo() {
        TelephonyDisplayInfo newDisplayInfo = new TelephonyDisplayInfo(
                mPhone.getServiceState().getDataNetworkType(),
                mNetworkTypeController.getOverrideNetworkType());
        if (!newDisplayInfo.equals(mTelephonyDisplayInfo)) {
            Rlog.d(TAG, "TelephonyDisplayInfo changed from " + mTelephonyDisplayInfo + " to "
                    + newDisplayInfo);
            mTelephonyDisplayInfo = newDisplayInfo;
            mTelephonyDisplayInfoChangedRegistrants.notifyRegistrants();
            mPhone.notifyDisplayInfoChanged(mTelephonyDisplayInfo);
        }
    }

    /**
     * Register for TelephonyDisplayInfo changed.
     * @param h Handler to notify
     * @param what msg.what when the message is delivered
     * @param obj msg.obj when the message is delivered
     */
    public void registerForTelephonyDisplayInfoChanged(Handler h, int what, Object obj) {
        Registrant r = new Registrant(h, what, obj);
        mTelephonyDisplayInfoChangedRegistrants.add(r);
    }

    /**
     * Unregister for TelephonyDisplayInfo changed.
     * @param h Handler to notify
     */
    public void unregisterForTelephonyDisplayInfoChanged(Handler h) {
        mTelephonyDisplayInfoChangedRegistrants.remove(h);
    }

    /**
     * Dump the current state.
     */
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("DisplayInfoController:");
        pw.println(" mPhone=" + mPhone.getPhoneName());
        pw.println(" mTelephonyDisplayInfo=" + mTelephonyDisplayInfo.toString());
        pw.flush();
        pw.println(" ***************************************");
        mNetworkTypeController.dump(fd, pw, args);
        pw.flush();
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -282,6 +282,11 @@ public class GsmCdmaPhone extends Phone {
        mDeviceStateMonitor = mTelephonyComponentFactory.inject(DeviceStateMonitor.class.getName())
                .makeDeviceStateMonitor(this);

        // DisplayInfoController creates an OverrideNetworkTypeController, which uses
        // DeviceStateMonitor so needs to be crated after it is instantiated.
        mDisplayInfoController = mTelephonyComponentFactory.inject(
                DisplayInfoController.class.getName()).makeDisplayInfoController(this);

        mSST.registerForVoiceRegStateOrRatChanged(this, EVENT_VRS_OR_RAT_CHANGED, null);

        mSettingsObserver = new SettingsObserver(context, this);
@@ -581,6 +586,16 @@ public class GsmCdmaPhone extends Phone {
        return mTransportManager;
    }

    @Override
    public DeviceStateMonitor getDeviceStateMonitor() {
        return mDeviceStateMonitor;
    }

    @Override
    public DisplayInfoController getDisplayInfoController() {
        return mDisplayInfoController;
    }

    @Override
    public void updateVoiceMail() {
        if (isPhoneTypeGsm()) {
+956 −0

File added.

Preview size limit exceeded, changes collapsed.

+26 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private final String mActionDetached;
    private final String mActionAttached;
    protected DeviceStateMonitor mDeviceStateMonitor;
    protected DisplayInfoController mDisplayInfoController;
    protected TransportManager mTransportManager;
    protected DataEnabledSettings mDataEnabledSettings;
    // Used for identify the carrier of current subscription
@@ -1814,6 +1815,20 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return null;
    }

    /**
     * Retrieves the DeviceStateMonitor of the phone instance.
     */
    public DeviceStateMonitor getDeviceStateMonitor() {
        return null;
    }

    /**
     * Retrieves the DisplayInfoController of the phone instance.
     */
    public DisplayInfoController getDisplayInfoController() {
        return null;
    }

    /**
     * Update voice activation state
     */
@@ -4359,6 +4374,17 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            pw.println("++++++++++++++++++++++++++++++++");
        }

        if (getDisplayInfoController() != null) {
            try {
                getDisplayInfoController().dump(fd, pw, args);
            } catch (Exception e) {
                e.printStackTrace();
            }

            pw.flush();
            pw.println("++++++++++++++++++++++++++++++++");
        }

        if (mCarrierResolver != null) {
            try {
                mCarrierResolver.dump(fd, pw, args);
Loading