mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
481ca4d2d0
commit
ff3f9df450
|
@ -86,7 +86,7 @@ public class ActivityAnswer extends ActivityBase {
|
|||
String html = answer.getHtml(null);
|
||||
String text = HtmlHelper.getText(context, html);
|
||||
|
||||
ClipboardManager cbm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(ActivityAnswer.this, ClipboardManager.class);
|
||||
cbm.setPrimaryClip(ClipData.newHtmlText(getString(R.string.app_name), text, html));
|
||||
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
|
||||
|
||||
|
|
|
@ -354,8 +354,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
|
|||
|
||||
ServiceSynchronize.eval(context, "outbox/drafts");
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
nm.cancel("send:" + id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
|
||||
return message.id;
|
||||
|
|
|
@ -609,7 +609,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
|
||||
Log.i("Collecting data");
|
||||
DB db = DB.getInstance(context);
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
|
||||
// Accounts
|
||||
JSONArray jaccounts = new JSONArray();
|
||||
|
@ -898,7 +898,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
JSONObject jimport = new JSONObject(json);
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ public class ActivitySignature extends ActivityBase {
|
|||
final int start = etText.getSelectionStart();
|
||||
final int end = etText.getSelectionEnd();
|
||||
|
||||
ClipboardManager cbm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(this, ClipboardManager.class);
|
||||
if (cbm != null && cbm.hasPrimaryClip()) {
|
||||
String link = cbm.getPrimaryClip().getItemAt(0).coerceToText(this).toString();
|
||||
uri = Uri.parse(link);
|
||||
|
|
|
@ -380,7 +380,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
if (account.notify &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
String channelId = EntityAccount.getNotificationChannelId(account.id);
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
NotificationChannel channel = nm.getNotificationChannel(channelId);
|
||||
if (channel != null)
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_channel, order++, R.string.title_edit_channel);
|
||||
|
|
|
@ -602,7 +602,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP) {
|
||||
if (folder.notify && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
String channelId = EntityFolder.getNotificationChannelId(folder.id);
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
NotificationChannel channel = nm.getNotificationChannel(channelId);
|
||||
if (channel == null)
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_create_channel, order++, R.string.title_create_channel);
|
||||
|
|
|
@ -3061,8 +3061,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
private void onCopy() {
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
|
@ -4457,8 +4456,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
private void onCopy() {
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
|
@ -4556,7 +4554,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
private void onNotifyContact(final TupleMessageEx message) {
|
||||
final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
final NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
final String channelId = message.getNotificationChannelId();
|
||||
|
||||
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, ibNotifyContact);
|
||||
|
@ -4617,7 +4615,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
private void onActionDeleteChannel() {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
nm.deleteNotificationChannel(channelId);
|
||||
}
|
||||
});
|
||||
|
@ -4795,8 +4793,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
if (TextUtils.isEmpty(message.notes))
|
||||
return;
|
||||
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
|
@ -6339,8 +6336,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
private void onCopyHeaders(TupleMessageEx message) {
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
|
@ -8232,7 +8228,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
String html = HtmlHelper.toHtml((Spanned) tvText.getText(), context);
|
||||
String text = HtmlHelper.getText(context, html);
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class);
|
||||
cbm.setPrimaryClip(ClipData.newHtmlText(getString(R.string.app_name), text, html));
|
||||
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class AlarmManagerCompatEx {
|
|||
return true;
|
||||
try {
|
||||
// https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission
|
||||
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
AlarmManager am = Helper.getSystemService(context, AlarmManager.class);
|
||||
return am.canScheduleExactAlarms();
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
|
|
|
@ -175,7 +175,7 @@ public class ConnectionHelper {
|
|||
|
||||
static NetworkInfo getNetworkInfo(Context context, Network network) {
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
return (cm == null ? null : cm.getNetworkInfo(network));
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
|
@ -197,7 +197,7 @@ public class ConnectionHelper {
|
|||
state.suitable = (isMetered != null && (metered || !isMetered));
|
||||
state.active = getActiveNetwork(context);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
|
||||
if (state.connected && !roaming) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
|
@ -215,7 +215,7 @@ public class ConnectionHelper {
|
|||
|
||||
if (state.roaming != null && state.roaming && rlah)
|
||||
try {
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
TelephonyManager tm = Helper.getSystemService(context, TelephonyManager.class);
|
||||
if (tm != null) {
|
||||
String sim = tm.getSimCountryIso();
|
||||
String network = tm.getNetworkCountryIso();
|
||||
|
@ -242,7 +242,7 @@ public class ConnectionHelper {
|
|||
boolean require_validated = prefs.getBoolean("require_validated", false);
|
||||
boolean vpn_only = prefs.getBoolean("vpn_only", false);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
if (cm == null) {
|
||||
Log.i("isMetered: no connectivity manager");
|
||||
return null;
|
||||
|
@ -381,7 +381,7 @@ public class ConnectionHelper {
|
|||
}
|
||||
|
||||
static Network getActiveNetwork(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
if (cm == null)
|
||||
return null;
|
||||
|
||||
|
@ -456,8 +456,7 @@ public class ConnectionHelper {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
||||
return false;
|
||||
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
if (cm == null)
|
||||
return false;
|
||||
|
||||
|
@ -473,8 +472,7 @@ public class ConnectionHelper {
|
|||
return null;
|
||||
|
||||
try {
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
if (cm == null)
|
||||
return null;
|
||||
|
||||
|
@ -496,7 +494,7 @@ public class ConnectionHelper {
|
|||
}
|
||||
|
||||
static boolean vpnActive(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
if (cm == null)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -873,7 +873,7 @@ public class ContactInfo {
|
|||
|
||||
private static boolean isRecoverable(Throwable ex, Context context) {
|
||||
if (ex instanceof SocketTimeoutException) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
NetworkInfo ni = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||
return (ni == null || !ni.isConnected());
|
||||
}
|
||||
|
|
|
@ -189,8 +189,7 @@ class Core {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int chunk_size = prefs.getInt("chunk_size", DEFAULT_CHUNK_SIZE);
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
|
||||
int retry = 0;
|
||||
boolean group = true;
|
||||
|
@ -2072,7 +2071,7 @@ class Core {
|
|||
PendingIntent piExists = PendingIntentCompat.getForegroundService(
|
||||
context, ServiceSynchronize.PI_EXISTS, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
AlarmManager am = Helper.getSystemService(context, AlarmManager.class);
|
||||
AlarmManagerCompatEx.setAndAllowWhileIdle(context, am, AlarmManager.RTC_WAKEUP, next, piExists);
|
||||
return;
|
||||
}
|
||||
|
@ -4810,7 +4809,7 @@ class Core {
|
|||
if (messages == null)
|
||||
messages = new ArrayList<>();
|
||||
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
if (nm == null)
|
||||
return;
|
||||
|
||||
|
@ -5034,7 +5033,7 @@ class Core {
|
|||
|
||||
if (notify_screen_on && flash) {
|
||||
Log.i("Notify screen on");
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager pm = Helper.getSystemService(context, PowerManager.class);
|
||||
PowerManager.WakeLock wakeLock = pm.newWakeLock(
|
||||
PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
|
||||
BuildConfig.APPLICATION_ID + ":notification");
|
||||
|
@ -5057,7 +5056,7 @@ class Core {
|
|||
// = 0: unified
|
||||
// > 0: account
|
||||
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
if (messages == null || messages.size() == 0 || nm == null)
|
||||
return notifications;
|
||||
|
||||
|
@ -6029,7 +6028,7 @@ class Core {
|
|||
// Get existing notifications
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
for (StatusBarNotification sbn : nm.getActiveNotifications()) {
|
||||
String tag = sbn.getTag();
|
||||
if (tag != null && tag.startsWith("unseen.")) {
|
||||
|
|
|
@ -447,7 +447,7 @@ public abstract class DB extends RoomDatabase {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int sqlite_cache = prefs.getInt("sqlite_cache", DEFAULT_CACHE_SIZE);
|
||||
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager am = Helper.getSystemService(context, ActivityManager.class);
|
||||
int class_mb = am.getMemoryClass();
|
||||
int cache_size = sqlite_cache * class_mb * 1024 / 100;
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ public class DnsHelper {
|
|||
}
|
||||
|
||||
if (ex == null) {
|
||||
//ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
//ConnectivityManager cm = getSystemService(context, ConnectivityManager.class);
|
||||
//Network active = (cm == null ? null : cm.getActiveNetwork());
|
||||
//LinkProperties props = (active == null ? null : cm.getLinkProperties(active));
|
||||
//Log.i("DNS private=" + (props == null ? null : props.isPrivateDnsActive()));
|
||||
|
@ -215,7 +215,7 @@ public class DnsHelper {
|
|||
}
|
||||
|
||||
private static String getDnsServer(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
if (cm == null)
|
||||
return DEFAULT_DNS;
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ public class EditTextCompose extends FixedEditText {
|
|||
}
|
||||
|
||||
Context context = getContext();
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (start != end && cbm != null) {
|
||||
CharSequence selected = getEditableText().subSequence(start, end);
|
||||
if (selected instanceof Spanned) {
|
||||
|
@ -373,7 +373,7 @@ public class EditTextCompose extends FixedEditText {
|
|||
} else if (id == android.R.id.paste) {
|
||||
final Context context = getContext();
|
||||
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (cbm == null || !cbm.hasPrimaryClip())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public class EditTextPlain extends FixedEditText {
|
|||
try {
|
||||
if (id == android.R.id.paste) {
|
||||
Context context = getContext();
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (cbm != null && cbm.hasPrimaryClip()) {
|
||||
ClipData data = cbm.getPrimaryClip();
|
||||
ClipData.Item item = (data == null ? null : data.getItemAt(0));
|
||||
|
|
|
@ -388,7 +388,7 @@ public class EmailService implements AutoCloseable {
|
|||
if (bind_socket &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
Network active = cm.getActiveNetwork();
|
||||
if (active != null) {
|
||||
EntityLog.log(context, EntityLog.Type.Network, "Binding to" +
|
||||
|
|
|
@ -211,7 +211,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
void createNotificationChannel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
|
||||
NotificationChannelGroup group = new NotificationChannelGroup("group." + id, name);
|
||||
nm.createNotificationChannelGroup(group);
|
||||
|
@ -228,7 +228,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
void deleteNotificationChannel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
nm.deleteNotificationChannel(getNotificationChannelId(id));
|
||||
}
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ public class EntityMessage implements Serializable {
|
|||
PendingIntent pi = PendingIntentCompat.getForegroundService(
|
||||
context, ServiceSynchronize.PI_UNSNOOZE, snoozed, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
AlarmManager am = Helper.getSystemService(context, AlarmManager.class);
|
||||
if (wakeup == null || wakeup == Long.MAX_VALUE) {
|
||||
Log.i("Cancel snooze id=" + id);
|
||||
am.cancel(pi);
|
||||
|
|
|
@ -384,7 +384,7 @@ public class FixedTextView extends AppCompatTextView {
|
|||
try {
|
||||
if (id == android.R.id.copy) {
|
||||
Context context = getContext();
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class);
|
||||
|
||||
int start = getSelectionStart();
|
||||
int end = getSelectionEnd();
|
||||
|
|
|
@ -1313,7 +1313,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
ServiceSynchronize.eval(context, "save account");
|
||||
|
||||
if (!synchronize) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
nm.cancel("receive:" + account.id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
nm.cancel("alert:" + account.id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
}
|
||||
|
|
|
@ -571,7 +571,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
if (action == R.id.menu_link) {
|
||||
Uri uri = null;
|
||||
|
||||
ClipboardManager cbm = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(getContext(), ClipboardManager.class);
|
||||
if (cbm != null && cbm.hasPrimaryClip()) {
|
||||
String link = cbm.getPrimaryClip().getItemAt(0).coerceToText(getContext()).toString();
|
||||
uri = Uri.parse(link);
|
||||
|
|
|
@ -798,8 +798,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
if (identity == null || TextUtils.isEmpty(identity.signature))
|
||||
return;
|
||||
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager clipboard = Helper.getSystemService(v.getContext(), ClipboardManager.class);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
|
@ -1345,8 +1344,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
if (context == null)
|
||||
return;
|
||||
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
|
@ -1477,7 +1475,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||
|
@ -1493,7 +1491,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
onAction(R.id.action_save, extras, "pause");
|
||||
}
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
cm.unregisterNetworkCallback(networkCallback);
|
||||
|
||||
super.onPause();
|
||||
|
@ -2347,7 +2345,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
if (uri == null)
|
||||
try {
|
||||
ClipboardManager cbm = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(getContext(), ClipboardManager.class);
|
||||
if (cbm != null && cbm.hasPrimaryClip()) {
|
||||
String link = cbm.getPrimaryClip().getItemAt(0).coerceToText(getContext()).toString();
|
||||
uri = Uri.parse(link);
|
||||
|
@ -6295,7 +6293,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
if (addresses == null)
|
||||
return;
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
NetworkInfo ani = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||
if (ani != null && ani.isConnected())
|
||||
DnsHelper.checkMx(context, addresses);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class FragmentDialogFolder extends FragmentDialogBase {
|
|||
|
||||
final Context context = getContext();
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
final InputMethodManager imm = Helper.getSystemService(context, InputMethodManager.class);
|
||||
|
||||
List<String> selected_folders = new ArrayList<>();
|
||||
String json = prefs.getString("selected_folders", "[]");
|
||||
|
|
|
@ -264,7 +264,7 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||
|
@ -274,7 +274,7 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
|
|||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
cm.unregisterNetworkCallback(networkCallback);
|
||||
}
|
||||
|
||||
|
|
|
@ -251,8 +251,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|||
ibCopy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager clipboard = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1163,8 +1163,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
|
||||
}
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(context, "progress")
|
||||
.setSmallIcon(R.drawable.baseline_get_app_white_24)
|
||||
|
|
|
@ -407,7 +407,7 @@ public class FragmentGmail extends FragmentBase {
|
|||
if (TextUtils.isEmpty(password))
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
NetworkInfo ani = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||
if (ani == null || !ani.isConnected())
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_internet));
|
||||
|
|
|
@ -4368,7 +4368,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
iff.addAction(ACTION_KEYWORDS);
|
||||
lbm.registerReceiver(receiver, iff);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||
|
@ -4432,7 +4432,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
cm.unregisterNetworkCallback(networkCallback);
|
||||
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
|
@ -8452,8 +8452,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
ServiceSynchronize.eval(context, "delete");
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
nm.cancel("send:" + id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
|
||||
return null;
|
||||
|
@ -9106,7 +9105,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
return;
|
||||
}
|
||||
|
||||
PrintManager printManager = (PrintManager) context.getSystemService(Context.PRINT_SERVICE);
|
||||
PrintManager printManager = Helper.getSystemService(context, PrintManager.class);
|
||||
String jobName = getString(R.string.app_name);
|
||||
if (!TextUtils.isEmpty(data[0]))
|
||||
jobName += " - " + data[0];
|
||||
|
|
|
@ -748,7 +748,7 @@ public class FragmentOAuth extends FragmentBase {
|
|||
} else
|
||||
throw new IllegalArgumentException("Unknown provider=" + id);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
NetworkInfo ani = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||
if (ani == null || !ani.isConnected())
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_internet));
|
||||
|
|
|
@ -325,7 +325,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
if (cm == null)
|
||||
return;
|
||||
|
||||
|
@ -338,7 +338,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
|
||||
@Override
|
||||
public void onPause() {
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
if (cm == null)
|
||||
return;
|
||||
|
||||
|
@ -439,7 +439,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
|||
if ((debug || BuildConfig.DEBUG) &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
Network active = (cm == null ? null : cm.getActiveNetwork());
|
||||
if (active != null) {
|
||||
NetworkInfo ni = cm.getNetworkInfo(active);
|
||||
|
|
|
@ -592,7 +592,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
super.onResume();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(getContext(), NotificationManager.class);
|
||||
|
||||
NotificationChannel notification = nm.getNotificationChannel("notification");
|
||||
if (notification != null) {
|
||||
|
|
|
@ -467,7 +467,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
|
|||
prefs.edit().putString("wipe_mnemonic", mnemonic).apply();
|
||||
tvMnemonic.setText(mnemonic);
|
||||
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipboardManager cbm = Helper.getSystemService(context, ClipboardManager.class);
|
||||
if (cbm == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -629,8 +629,7 @@ public class FragmentPop extends FragmentBase {
|
|||
ServiceSynchronize.eval(context, "POP3");
|
||||
|
||||
if (!synchronize) {
|
||||
NotificationManager nm =
|
||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
nm.cancel("receive:" + account.id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
nm.cancel("alert:" + account.id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
int at = email.indexOf('@');
|
||||
String username = email.substring(0, at);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
NetworkInfo ani = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||
if (ani == null || !ani.isConnected())
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_no_internet));
|
||||
|
|
|
@ -743,7 +743,7 @@ public class FragmentSetup extends FragmentBase {
|
|||
updateManual();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
cm.registerDefaultNetworkCallback(networkCallback);
|
||||
}
|
||||
|
||||
|
@ -770,8 +770,7 @@ public class FragmentSetup extends FragmentBase {
|
|||
tvDoze12.setVisibility(!canScheduleExact && !isIgnoring ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
ActivityManager am =
|
||||
(ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager am = Helper.getSystemService(getContext(), ActivityManager.class);
|
||||
grpBackgroundRestricted.setVisibility(am.isBackgroundRestricted()
|
||||
? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
@ -788,7 +787,7 @@ public class FragmentSetup extends FragmentBase {
|
|||
super.onPause();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(getContext(), ConnectivityManager.class);
|
||||
cm.unregisterNetworkCallback(networkCallback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.animation.ObjectAnimator;
|
|||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.UiModeManager;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
|
@ -456,7 +457,7 @@ public class Helper {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return null;
|
||||
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager pm = Helper.getSystemService(context, PowerManager.class);
|
||||
if (pm == null)
|
||||
return null;
|
||||
|
||||
|
@ -465,7 +466,7 @@ public class Helper {
|
|||
|
||||
static Integer getBatteryLevel(Context context) {
|
||||
try {
|
||||
BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
|
||||
BatteryManager bm = Helper.getSystemService(context, BatteryManager.class);
|
||||
if (bm == null)
|
||||
return null;
|
||||
return bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
|
@ -479,7 +480,7 @@ public class Helper {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return false;
|
||||
try {
|
||||
BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
|
||||
BatteryManager bm = Helper.getSystemService(context, BatteryManager.class);
|
||||
if (bm == null)
|
||||
return false;
|
||||
return bm.isCharging();
|
||||
|
@ -520,7 +521,7 @@ public class Helper {
|
|||
int enabled = Settings.System.getInt(resolver, Settings.Secure.LOCK_PATTERN_ENABLED, 0);
|
||||
return (enabled != 0);
|
||||
} else {
|
||||
KeyguardManager kgm = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
KeyguardManager kgm = Helper.getSystemService(context, KeyguardManager.class);
|
||||
return (kgm != null && kgm.isDeviceSecure());
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
|
@ -591,8 +592,7 @@ public class Helper {
|
|||
|
||||
static boolean isAccessibilityEnabled(Context context) {
|
||||
try {
|
||||
AccessibilityManager am =
|
||||
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
AccessibilityManager am = Helper.getSystemService(context, AccessibilityManager.class);
|
||||
return (am != null && am.isEnabled());
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
|
@ -619,6 +619,10 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
static <T extends Object> T getSystemService(Context context, Class<T> type) {
|
||||
return ContextCompat.getSystemService(context.getApplicationContext(), type);
|
||||
}
|
||||
|
||||
// View
|
||||
|
||||
static int getActionBarHeight(Context context) {
|
||||
|
@ -1123,8 +1127,7 @@ public class Helper {
|
|||
|
||||
static String getUiModeType(Context context) {
|
||||
try {
|
||||
UiModeManager uimm =
|
||||
(UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
||||
UiModeManager uimm = Helper.getSystemService(context, UiModeManager.class);
|
||||
int uiModeType = uimm.getCurrentModeType();
|
||||
switch (uiModeType) {
|
||||
case Configuration.UI_MODE_TYPE_UNDEFINED:
|
||||
|
|
|
@ -406,7 +406,7 @@ public class HtmlHelper {
|
|||
}
|
||||
|
||||
private static int getMaxFormatTextSize(Context context) {
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager am = Helper.getSystemService(context, ActivityManager.class);
|
||||
int mc = am.getMemoryClass();
|
||||
if (mc >= 256)
|
||||
return MAX_FORMAT_TEXT_SIZE;
|
||||
|
|
|
@ -482,7 +482,7 @@ class ImageHelper {
|
|||
// H+ HSPA+ ~14.4 Mbps-23.0 Mbps
|
||||
// 4G LTE ~50 Mbps
|
||||
// 4G LTE-A ~500 Mbps
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
Network active = (cm == null ? null : cm.getActiveNetwork());
|
||||
NetworkCapabilities caps = (active == null ? null : cm.getNetworkCapabilities(active));
|
||||
if (caps != null) {
|
||||
|
|
|
@ -423,7 +423,7 @@ public class Log {
|
|||
config.setDiscardClasses(ignore);
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager am = Helper.getSystemService(context, ActivityManager.class);
|
||||
|
||||
String no_internet = context.getString(R.string.title_no_internet);
|
||||
|
||||
|
@ -678,7 +678,7 @@ public class Log {
|
|||
|
||||
static void logMemory(Context context, String message) {
|
||||
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager activityManager = Helper.getSystemService(context, ActivityManager.class);
|
||||
activityManager.getMemoryInfo(mi);
|
||||
int mb = Math.round(mi.availMem / 0x100000L);
|
||||
int perc = Math.round(mi.availMem / (float) mi.totalMem * 100.0f);
|
||||
|
@ -1859,7 +1859,7 @@ public class Log {
|
|||
|
||||
sb.append(String.format("Processors: %d\r\n", Runtime.getRuntime().availableProcessors()));
|
||||
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager am = Helper.getSystemService(context, ActivityManager.class);
|
||||
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
||||
am.getMemoryInfo(mi);
|
||||
sb.append(String.format("Memory class: %d/%d MB Total: %s\r\n",
|
||||
|
@ -1906,7 +1906,7 @@ public class Log {
|
|||
sb.append("\r\n");
|
||||
|
||||
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
WindowManager wm = Helper.getSystemService(context, WindowManager.class);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point dim = new Point();
|
||||
display.getSize(dim);
|
||||
|
@ -1964,7 +1964,7 @@ public class Log {
|
|||
ignoring == null ? null : Boolean.toString(!ignoring),
|
||||
Boolean.FALSE.equals(ignoring) ? "!!!" : ""));
|
||||
|
||||
PowerManager power = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager power = Helper.getSystemService(context, PowerManager.class);
|
||||
boolean psaving = power.isPowerSaveMode();
|
||||
sb.append(String.format("Battery saving: %s %s\r\n", psaving, psaving ? "!!!" : ""));
|
||||
|
||||
|
@ -1973,7 +1973,7 @@ public class Log {
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
// https://developer.android.com/reference/android/app/usage/UsageStatsManager
|
||||
UsageStatsManager usm = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
|
||||
UsageStatsManager usm = Helper.getSystemService(context, UsageStatsManager.class);
|
||||
int bucket = usm.getAppStandbyBucket();
|
||||
boolean inactive = usm.isAppInactive(BuildConfig.APPLICATION_ID);
|
||||
sb.append(String.format("Standby bucket: %d-%b-%s %s\r\n",
|
||||
|
@ -2282,7 +2282,7 @@ public class Log {
|
|||
long size = 0;
|
||||
File file = attachment.getFile(context);
|
||||
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
|
||||
NetworkInfo ani = cm.getActiveNetworkInfo();
|
||||
if (ani != null)
|
||||
|
@ -2512,7 +2512,7 @@ public class Log {
|
|||
long size = 0;
|
||||
File file = attachment.getFile(context);
|
||||
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
|
||||
|
||||
String name;
|
||||
|
@ -2639,7 +2639,7 @@ public class Log {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
try {
|
||||
// https://developer.android.com/reference/android/app/ApplicationExitInfo
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager am = Helper.getSystemService(context, ActivityManager.class);
|
||||
List<ApplicationExitInfo> infos = am.getHistoricalProcessExitReasons(
|
||||
context.getPackageName(), 0, 20);
|
||||
for (ApplicationExitInfo info : infos)
|
||||
|
@ -2657,7 +2657,7 @@ public class Log {
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
try {
|
||||
UsageStatsManager usm = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
|
||||
UsageStatsManager usm = Helper.getSystemService(context, UsageStatsManager.class);
|
||||
UsageEvents events = usm.queryEventsForSelf(now - 12 * 3600L, now);
|
||||
UsageEvents.Event event = new UsageEvents.Event();
|
||||
while (events != null && events.hasNextEvent()) {
|
||||
|
|
|
@ -81,8 +81,7 @@ public class MediaPlayerHelper {
|
|||
}
|
||||
|
||||
static boolean isInCall(Context context) {
|
||||
AudioManager am =
|
||||
(AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
AudioManager am = Helper.getSystemService(context, AudioManager.class);
|
||||
if (am == null)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class NotificationHelper {
|
|||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
static void createNotificationChannels(Context context) {
|
||||
// https://issuetracker.google.com/issues/65108694
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
|
||||
// Sync
|
||||
NotificationChannel service = new NotificationChannel(
|
||||
|
@ -151,7 +151,7 @@ class NotificationHelper {
|
|||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
static void clear(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
for (NotificationChannel channel : nm.getNotificationChannels()) {
|
||||
String id = channel.getId();
|
||||
if (!PERSISTENT_IDS.contains(id)) {
|
||||
|
|
|
@ -94,7 +94,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
|
||||
owner = new TwoStateOwner(this, "send");
|
||||
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager pm = Helper.getSystemService(this, PowerManager.class);
|
||||
wlOutbox = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":send");
|
||||
|
||||
// Observe unsent count
|
||||
|
@ -107,8 +107,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
EntityLog.log(ServiceSend.this, "Unsent=" + (unsent == null ? null : unsent.count));
|
||||
|
||||
try {
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(ServiceSend.this, NotificationManager.class);
|
||||
nm.notify(NotificationHelper.NOTIFICATION_SEND,
|
||||
getNotificationService(false).build());
|
||||
} catch (Throwable ex) {
|
||||
|
@ -157,7 +156,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
if (lastSuitable)
|
||||
owner.start();
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(this, ConnectivityManager.class);
|
||||
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||
|
@ -178,7 +177,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
|
||||
unregisterReceiver(connectionChangedReceiver);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(this, ConnectivityManager.class);
|
||||
cm.unregisterNetworkCallback(networkCallback);
|
||||
|
||||
getMainHandler().removeCallbacks(_checkConnectivity);
|
||||
|
@ -188,8 +187,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
|
||||
stopForeground(true);
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.cancel(NotificationHelper.NOTIFICATION_SEND);
|
||||
|
||||
super.onDestroy();
|
||||
|
@ -331,8 +329,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
EntityLog.log(ServiceSend.this, "Service send suitable=" + suitable);
|
||||
|
||||
try {
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(ServiceSend.this, NotificationManager.class);
|
||||
nm.notify(NotificationHelper.NOTIFICATION_SEND,
|
||||
getNotificationService(false).build());
|
||||
} catch (Throwable ex) {
|
||||
|
@ -432,7 +429,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
|
||||
try {
|
||||
int tries_left = (unrecoverable ? 0 : RETRY_MAX - op.tries);
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.notify("send:" + message.id,
|
||||
NotificationHelper.NOTIFICATION_TAGGED,
|
||||
getNotificationError(
|
||||
|
@ -467,7 +464,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
}
|
||||
|
||||
private void onSync(EntityFolder outbox) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
|
||||
DB db = DB.getInstance(this);
|
||||
try {
|
||||
|
@ -519,8 +516,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
db.message().setMessageLastAttempt(message.id, message.last_attempt);
|
||||
}
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService(true).build());
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
@ -895,7 +891,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
context, PI_SEND, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
long trigger = System.currentTimeMillis() + delay;
|
||||
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
AlarmManager am = Helper.getSystemService(context, AlarmManager.class);
|
||||
am.cancel(pi);
|
||||
AlarmManagerCompatEx.setAndAllowWhileIdle(context, am, AlarmManager.RTC_WAKEUP, trigger, pi);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
getNotificationService(null, null).build());
|
||||
|
||||
// Listen for network changes
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(this, ConnectivityManager.class);
|
||||
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||
// Removed because of Android VPN service
|
||||
|
@ -240,7 +240,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
private int lastQuitId = -1;
|
||||
private List<Long> initialized = new ArrayList<>();
|
||||
private List<TupleAccountNetworkState> accountStates = new ArrayList<>();
|
||||
private PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
private PowerManager pm = Helper.getSystemService(ServiceSynchronize.this, PowerManager.class);
|
||||
private PowerManager.WakeLock wl = pm.newWakeLock(
|
||||
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":service");
|
||||
private ExecutorService queue = Helper.getBackgroundExecutor(1, "service");
|
||||
|
@ -399,8 +399,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
if (!isBackgroundService(ServiceSynchronize.this))
|
||||
try {
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(ServiceSynchronize.this, NotificationManager.class);
|
||||
nm.notify(NotificationHelper.NOTIFICATION_SYNCHRONIZE,
|
||||
getNotificationService(lastAccounts, lastOperations).build());
|
||||
} catch (Throwable ex) {
|
||||
|
@ -567,7 +566,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
db.account().deleteAccount(accountNetworkState.accountState.id);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(ServiceSynchronize.this, NotificationManager.class);
|
||||
nm.deleteNotificationChannel(EntityAccount.getNotificationChannelId(accountNetworkState.accountState.id));
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
|
@ -882,7 +881,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
unregisterReceiver(connectionChangedReceiver);
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(this, ConnectivityManager.class);
|
||||
cm.unregisterNetworkCallback(networkCallback);
|
||||
|
||||
liveAccountNetworkState.postDestroy();
|
||||
|
@ -916,8 +915,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
*/
|
||||
}
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.cancel(NotificationHelper.NOTIFICATION_SYNCHRONIZE);
|
||||
|
||||
super.onDestroy();
|
||||
|
@ -1361,7 +1359,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
private void monitorAccount(
|
||||
final EntityAccount account, final Core.State state,
|
||||
final boolean sync, final boolean force) throws NoSuchProviderException {
|
||||
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
final PowerManager pm = Helper.getSystemService(this, PowerManager.class);
|
||||
final PowerManager.WakeLock wlAccount = pm.newWakeLock(
|
||||
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":account." + account.id);
|
||||
final PowerManager.WakeLock wlFolder = pm.newWakeLock(
|
||||
|
@ -1447,7 +1445,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
if (!ConnectionHelper.isMaxConnections(message))
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(ServiceSynchronize.this, NotificationManager.class);
|
||||
nm.notify("alert:" + account.id,
|
||||
NotificationHelper.NOTIFICATION_TAGGED,
|
||||
getNotificationAlert(account, message).build());
|
||||
|
@ -1488,7 +1486,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
try {
|
||||
state.setBackoff(2 * CONNECT_BACKOFF_ALARM_MAX * 60);
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.notify("receive:" + account.id,
|
||||
NotificationHelper.NOTIFICATION_TAGGED,
|
||||
Core.getNotificationError(this, "error", account, 0, ex)
|
||||
|
@ -2237,8 +2235,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
db.account().setAccountConnected(account.id, account.last_connected);
|
||||
db.account().setAccountWarning(account.id, capIdle ? null : getString(R.string.title_no_idle));
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.cancel("receive:" + account.id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
nm.cancel("alert:" + account.id, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
|
||||
|
@ -2248,7 +2245,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
PendingIntent pi = PendingIntentCompat.getForegroundService(
|
||||
this, PI_KEEPALIVE, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
AlarmManager am = Helper.getSystemService(this, AlarmManager.class);
|
||||
try {
|
||||
long duration = account.poll_interval * 60 * 1000L;
|
||||
long trigger = System.currentTimeMillis() + duration;
|
||||
|
@ -2301,7 +2298,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
Helper.getDateTimeInstance(this, DateFormat.SHORT, DateFormat.SHORT)
|
||||
.format(account.last_connected)), ex);
|
||||
try {
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.notify("receive:" + account.id,
|
||||
NotificationHelper.NOTIFICATION_TAGGED,
|
||||
Core.getNotificationError(this, "warning", account, 0, warning)
|
||||
|
@ -2477,7 +2474,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
PendingIntent pi = PendingIntentCompat.getForegroundService(
|
||||
this, PI_BACKOFF, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
AlarmManager am = Helper.getSystemService(this, AlarmManager.class);
|
||||
try {
|
||||
long trigger = System.currentTimeMillis() + backoff * 1000L;
|
||||
EntityLog.log(this, EntityLog.Type.Account, account,
|
||||
|
@ -2653,7 +2650,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
@Override
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager pm = Helper.getSystemService(context, PowerManager.class);
|
||||
EntityLog.log(context, "Doze mode=" + pm.isDeviceIdleMode() +
|
||||
" ignoring=" + pm.isIgnoringBatteryOptimizations(context.getPackageName()));
|
||||
}
|
||||
|
@ -2666,7 +2663,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
Log.i("Received intent=" + intent +
|
||||
" " + TextUtils.join(" ", Log.getExtras(intent.getExtras())));
|
||||
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
||||
Integer status = (cm == null ? null : cm.getRestrictBackgroundStatus());
|
||||
EntityLog.log(context, "Data saver=" + status);
|
||||
|
||||
|
@ -2737,8 +2734,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
if (!isBackgroundService(ServiceSynchronize.this))
|
||||
try {
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(ServiceSynchronize.this, NotificationManager.class);
|
||||
nm.notify(NotificationHelper.NOTIFICATION_SYNCHRONIZE,
|
||||
getNotificationService(lastAccounts, lastOperations).build());
|
||||
} catch (Throwable ex) {
|
||||
|
|
|
@ -214,8 +214,7 @@ public class ServiceUI extends IntentService {
|
|||
// https://issuetracker.google.com/issues/159152393
|
||||
String tag = "unseen." + group + ":" + id;
|
||||
|
||||
NotificationManager nm =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
|
||||
nm.cancel(tag, NotificationHelper.NOTIFICATION_TAGGED);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class Shortcuts {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean enabled = prefs.getBoolean("shortcuts", true);
|
||||
|
||||
ShortcutManager sm = (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);
|
||||
ShortcutManager sm = Helper.getSystemService(context, ShortcutManager.class);
|
||||
int app = sm.getMaxShortcutCountPerActivity();
|
||||
int manifest = sm.getManifestShortcuts().size();
|
||||
int count = Math.min(app - manifest, MAX_SHORTCUTS);
|
||||
|
|
|
@ -85,7 +85,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|||
|
||||
private ExecutorService getExecutor(Context context) {
|
||||
if (wl == null) {
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager pm = Helper.getSystemService(context, PowerManager.class);
|
||||
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":task");
|
||||
}
|
||||
|
||||
|
|
|
@ -147,8 +147,7 @@ public class TextHelper {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
|
||||
return null;
|
||||
|
||||
TextClassificationManager tcm =
|
||||
(TextClassificationManager) context.getSystemService(Context.TEXT_CLASSIFICATION_SERVICE);
|
||||
TextClassificationManager tcm = Helper.getSystemService(context, TextClassificationManager.class);
|
||||
if (tcm == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
|
|||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
void createNotificationChannel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
|
||||
NotificationChannelGroup group = new NotificationChannelGroup("group." + accountId, accountName);
|
||||
nm.createNotificationChannelGroup(group);
|
||||
|
@ -105,7 +105,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
|
|||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
void deleteNotificationChannel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
nm.deleteNotificationChannel(getNotificationChannelId(id));
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ public class WorkerCleanup extends Worker {
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Log.i("Checking notification channels");
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
||||
for (NotificationChannel channel : nm.getNotificationChannels()) {
|
||||
String cid = channel.getId();
|
||||
Log.i("Notification channel id=" + cid + " name=" + channel.getName());
|
||||
|
|
Loading…
Reference in New Issue