Merge "Remove hidden Icon.createWithResource API usage"
This commit is contained in:
@@ -84,7 +84,7 @@ public class NetworkNotificationManager {
|
|||||||
|
|
||||||
// The context is for the current user (system server)
|
// The context is for the current user (system server)
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Resources mResources;
|
private final ConnectivityResources mResources;
|
||||||
private final TelephonyManager mTelephonyManager;
|
private final TelephonyManager mTelephonyManager;
|
||||||
// The notification manager is created from a context for User.ALL, so notifications
|
// The notification manager is created from a context for User.ALL, so notifications
|
||||||
// will be sent to all users.
|
// will be sent to all users.
|
||||||
@@ -99,7 +99,7 @@ public class NetworkNotificationManager {
|
|||||||
(NotificationManager) c.createContextAsUser(UserHandle.ALL, 0 /* flags */)
|
(NotificationManager) c.createContextAsUser(UserHandle.ALL, 0 /* flags */)
|
||||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
mNotificationTypeMap = new SparseIntArray();
|
mNotificationTypeMap = new SparseIntArray();
|
||||||
mResources = new ConnectivityResources(mContext).get();
|
mResources = new ConnectivityResources(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -118,11 +118,11 @@ public class NetworkNotificationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getTransportName(final int transportType) {
|
private String getTransportName(final int transportType) {
|
||||||
String[] networkTypes = mResources.getStringArray(R.array.network_switch_type_name);
|
String[] networkTypes = mResources.get().getStringArray(R.array.network_switch_type_name);
|
||||||
try {
|
try {
|
||||||
return networkTypes[transportType];
|
return networkTypes[transportType];
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
return mResources.getString(R.string.network_switch_type_name_unknown);
|
return mResources.get().getString(R.string.network_switch_type_name_unknown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,10 +197,11 @@ public class NetworkNotificationManager {
|
|||||||
tag, nameOf(eventId), getTransportName(transportType), name, highPriority));
|
tag, nameOf(eventId), getTransportName(transportType), name, highPriority));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Resources r = mResources;
|
final Resources r = mResources.get();
|
||||||
final CharSequence title;
|
final CharSequence title;
|
||||||
final CharSequence details;
|
final CharSequence details;
|
||||||
Icon icon = Icon.createWithResource(r, getIcon(transportType));
|
Icon icon = Icon.createWithResource(
|
||||||
|
mResources.getResourcesContext(), getIcon(transportType));
|
||||||
if (notifyType == NotificationType.NO_INTERNET && transportType == TRANSPORT_WIFI) {
|
if (notifyType == NotificationType.NO_INTERNET && transportType == TRANSPORT_WIFI) {
|
||||||
title = r.getString(R.string.wifi_no_internet, name);
|
title = r.getString(R.string.wifi_no_internet, name);
|
||||||
details = r.getString(R.string.wifi_no_internet_detailed);
|
details = r.getString(R.string.wifi_no_internet_detailed);
|
||||||
@@ -355,7 +356,7 @@ public class NetworkNotificationManager {
|
|||||||
public void showToast(NetworkAgentInfo fromNai, NetworkAgentInfo toNai) {
|
public void showToast(NetworkAgentInfo fromNai, NetworkAgentInfo toNai) {
|
||||||
String fromTransport = getTransportName(approximateTransportType(fromNai));
|
String fromTransport = getTransportName(approximateTransportType(fromNai));
|
||||||
String toTransport = getTransportName(approximateTransportType(toNai));
|
String toTransport = getTransportName(approximateTransportType(toNai));
|
||||||
String text = mResources.getString(
|
String text = mResources.get().getString(
|
||||||
R.string.network_switch_metered_toast, fromTransport, toTransport);
|
R.string.network_switch_metered_toast, fromTransport, toTransport);
|
||||||
Toast.makeText(mContext, text, Toast.LENGTH_LONG).show();
|
Toast.makeText(mContext, text, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user