Search in sources :

Example 76 with IActivityManager

use of android.app.IActivityManager in project android_frameworks_base by ResurrectionRemix.

the class BroadcastReceiver method peekService.

/**
     * Provide a binder to an already-bound service.  This method is synchronous
     * and will not start the target service if it is not present, so it is safe
     * to call from {@link #onReceive}.
     *
     * For peekService() to return a non null {@link android.os.IBinder} interface
     * the service must have published it before. In other words some component
     * must have called {@link android.content.Context#bindService(Intent, ServiceConnection, int)} on it.
     *
     * @param myContext The Context that had been passed to {@link #onReceive(Context, Intent)}
     * @param service Identifies the already-bound service you wish to use. See
     * {@link android.content.Context#bindService(Intent, ServiceConnection, int)}
     * for more information.
     */
public IBinder peekService(Context myContext, Intent service) {
    IActivityManager am = ActivityManagerNative.getDefault();
    IBinder binder = null;
    try {
        service.prepareToLeaveProcess(myContext);
        binder = am.peekService(service, service.resolveTypeIfNeeded(myContext.getContentResolver()), myContext.getOpPackageName());
    } catch (RemoteException e) {
    }
    return binder;
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 77 with IActivityManager

use of android.app.IActivityManager in project android_frameworks_base by ResurrectionRemix.

the class OverlayManagerService method updateSelectedAssets.

private void updateSelectedAssets(final int userId, List<String> targetPackageNames) {
    final PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
    final boolean updateFrameworkRes = targetPackageNames.contains("android");
    if (updateFrameworkRes) {
        targetPackageNames = pm.getTargetPackageNames(userId);
    }
    final Map<String, String[]> allPaths = new ArrayMap<>(targetPackageNames.size());
    synchronized (mLock) {
        final List<String> frameworkPaths = mImpl.onGetEnabledOverlayPaths("android", userId);
        for (final String packageName : targetPackageNames) {
            final List<String> paths = new ArrayList<>();
            paths.addAll(frameworkPaths);
            if (!"android".equals(packageName)) {
                paths.addAll(mImpl.onGetEnabledOverlayPaths(packageName, userId));
            }
            allPaths.put(packageName, paths.isEmpty() ? null : paths.toArray(new String[paths.size()]));
        }
    }
    for (String packageName : targetPackageNames) {
        pm.setResourceDirs(userId, packageName, allPaths.get(packageName));
    }
    final IActivityManager am = ActivityManagerNative.getDefault();
    try {
        am.updateAssets(userId, targetPackageNames);
    } catch (RemoteException e) {
    // Intentionally left empty.
    }
}
Also used : ArrayList(java.util.ArrayList) PackageManagerInternal(android.content.pm.PackageManagerInternal) ArrayMap(android.util.ArrayMap) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 78 with IActivityManager

use of android.app.IActivityManager in project android_frameworks_base by ResurrectionRemix.

the class UserManagerService method runList.

private int runList(PrintWriter pw) throws RemoteException {
    final IActivityManager am = ActivityManagerNative.getDefault();
    final List<UserInfo> users = getUsers(false);
    if (users == null) {
        pw.println("Error: couldn't get users");
        return 1;
    } else {
        pw.println("Users:");
        for (int i = 0; i < users.size(); i++) {
            String running = am.isUserRunning(users.get(i).id, 0) ? " running" : "";
            pw.println("\t" + users.get(i).toString() + running);
        }
        return 0;
    }
}
Also used : UserInfo(android.content.pm.UserInfo) IActivityManager(android.app.IActivityManager)

Example 79 with IActivityManager

use of android.app.IActivityManager in project android_frameworks_base by DirtyUnicorns.

the class LocalePicker method updateLocales.

/**
     * Requests the system to update the list of system locales.
     * Note that the system looks halted for a while during the Locale migration,
     * so the caller need to take care of it.
     */
public static void updateLocales(LocaleList locales) {
    try {
        final IActivityManager am = ActivityManagerNative.getDefault();
        final Configuration config = am.getConfiguration();
        config.setLocales(locales);
        config.userSetLocale = true;
        am.updatePersistentConfiguration(config);
        // Trigger the dirty bit for the Settings Provider.
        BackupManager.dataChanged("com.android.providers.settings");
    } catch (RemoteException e) {
    // Intentionally left blank
    }
}
Also used : Configuration(android.content.res.Configuration) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 80 with IActivityManager

use of android.app.IActivityManager in project android_frameworks_base by ResurrectionRemix.

the class StrictMode method dropboxViolationAsync.

/**
     * In the common case, as set by conditionallyEnableDebugLogging,
     * we're just dropboxing any violations but not showing a dialog,
     * not loggging, and not killing the process.  In these cases we
     * don't need to do a synchronous call to the ActivityManager.
     * This is used by both per-thread and vm-wide violations when
     * applicable.
     */
private static void dropboxViolationAsync(final int violationMaskSubset, final ViolationInfo info) {
    int outstanding = sDropboxCallsInFlight.incrementAndGet();
    if (outstanding > 20) {
        // What's going on?  Let's not make make the situation
        // worse and just not log.
        sDropboxCallsInFlight.decrementAndGet();
        return;
    }
    if (LOG_V)
        Log.d(TAG, "Dropboxing async; in-flight=" + outstanding);
    new Thread("callActivityManagerForStrictModeDropbox") {

        public void run() {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            try {
                IActivityManager am = ActivityManagerNative.getDefault();
                if (am == null) {
                    Log.d(TAG, "No activity manager; failed to Dropbox violation.");
                } else {
                    am.handleApplicationStrictModeViolation(RuntimeInit.getApplicationObject(), violationMaskSubset, info);
                }
            } catch (RemoteException e) {
                if (e instanceof DeadObjectException) {
                // System process is dead; ignore
                } else {
                    Log.e(TAG, "RemoteException handling StrictMode violation", e);
                }
            }
            int outstanding = sDropboxCallsInFlight.decrementAndGet();
            if (LOG_V)
                Log.d(TAG, "Dropbox complete; in-flight=" + outstanding);
        }
    }.start();
}
Also used : ActivityThread(android.app.ActivityThread) IActivityManager(android.app.IActivityManager)

Aggregations

IActivityManager (android.app.IActivityManager)85 RemoteException (android.os.RemoteException)72 Intent (android.content.Intent)21 IBinder (android.os.IBinder)18 Configuration (android.content.res.Configuration)14 ContentProviderHolder (android.app.IActivityManager.ContentProviderHolder)11 IContentProvider (android.content.IContentProvider)11 Binder (android.os.Binder)11 ActivityThread (android.app.ActivityThread)7 Locale (java.util.Locale)7 BroadcastReceiver (android.content.BroadcastReceiver)6 Context (android.content.Context)6 IMountService (android.os.storage.IMountService)6 IMountShutdownObserver (android.os.storage.IMountShutdownObserver)6 Cursor (android.database.Cursor)5 ComponentName (android.content.ComponentName)4 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 UserInfo (android.content.pm.UserInfo)4 ErrnoException (android.system.ErrnoException)4 ArrayMap (android.util.ArrayMap)4