Search in sources :

Example 11 with IActivityManager

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

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 12 with IActivityManager

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

the class ShellUiAutomatorBridge method getSystemLongPressTime.

public long getSystemLongPressTime() {
    // Read the long press timeout setting.
    long longPressTimeout = 0;
    try {
        IContentProvider provider = null;
        Cursor cursor = null;
        IActivityManager activityManager = ActivityManagerNative.getDefault();
        String providerName = Settings.Secure.CONTENT_URI.getAuthority();
        IBinder token = new Binder();
        try {
            ContentProviderHolder holder = activityManager.getContentProviderExternal(providerName, UserHandle.USER_SYSTEM, token);
            if (holder == null) {
                throw new IllegalStateException("Could not find provider: " + providerName);
            }
            provider = holder.provider;
            cursor = provider.query(null, Settings.Secure.CONTENT_URI, new String[] { Settings.Secure.VALUE }, "name=?", new String[] { Settings.Secure.LONG_PRESS_TIMEOUT }, null, null);
            if (cursor.moveToFirst()) {
                longPressTimeout = cursor.getInt(0);
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
            if (provider != null) {
                activityManager.removeContentProviderExternal(providerName, token);
            }
        }
    } catch (RemoteException e) {
        String message = "Error reading long press timeout setting.";
        Log.e(LOG_TAG, message, e);
        throw new RuntimeException(message, e);
    }
    return longPressTimeout;
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder) IBinder(android.os.IBinder) IContentProvider(android.content.IContentProvider) ContentProviderHolder(android.app.IActivityManager.ContentProviderHolder) Cursor(android.database.Cursor) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 13 with IActivityManager

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

the class ShellUiAutomatorBridge method getSystemLongPressTime.

public long getSystemLongPressTime() {
    // Read the long press timeout setting.
    long longPressTimeout = 0;
    try {
        IContentProvider provider = null;
        Cursor cursor = null;
        IActivityManager activityManager = ActivityManagerNative.getDefault();
        String providerName = Settings.Secure.CONTENT_URI.getAuthority();
        IBinder token = new Binder();
        try {
            ContentProviderHolder holder = activityManager.getContentProviderExternal(providerName, UserHandle.USER_SYSTEM, token);
            if (holder == null) {
                throw new IllegalStateException("Could not find provider: " + providerName);
            }
            provider = holder.provider;
            cursor = provider.query(null, Settings.Secure.CONTENT_URI, new String[] { Settings.Secure.VALUE }, "name=?", new String[] { Settings.Secure.LONG_PRESS_TIMEOUT }, null, null);
            if (cursor.moveToFirst()) {
                longPressTimeout = cursor.getInt(0);
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
            if (provider != null) {
                activityManager.removeContentProviderExternal(providerName, token);
            }
        }
    } catch (RemoteException e) {
        String message = "Error reading long press timeout setting.";
        Log.e(LOG_TAG, message, e);
        throw new RuntimeException(message, e);
    }
    return longPressTimeout;
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder) IBinder(android.os.IBinder) IContentProvider(android.content.IContentProvider) ContentProviderHolder(android.app.IActivityManager.ContentProviderHolder) Cursor(android.database.Cursor) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 14 with IActivityManager

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

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 15 with IActivityManager

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

the class Dpm method parseArgs.

private void parseArgs(boolean canHaveName) {
    String opt;
    while ((opt = nextOption()) != null) {
        if ("--user".equals(opt)) {
            String arg = nextArgRequired();
            if ("current".equals(arg) || "cur".equals(arg)) {
                mUserId = UserHandle.USER_CURRENT;
            } else {
                mUserId = parseInt(arg);
            }
            if (mUserId == UserHandle.USER_CURRENT) {
                IActivityManager activityManager = ActivityManagerNative.getDefault();
                try {
                    mUserId = activityManager.getCurrentUser().id;
                } catch (RemoteException e) {
                    e.rethrowAsRuntimeException();
                }
            }
        } else if (canHaveName && "--name".equals(opt)) {
            mName = nextArgRequired();
        } else {
            throw new IllegalArgumentException("Unknown option: " + opt);
        }
    }
    mComponent = parseComponentName(nextArgRequired());
}
Also used : RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Aggregations

IActivityManager (android.app.IActivityManager)112 RemoteException (android.os.RemoteException)93 Intent (android.content.Intent)23 IBinder (android.os.IBinder)20 Configuration (android.content.res.Configuration)15 UserHandle (android.os.UserHandle)14 ContentProviderHolder (android.app.IActivityManager.ContentProviderHolder)11 IContentProvider (android.content.IContentProvider)11 Binder (android.os.Binder)11 ActivityOptions (android.app.ActivityOptions)9 ActivityThread (android.app.ActivityThread)9 Context (android.content.Context)8 IntentSender (android.content.IntentSender)8 Point (android.graphics.Point)7 SpannableString (android.text.SpannableString)7 BroadcastReceiver (android.content.BroadcastReceiver)6 ComponentName (android.content.ComponentName)6 IMountService (android.os.storage.IMountService)6 IMountShutdownObserver (android.os.storage.IMountShutdownObserver)6 Locale (java.util.Locale)6