Loading src/java/com/android/internal/telephony/DeviceStateMonitor.java +33 −0 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,8 @@ import android.os.BatteryManager; import android.os.Handler; import android.os.Handler; import android.os.Message; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager; import android.os.Registrant; import android.os.RegistrantList; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.CarrierConfigManager; import android.telephony.CarrierConfigManager; import android.telephony.SignalThresholdInfo; import android.telephony.SignalThresholdInfo; Loading Loading @@ -83,6 +85,8 @@ public class DeviceStateMonitor extends Handler { private final LocalLog mLocalLog = new LocalLog(100); private final LocalLog mLocalLog = new LocalLog(100); private final RegistrantList mPhysicalChannelConfigRegistrants = new RegistrantList(); private final NetworkRequest mWifiNetworkRequest = private final NetworkRequest mWifiNetworkRequest = new NetworkRequest.Builder() new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) Loading Loading @@ -492,6 +496,13 @@ public class DeviceStateMonitor extends Handler { newFilter |= IndicationFilter.BARRING_INFO; 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); setUnsolResponseFilter(newFilter, false); // Pull barring info AFTER setting filter, the order matters // Pull barring info AFTER setting filter, the order matters Loading Loading @@ -655,6 +666,28 @@ public class DeviceStateMonitor extends Handler { return false; 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 msg Debug message * @param logIntoLocalLog True if log into the local log * @param logIntoLocalLog True if log into the local log Loading src/java/com/android/internal/telephony/DisplayInfoController.java 0 → 100644 +103 −0 Original line number Original line 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(); } } src/java/com/android/internal/telephony/GsmCdmaPhone.java +19 −4 Original line number Original line Diff line number Diff line Loading @@ -264,8 +264,16 @@ public class GsmCdmaPhone extends Phone { this, this.mCi); this, this.mCi); mDataEnabledSettings = mTelephonyComponentFactory mDataEnabledSettings = mTelephonyComponentFactory .inject(DataEnabledSettings.class.getName()).makeDataEnabledSettings(this); .inject(DataEnabledSettings.class.getName()).makeDataEnabledSettings(this); 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); // DcTracker uses SST so needs to be created after it is instantiated // DcTracker uses ServiceStateTracker and DisplayInfoController so needs to be created // after they are instantiated for (int transport : mTransportManager.getAvailableTransports()) { for (int transport : mTransportManager.getAvailableTransports()) { mDcTrackers.put(transport, mTelephonyComponentFactory.inject(DcTracker.class.getName()) mDcTrackers.put(transport, mTelephonyComponentFactory.inject(DcTracker.class.getName()) .makeDcTracker(this, transport)); .makeDcTracker(this, transport)); Loading @@ -279,9 +287,6 @@ public class GsmCdmaPhone extends Phone { EVENT_SET_CARRIER_DATA_ENABLED, null, false); EVENT_SET_CARRIER_DATA_ENABLED, null, false); mSST.registerForNetworkAttached(this, EVENT_REGISTERED_TO_NETWORK, null); mSST.registerForNetworkAttached(this, EVENT_REGISTERED_TO_NETWORK, null); mDeviceStateMonitor = mTelephonyComponentFactory.inject(DeviceStateMonitor.class.getName()) .makeDeviceStateMonitor(this); mSST.registerForVoiceRegStateOrRatChanged(this, EVENT_VRS_OR_RAT_CHANGED, null); mSST.registerForVoiceRegStateOrRatChanged(this, EVENT_VRS_OR_RAT_CHANGED, null); mSettingsObserver = new SettingsObserver(context, this); mSettingsObserver = new SettingsObserver(context, this); Loading Loading @@ -585,6 +590,16 @@ public class GsmCdmaPhone extends Phone { return mTransportManager; return mTransportManager; } } @Override public DeviceStateMonitor getDeviceStateMonitor() { return mDeviceStateMonitor; } @Override public DisplayInfoController getDisplayInfoController() { return mDisplayInfoController; } @Override @Override public void updateVoiceMail() { public void updateVoiceMail() { if (isPhoneTypeGsm()) { if (isPhoneTypeGsm()) { Loading Loading
src/java/com/android/internal/telephony/DeviceStateMonitor.java +33 −0 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,8 @@ import android.os.BatteryManager; import android.os.Handler; import android.os.Handler; import android.os.Message; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager; import android.os.Registrant; import android.os.RegistrantList; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.CarrierConfigManager; import android.telephony.CarrierConfigManager; import android.telephony.SignalThresholdInfo; import android.telephony.SignalThresholdInfo; Loading Loading @@ -83,6 +85,8 @@ public class DeviceStateMonitor extends Handler { private final LocalLog mLocalLog = new LocalLog(100); private final LocalLog mLocalLog = new LocalLog(100); private final RegistrantList mPhysicalChannelConfigRegistrants = new RegistrantList(); private final NetworkRequest mWifiNetworkRequest = private final NetworkRequest mWifiNetworkRequest = new NetworkRequest.Builder() new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) Loading Loading @@ -492,6 +496,13 @@ public class DeviceStateMonitor extends Handler { newFilter |= IndicationFilter.BARRING_INFO; 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); setUnsolResponseFilter(newFilter, false); // Pull barring info AFTER setting filter, the order matters // Pull barring info AFTER setting filter, the order matters Loading Loading @@ -655,6 +666,28 @@ public class DeviceStateMonitor extends Handler { return false; 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 msg Debug message * @param logIntoLocalLog True if log into the local log * @param logIntoLocalLog True if log into the local log Loading
src/java/com/android/internal/telephony/DisplayInfoController.java 0 → 100644 +103 −0 Original line number Original line 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(); } }
src/java/com/android/internal/telephony/GsmCdmaPhone.java +19 −4 Original line number Original line Diff line number Diff line Loading @@ -264,8 +264,16 @@ public class GsmCdmaPhone extends Phone { this, this.mCi); this, this.mCi); mDataEnabledSettings = mTelephonyComponentFactory mDataEnabledSettings = mTelephonyComponentFactory .inject(DataEnabledSettings.class.getName()).makeDataEnabledSettings(this); .inject(DataEnabledSettings.class.getName()).makeDataEnabledSettings(this); 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); // DcTracker uses SST so needs to be created after it is instantiated // DcTracker uses ServiceStateTracker and DisplayInfoController so needs to be created // after they are instantiated for (int transport : mTransportManager.getAvailableTransports()) { for (int transport : mTransportManager.getAvailableTransports()) { mDcTrackers.put(transport, mTelephonyComponentFactory.inject(DcTracker.class.getName()) mDcTrackers.put(transport, mTelephonyComponentFactory.inject(DcTracker.class.getName()) .makeDcTracker(this, transport)); .makeDcTracker(this, transport)); Loading @@ -279,9 +287,6 @@ public class GsmCdmaPhone extends Phone { EVENT_SET_CARRIER_DATA_ENABLED, null, false); EVENT_SET_CARRIER_DATA_ENABLED, null, false); mSST.registerForNetworkAttached(this, EVENT_REGISTERED_TO_NETWORK, null); mSST.registerForNetworkAttached(this, EVENT_REGISTERED_TO_NETWORK, null); mDeviceStateMonitor = mTelephonyComponentFactory.inject(DeviceStateMonitor.class.getName()) .makeDeviceStateMonitor(this); mSST.registerForVoiceRegStateOrRatChanged(this, EVENT_VRS_OR_RAT_CHANGED, null); mSST.registerForVoiceRegStateOrRatChanged(this, EVENT_VRS_OR_RAT_CHANGED, null); mSettingsObserver = new SettingsObserver(context, this); mSettingsObserver = new SettingsObserver(context, this); Loading Loading @@ -585,6 +590,16 @@ public class GsmCdmaPhone extends Phone { return mTransportManager; return mTransportManager; } } @Override public DeviceStateMonitor getDeviceStateMonitor() { return mDeviceStateMonitor; } @Override public DisplayInfoController getDisplayInfoController() { return mDisplayInfoController; } @Override @Override public void updateVoiceMail() { public void updateVoiceMail() { if (isPhoneTypeGsm()) { if (isPhoneTypeGsm()) { Loading