[Settings] Support getSystemService(Class<T>)

Add getSystemService(Class<T>) to align the capability with framework
part.

This is a back port from aosp/1639943, aosp/1645152 and aosp/1648047

Bug: 179640862
Test: local
Change-Id: I035db55a71f94000ca35f8d71f03c19208423c73
This commit is contained in:
Bonian Chen
2021-03-24 00:59:46 +08:00
parent d8c9a53931
commit d5ccde31a8
63 changed files with 103 additions and 103 deletions

View File

@@ -104,8 +104,8 @@ public class SimSelectNotification extends BroadcastReceiver {
subId = SubscriptionManager.getDefaultSmsSubscriptionId();
}
SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
Context.TELEPHONY_SUBSCRIPTION_SERVICE));
SubscriptionManager subscriptionManager = (context.getSystemService(
SubscriptionManager.class));
if (!subscriptionManager.isActiveSubscriptionId(subId)) {
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
return;
@@ -130,8 +130,8 @@ public class SimSelectNotification extends BroadcastReceiver {
return;
}
TelephonyManager tm = ((TelephonyManager) context.getSystemService(
Context.TELEPHONY_SERVICE)).createForSubscriptionId(subId);
TelephonyManager tm = (context.getSystemService(
TelephonyManager.class)).createForSubscriptionId(subId);
if (tm.isDataEnabledForApn(TYPE_MMS)) {
Log.w(TAG, "onEnableMmsDataRequest MMS data already enabled on sub ID " + subId);
@@ -230,14 +230,14 @@ public class SimSelectNotification extends BroadcastReceiver {
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(notificationChannel);
notificationManager.notify(SIM_SELECT_NOTIFICATION_ID, builder.build());
}
public static void cancelSimSelectNotification(Context context) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
context.getSystemService(NotificationManager.class);
notificationManager.cancel(SIM_SELECT_NOTIFICATION_ID);
}
@@ -270,14 +270,14 @@ public class SimSelectNotification extends BroadcastReceiver {
// Notify the notification.
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(notificationChannel);
notificationManager.notify(ENABLE_MMS_NOTIFICATION_ID, builder.build());
}
private void cancelEnableMmsNotification(Context context) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
context.getSystemService(NotificationManager.class);
notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
}