2015-07-07 14:25:41 -07:00
|
|
|
package org.thoughtcrime.securesms.util;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
2019-07-25 15:29:31 -04:00
|
|
|
import android.app.ActivityManager;
|
2017-11-27 12:18:14 -08:00
|
|
|
import android.app.AlarmManager;
|
2015-09-29 13:14:22 -07:00
|
|
|
import android.app.NotificationManager;
|
2019-05-31 17:12:41 -04:00
|
|
|
import android.app.job.JobScheduler;
|
2015-07-07 14:25:41 -07:00
|
|
|
import android.content.Context;
|
2019-06-26 18:10:57 -04:00
|
|
|
import android.hardware.display.DisplayManager;
|
2019-10-15 12:45:03 -04:00
|
|
|
import android.location.LocationManager;
|
2015-11-04 10:42:19 -08:00
|
|
|
import android.media.AudioManager;
|
2015-08-24 15:24:31 -07:00
|
|
|
import android.net.ConnectivityManager;
|
2019-04-19 12:36:00 -03:00
|
|
|
import android.os.Build;
|
2017-03-26 16:55:43 +02:00
|
|
|
import android.os.PowerManager;
|
2017-12-05 11:52:03 -08:00
|
|
|
import android.os.Vibrator;
|
2019-06-05 15:47:14 -04:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.RequiresApi;
|
2019-10-15 12:45:03 -04:00
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
|
2019-04-19 12:36:00 -03:00
|
|
|
import android.telephony.SubscriptionManager;
|
2015-10-28 10:24:55 -07:00
|
|
|
import android.telephony.TelephonyManager;
|
2015-07-07 14:25:41 -07:00
|
|
|
import android.view.WindowManager;
|
2019-07-29 09:36:48 -04:00
|
|
|
import android.view.accessibility.AccessibilityManager;
|
2015-07-07 14:25:41 -07:00
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
|
|
|
|
public class ServiceUtil {
|
|
|
|
public static InputMethodManager getInputMethodManager(Context context) {
|
|
|
|
return (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static WindowManager getWindowManager(Context context) {
|
|
|
|
return (WindowManager) context.getSystemService(Activity.WINDOW_SERVICE);
|
|
|
|
}
|
2015-08-24 15:24:31 -07:00
|
|
|
|
|
|
|
public static ConnectivityManager getConnectivityManager(Context context) {
|
|
|
|
return (ConnectivityManager) context.getSystemService(Activity.CONNECTIVITY_SERVICE);
|
|
|
|
}
|
2015-09-29 13:14:22 -07:00
|
|
|
|
|
|
|
public static NotificationManager getNotificationManager(Context context) {
|
|
|
|
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
}
|
2015-10-28 10:24:55 -07:00
|
|
|
|
|
|
|
public static TelephonyManager getTelephonyManager(Context context) {
|
|
|
|
return (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
}
|
2015-11-04 10:42:19 -08:00
|
|
|
|
|
|
|
public static AudioManager getAudioManager(Context context) {
|
|
|
|
return (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
|
|
|
|
}
|
2017-03-26 16:55:43 +02:00
|
|
|
|
|
|
|
public static PowerManager getPowerManager(Context context) {
|
|
|
|
return (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
|
|
|
}
|
2017-11-27 12:18:14 -08:00
|
|
|
|
|
|
|
public static AlarmManager getAlarmManager(Context context) {
|
|
|
|
return (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
|
|
|
}
|
2017-12-05 11:52:03 -08:00
|
|
|
|
|
|
|
public static Vibrator getVibrator(Context context) {
|
|
|
|
return (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
|
|
|
|
}
|
2019-04-19 12:36:00 -03:00
|
|
|
|
2019-06-26 18:10:57 -04:00
|
|
|
public static DisplayManager getDisplayManager(@NonNull Context context) {
|
|
|
|
return (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
|
|
|
}
|
|
|
|
|
2019-07-29 09:36:48 -04:00
|
|
|
public static AccessibilityManager getAccessibilityManager(@NonNull Context context) {
|
|
|
|
return (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
|
|
|
}
|
|
|
|
|
2019-05-31 17:12:41 -04:00
|
|
|
@RequiresApi(26)
|
|
|
|
public static JobScheduler getJobScheduler(Context context) {
|
|
|
|
return (JobScheduler) context.getSystemService(JobScheduler.class);
|
|
|
|
}
|
|
|
|
|
2019-04-19 12:36:00 -03:00
|
|
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
|
2019-05-01 08:36:24 -07:00
|
|
|
public static @Nullable SubscriptionManager getSubscriptionManager(@NonNull Context context) {
|
2019-05-23 11:38:24 -03:00
|
|
|
return (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
2019-04-19 12:36:00 -03:00
|
|
|
}
|
2019-07-25 15:29:31 -04:00
|
|
|
|
|
|
|
public static ActivityManager getActivityManager(@NonNull Context context) {
|
|
|
|
return (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
|
|
|
}
|
2019-10-15 12:45:03 -04:00
|
|
|
|
|
|
|
public static LocationManager getLocationManager(@NonNull Context context) {
|
|
|
|
return ContextCompat.getSystemService(context, LocationManager.class);
|
|
|
|
}
|
2015-07-07 14:25:41 -07:00
|
|
|
}
|