/** * @deprecated Please use {@link Context#getSystemService(Context.APPWIDGET_SERVICE)} intstead. */ @Deprecated public AppWidgetManager getAppWidgetManager() { return (AppWidgetManager) realApplication.getSystemService(Context.APPWIDGET_SERVICE); }
private void removeForegroundNotification() { NotificationManager nm = (NotificationManager)RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(lastForegroundNotificationId); lastForegroundNotification = null; }
@Override public Object getSystemService(String name) { Object service = super.getSystemService(name); if (applicationLike != null) { return invokeAppLikeGetSystemService(applicationLike, name, service); } return service; }
@Implementation protected final void startForeground(int id, Notification notification) { foregroundStopped = false; lastForegroundNotificationId = id; lastForegroundNotification = notification; notification.flags |= Notification.FLAG_FOREGROUND_SERVICE; NotificationManager nm = (NotificationManager)RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(id, notification); }
public ConnectivityHarness() { ConnectivityManager connectivityManager = (ConnectivityManager) RuntimeEnvironment.application .getSystemService(Context.CONNECTIVITY_SERVICE); shadowConnectivityManager = Shadow.extract(connectivityManager); }
@Test @Config(minSdk = JELLY_BEAN_MR1) public void shouldProvideServicesIntroducedInJellyBeanMr1() throws Exception { assertThat(context.getSystemService(Context.DISPLAY_SERVICE)) .isInstanceOf(android.hardware.display.DisplayManager.class); assertThat(context.getSystemService(Context.USER_SERVICE)).isInstanceOf(UserManager.class); }
@Test @Config(minSdk = O) public void shouldProvideServicesIntroducedOreo() throws Exception { // Context.AUTOFILL_MANAGER_SERVICE is marked @hide and this is the documented way to obtain // this service. AutofillManager autofillManager = context.getSystemService(AutofillManager.class); assertThat(autofillManager).isNotNull(); assertThat(context.getSystemService(Context.TEXT_CLASSIFICATION_SERVICE)) .isInstanceOf(TextClassificationManager.class); }
@Test @Config(minSdk = JELLY_BEAN_MR2) public void getSystemService_shouldReturnBluetoothAdapter() { assertThat(context.getSystemService(Context.BLUETOOTH_SERVICE)) .isInstanceOf(BluetoothManager.class); }
@HiddenApi @Implementation(minSdk = JELLY_BEAN_MR1) protected boolean switchUser(int userid) { ShadowUserManager shadowUserManager = Shadow.extract(RuntimeEnvironment.application.getSystemService(Context.USER_SERVICE)); shadowUserManager.switchUser(userid); return true; }
@Before public void setUp() { NotificationManager notificationManager = (NotificationManager) RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE); shadowManager = Shadow.extract(notificationManager); remoteViews = mock(RemoteViews.class); viewId = 123; notification = mock(Notification.class); notificationId = 456; notificationTag = "tag"; target = new NotificationTarget(RuntimeEnvironment.application, 100 /*width*/, 100 /*height*/, viewId, remoteViews, notification, notificationId, notificationTag); }
@Before public void setUp() { euiccManager = application.getSystemService(EuiccManager.class); shadowEuiccManager = Shadows.shadowOf(euiccManager); }
@Before public void setUp() { context = ApplicationProvider.getApplicationContext(); jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); }
@Test public void removeSystemService_getSystemServiceReturnsNull() { shadowContext.removeSystemService(Context.WALLPAPER_SERVICE); assertThat(context.getSystemService(Context.WALLPAPER_SERVICE)).isNull(); }
@Test public void createPackageContext() throws Exception { Context packageContext = context.createPackageContext(context.getPackageName(), 0); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.cloneInContext(packageContext); inflater.inflate(R.layout.remote_views, new FrameLayout(context), false); }
@Before public void setUp() { audioManager = (AudioManager) RuntimeEnvironment.application.getSystemService(Context.AUDIO_SERVICE); testPlayerControl = new TestPlayerControl(); audioFocusManager = new AudioFocusManager(RuntimeEnvironment.application, testPlayerControl); }
private void setDisplayDimens(Integer width, Integer height) { WindowManager windowManager = (WindowManager) RuntimeEnvironment.application.getSystemService(Context.WINDOW_SERVICE); Display display = Preconditions.checkNotNull(windowManager).getDefaultDisplay(); if (width != null) { Shadows.shadowOf(display).setWidth(width); } if (height != null) { Shadows.shadowOf(display).setHeight(height); } }
private void setDisplayDimens(Integer width, Integer height) { WindowManager windowManager = (WindowManager) RuntimeEnvironment.application.getSystemService(Context.WINDOW_SERVICE); Display display = Preconditions.checkNotNull(windowManager).getDefaultDisplay(); if (width != null) { Shadows.shadowOf(display).setWidth(width); } if (height != null) { Shadows.shadowOf(display).setHeight(height); } }
@Before public void setUp() { context = ApplicationProvider.getApplicationContext(); locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); shadowLocationManager = shadowOf(locationManager); }
@Test @Config(minSdk = KITKAT) public void shouldCorrectlyInstantiatedAccessibilityService() throws Exception { AccessibilityManager accessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); AccessibilityManager.TouchExplorationStateChangeListener listener = createTouchListener(); assertThat(accessibilityManager.addTouchExplorationStateChangeListener(listener)).isTrue(); assertThat(accessibilityManager.removeTouchExplorationStateChangeListener(listener)).isTrue(); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); Application context = ApplicationProvider.getApplicationContext(); manager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE); shadowManager = shadowOf(manager); channel = manager.initialize(context, context.getMainLooper(), mockListener); assertThat(channel).isNotNull(); }