Java Code Examples for android.os.ServiceManager#getService()

The following examples show how to use android.os.ServiceManager#getService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccessibilityManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void tryConnectToServiceLocked(IAccessibilityManager service) {
    if (service == null) {
        IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE);
        if (iBinder == null) {
            return;
        }
        service = IAccessibilityManager.Stub.asInterface(iBinder);
    }

    try {
        final long userStateAndRelevantEvents = service.addClient(mClient, mUserId);
        setStateLocked(IntPair.first(userStateAndRelevantEvents));
        mRelevantEventTypes = IntPair.second(userStateAndRelevantEvents);
        mService = service;
    } catch (RemoteException re) {
        Log.e(LOG_TAG, "AccessibilityManagerService is dead", re);
    }
}
 
Example 2
Source File: BatteryStatsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public static IBatteryStats getService() {
    if (sService != null) {
        return sService;
    }
    IBinder b = ServiceManager.getService(BatteryStats.SERVICE_NAME);
    sService = asInterface(b);
    return sService;
}
 
Example 3
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(PERSISTENT_DATA_BLOCK_SERVICE);
    IPersistentDataBlockService persistentDataBlockService =
            IPersistentDataBlockService.Stub.asInterface(b);
    if (persistentDataBlockService != null) {
        return new PersistentDataBlockManager(persistentDataBlockService);
    } else {
        // not supported
        return null;
    }
}
 
Example 4
Source File: Watchdog.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Perform a full reboot of the system.
 */
void rebootSystem(String reason) {
    Slog.i(TAG, "Rebooting system because: " + reason);
    IPowerManager pms = (IPowerManager)ServiceManager.getService(Context.POWER_SERVICE);
    try {
        pms.reboot(false, reason, false);
    } catch (RemoteException ex) {
    }
}
 
Example 5
Source File: NetworkManagementService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public IBinder getService(String name) {
    return ServiceManager.getService(name);
}
 
Example 6
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(RESTRICTIONS_SERVICE);
    IRestrictionsManager service = IRestrictionsManager.Stub.asInterface(b);
    return new RestrictionsManager(ctx, service);
}
 
Example 7
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(APP_OPS_SERVICE);
    IAppOpsService service = IAppOpsService.Stub.asInterface(b);
    return new AppOpsManager(ctx, service);
}
 
Example 8
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(LOCATION_SERVICE);
    return new LocationManager(ctx, ILocationManager.Stub.asInterface(b));
}
 
Example 9
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(USB_SERVICE);
    return new UsbManager(ctx, IUsbManager.Stub.asInterface(b));
}
 
Example 10
Source File: DiskStatsService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private int getRecentPerf() throws RemoteException, IllegalStateException {
    IBinder binder = ServiceManager.getService("storaged");
    if (binder == null) throw new IllegalStateException("storaged not found");
    IStoraged storaged = IStoraged.Stub.asInterface(binder);
    return storaged.getRecentPerf();
}
 
Example 11
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(ACCOUNT_SERVICE);
    IAccountManager service = IAccountManager.Stub.asInterface(b);
    return new AccountManager(ctx, service);
}
 
Example 12
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(WIFI_SERVICE);
    IWifiManager service = IWifiManager.Stub.asInterface(b);
    return new WifiManager(ctx.getOuterContext(), service);
}
 
Example 13
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(ETHERNET_SERVICE);
    IEthernetManager service = IEthernetManager.Stub.asInterface(b);
    return new EthernetManager(ctx.getOuterContext(), service);
}
 
Example 14
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(ACCOUNT_SERVICE);
    IAccountManager service = IAccountManager.Stub.asInterface(b);
    return new AccountManager(ctx, service);
}
 
Example 15
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(RESTRICTIONS_SERVICE);
    IRestrictionsManager service = IRestrictionsManager.Stub.asInterface(b);
    return new RestrictionsManager(ctx, service);
}
 
Example 16
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(SERIAL_SERVICE);
    return new SerialManager(ctx, ISerialManager.Stub.asInterface(b));
}
 
Example 17
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createStaticService() {
    IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE);
    return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b));
}
 
Example 18
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(USB_SERVICE);
    return new UsbManager(ctx, IUsbManager.Stub.asInterface(b));
}
 
Example 19
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(NSD_SERVICE);
    INsdManager service = INsdManager.Stub.asInterface(b);
    return new NsdManager(ctx.getOuterContext(), service);
}
 
Example 20
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    IBinder b = ServiceManager.getService(WIFI_P2P_SERVICE);
    IWifiP2pManager service = IWifiP2pManager.Stub.asInterface(b);
    return new WifiP2pManager(service);
}