use of com.android.internal.telephony.metrics.MetricsCollector in project android_frameworks_opt_telephony by LineageOS.
the class PhoneFactory method makeDefaultPhone.
/**
* FIXME replace this with some other way of making these
* instances
*/
@UnsupportedAppUsage
public static void makeDefaultPhone(Context context) {
synchronized (sLockProxyPhones) {
if (!sMadeDefaults) {
sContext = context;
// create the telephony device controller.
TelephonyDevController.create();
TelephonyMetrics metrics = TelephonyMetrics.getInstance();
metrics.setContext(context);
int retryCount = 0;
for (; ; ) {
boolean hasException = false;
retryCount++;
try {
// use UNIX domain socket to
// prevent subsequent initialization
new LocalServerSocket("com.android.internal.telephony");
} catch (java.io.IOException ex) {
hasException = true;
}
if (!hasException) {
break;
} else if (retryCount > SOCKET_OPEN_MAX_RETRY) {
throw new RuntimeException("PhoneFactory probably already running");
} else {
try {
Thread.sleep(SOCKET_OPEN_RETRY_MILLIS);
} catch (InterruptedException er) {
}
}
}
// register statsd pullers.
sMetricsCollector = new MetricsCollector(context);
sPhoneNotifier = new DefaultPhoneNotifier(context);
int cdmaSubscription = CdmaSubscriptionSourceManager.getDefault(context);
Rlog.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription);
/* In case of multi SIM mode two instances of Phone, RIL are created,
where as in single SIM mode only instance. isMultiSimEnabled() function checks
whether it is single SIM or multi SIM mode */
int numPhones = TelephonyManager.getDefault().getActiveModemCount();
int[] networkModes = new int[numPhones];
sPhones = new Phone[numPhones];
sCommandsInterfaces = new RIL[numPhones];
sTelephonyNetworkFactories = new TelephonyNetworkFactory[numPhones];
for (int i = 0; i < numPhones; i++) {
// reads the system properties and makes commandsinterface
// Get preferred network type.
networkModes[i] = RILConstants.PREFERRED_NETWORK_MODE;
Rlog.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkModes[i]));
sCommandsInterfaces[i] = new RIL(context, networkModes[i], cdmaSubscription, i);
}
// Instantiate UiccController so that all other classes can just
// call getInstance()
sUiccController = UiccController.make(context);
Rlog.i(LOG_TAG, "Creating SubscriptionController");
TelephonyComponentFactory.getInstance().inject(SubscriptionController.class.getName()).initSubscriptionController(context);
TelephonyComponentFactory.getInstance().inject(MultiSimSettingController.class.getName()).initMultiSimSettingController(context, SubscriptionController.getInstance());
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_EUICC)) {
sEuiccController = EuiccController.init(context);
sEuiccCardController = EuiccCardController.init(context);
}
for (int i = 0; i < numPhones; i++) {
sPhones[i] = createPhone(context, i);
}
// FIXME: needs to be done in a more controlled manner in the future.
if (numPhones > 0)
sPhone = sPhones[0];
// Ensure that we have a default SMS app. Requesting the app with
// updateIfNeeded set to true is enough to configure a default SMS app.
ComponentName componentName = SmsApplication.getDefaultSmsApplication(context, true);
String packageName = "NONE";
if (componentName != null) {
packageName = componentName.getPackageName();
}
Rlog.i(LOG_TAG, "defaultSmsApplication: " + packageName);
// Set up monitor to watch for changes to SMS packages
SmsApplication.initSmsPackageMonitor(context);
sMadeDefaults = true;
Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater ");
HandlerThread pfhandlerThread = new HandlerThread("PhoneFactoryHandlerThread");
pfhandlerThread.start();
sSubInfoRecordUpdater = TelephonyComponentFactory.getInstance().inject(SubscriptionInfoUpdater.class.getName()).makeSubscriptionInfoUpdater(pfhandlerThread.getLooper(), context, sCommandsInterfaces);
// Only bring up IMS if the device supports having an IMS stack.
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS)) {
// might need it when it is being opened.
for (int i = 0; i < numPhones; i++) {
sPhones[i].createImsPhone();
}
} else {
Rlog.i(LOG_TAG, "IMS is not supported on this device, skipping ImsResolver.");
}
sPhoneConfigurationManager = PhoneConfigurationManager.init(sContext);
sCellularNetworkValidator = CellularNetworkValidator.make(sContext);
int maxActivePhones = sPhoneConfigurationManager.getNumberOfModemsWithSimultaneousDataConnections();
sPhoneSwitcher = TelephonyComponentFactory.getInstance().inject(PhoneSwitcher.class.getName()).makePhoneSwitcher(maxActivePhones, sContext, Looper.myLooper());
sProxyController = ProxyController.getInstance(context);
sIntentBroadcaster = IntentBroadcaster.getInstance(context);
sNotificationChannelController = new NotificationChannelController(context);
for (int i = 0; i < numPhones; i++) {
sTelephonyNetworkFactories[i] = new TelephonyNetworkFactory(Looper.myLooper(), sPhones[i]);
}
}
}
}
Aggregations