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

The following examples show how to use android.os.ServiceManager#addService() . 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: SettingsProvider.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onCreate() {
    Settings.setInSystemServer();
    synchronized (mLock) {
        mUserManager = UserManager.get(getContext());
        mPackageManager = AppGlobals.getPackageManager();
        mHandlerThread = new HandlerThread(LOG_TAG,
                Process.THREAD_PRIORITY_BACKGROUND);
        mHandlerThread.start();
        mHandler = new Handler(mHandlerThread.getLooper());
        mSettingsRegistry = new SettingsRegistry();
    }
    mHandler.post(() -> {
        registerBroadcastReceivers();
        startWatchingUserRestrictionChanges();
    });
    ServiceManager.addService("settings", new SettingsService(this));
    return true;
}
 
Example 2
Source File: OtaDexoptService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public static OtaDexoptService main(Context context,
        PackageManagerService packageManagerService) {
    OtaDexoptService ota = new OtaDexoptService(context, packageManagerService);
    ServiceManager.addService("otadexopt", ota);

    // Now it's time to check whether we need to move any A/B artifacts.
    ota.moveAbArtifacts(packageManagerService.mInstaller);

    return ota;
}
 
Example 3
Source File: BinderCallsStatsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public static void start() {
    BinderCallsStatsService service = new BinderCallsStatsService();
    ServiceManager.addService("binder_calls_stats", service);
    boolean detailedTrackingEnabled = SystemProperties.getBoolean(
            PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, false);

    if (detailedTrackingEnabled) {
        Slog.i(TAG, "Enabled CPU usage tracking for binder calls. Controlled by "
                + PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING
                + " or via dumpsys binder_calls_stats --enable-detailed-tracking");
        BinderCallsStats.getInstance().setDetailedTracking(true);
    }
}
 
Example 4
Source File: SuServiceStarter.java    From rebootmenu with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
private void hang() {
    Looper.prepareMainLooper();
    RMPowerActionService service = new RMPowerActionService(ActivityThread.systemMain().getSystemContext());
    ServiceManager.addService(XposedUtils.getServiceName(RMPowerActionService.TAG), service);
    service.allServicesInitialised();
    Looper.loop();
    throw new RuntimeException("Main thread loop unexpectedly exited");
}
 
Example 5
Source File: AppOpsService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void publish(Context context) {
    mContext = context;
    ServiceManager.addService(Context.APP_OPS_SERVICE, asBinder());
    LocalServices.addService(AppOpsManagerInternal.class, mAppOpsManagerInternal);
}
 
Example 6
Source File: BatteryStatsService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void publish() {
    LocalServices.addService(BatteryStatsInternal.class, new LocalService());
    ServiceManager.addService(BatteryStats.SERVICE_NAME, asBinder());
}
 
Example 7
Source File: SystemService.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Publish the service so it is accessible to other services and apps.
 *
 * @param name the name of the new service
 * @param service the service object
 * @param allowIsolated set to true to allow isolated sandboxed processes
 * to access this service
 * @param dumpPriority supported dump priority levels as a bitmask
 */
protected final void publishBinderService(String name, IBinder service,
        boolean allowIsolated, int dumpPriority) {
    ServiceManager.addService(name, service, allowIsolated, dumpPriority);
}