Search in sources :

Example 66 with IActivityManager

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

the class ShutdownThread method shutdownInner.

static void shutdownInner(final Context context, boolean confirm) {
    // any additional calls are just returned
    synchronized (sIsStartedGuard) {
        if (sIsStarted) {
            Log.d(TAG, "Request to shutdown already running, returning.");
            return;
        }
    }
    final int longPressBehavior = context.getResources().getInteger(com.android.internal.R.integer.config_longPressOnPowerBehavior);
    final int resourceId = mRebootSafeMode ? com.android.internal.R.string.reboot_safemode_confirm : (longPressBehavior == 2 ? com.android.internal.R.string.shutdown_confirm_question : com.android.internal.R.string.shutdown_confirm);
    final int titleResourceId = mRebootSafeMode ? com.android.internal.R.string.reboot_safemode_title : (mReboot ? com.android.internal.R.string.reboot_system : com.android.internal.R.string.power_off);
    Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);
    if (confirm) {
        final CloseDialogReceiver closer = new CloseDialogReceiver(context);
        if (sConfirmDialog != null) {
            sConfirmDialog.dismiss();
            sConfirmDialog = null;
        }
        if (mReboot && !mRebootSafeMode) {
            // Determine if primary user is logged in
            boolean isPrimary = UserHandle.getCallingUserId() == UserHandle.USER_OWNER;
            // See if the advanced reboot menu is enabled
            // (only if primary user) and check the keyguard state
            int advancedReboot = isPrimary ? getAdvancedReboot(context) : 0;
            KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
            boolean locked = km.inKeyguardRestrictedInputMode();
            if ((advancedReboot == 1 && !locked) || advancedReboot == 2) {
                // Include options in power menu for rebooting into recovery or bootloader
                sConfirmDialog = new AlertDialog.Builder(context).setTitle(titleResourceId).setSingleChoiceItems(com.android.internal.R.array.shutdown_reboot_options, 0, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        if (which < 0)
                            return;
                        String[] actions = context.getResources().getStringArray(com.android.internal.R.array.shutdown_reboot_actions);
                        if (actions != null && which < actions.length) {
                            mReason = actions[which];
                            if (actions[which].equals(HOT_REBOOT)) {
                                mRebootHot = true;
                            } else {
                                mRebootHot = false;
                            }
                        }
                    }
                }).setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        if (mRebootHot) {
                            mRebootHot = false;
                            try {
                                final IActivityManager am = ActivityManagerNative.asInterface(ServiceManager.checkService("activity"));
                                if (am != null) {
                                    am.restart();
                                }
                            } catch (RemoteException e) {
                                Log.e(TAG, "failure trying to perform hot reboot", e);
                            }
                        } else {
                            mReboot = true;
                            beginShutdownSequence(context);
                        }
                    }
                }).setNegativeButton(com.android.internal.R.string.no, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        mReboot = false;
                        mRebootHot = false;
                        dialog.cancel();
                    }
                }).create();
                sConfirmDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {

                    public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                        if (keyCode == KeyEvent.KEYCODE_BACK) {
                            mReboot = false;
                            mRebootHot = false;
                            dialog.cancel();
                        }
                        return true;
                    }
                });
            }
        }
        if (sConfirmDialog == null) {
            sConfirmDialog = new AlertDialog.Builder(context).setTitle(titleResourceId).setMessage(resourceId).setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    beginShutdownSequence(context);
                }
            }).setNegativeButton(com.android.internal.R.string.no, null).create();
        }
        closer.dialog = sConfirmDialog;
        sConfirmDialog.setOnDismissListener(closer);
        WindowManager.LayoutParams attrs = sConfirmDialog.getWindow().getAttributes();
        boolean isPrimary = UserHandle.getCallingUserId() == UserHandle.USER_OWNER;
        int powermenuAnimations = isPrimary ? getPowermenuAnimations(context) : 0;
        switch(powermenuAnimations) {
            case 0:
                attrs.windowAnimations = R.style.GlobalActionsAnimationEnter;
                attrs.gravity = Gravity.CENTER | Gravity.CENTER_HORIZONTAL;
                break;
            case 1:
                attrs.windowAnimations = R.style.GlobalActionsAnimation;
                attrs.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
                break;
            case 2:
                attrs.windowAnimations = R.style.GlobalActionsAnimationTop;
                attrs.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
                break;
        }
        sConfirmDialog.getWindow().setDimAmount(setPowerRebootDialogDim(context));
        sConfirmDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
        sConfirmDialog.show();
    } else {
        beginShutdownSequence(context);
    }
}
Also used : DialogInterface(android.content.DialogInterface) WindowManager(android.view.WindowManager) KeyEvent(android.view.KeyEvent) RemoteException(android.os.RemoteException) KeyguardManager(android.app.KeyguardManager) IActivityManager(android.app.IActivityManager)

Example 67 with IActivityManager

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

the class SearchManagerService method launchLegacyAssist.

@Override
public boolean launchLegacyAssist(String hint, int userHandle, Bundle args) {
    ComponentName comp = getLegacyAssistComponent(userHandle);
    if (comp == null) {
        return false;
    }
    long ident = Binder.clearCallingIdentity();
    try {
        Intent intent = new Intent(Intent.ACTION_ASSIST);
        intent.setComponent(comp);
        IActivityManager am = ActivityManagerNative.getDefault();
        return am.launchAssistIntent(intent, ActivityManager.ASSIST_CONTEXT_BASIC, hint, userHandle, args);
    } catch (RemoteException e) {
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
    return true;
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 68 with IActivityManager

use of android.app.IActivityManager in project XobotOS by xamarin.

the class LocalePicker method updateLocale.

/**
     * Requests the system to update the system locale. 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 updateLocale(Locale locale) {
    try {
        IActivityManager am = ActivityManagerNative.getDefault();
        Configuration config = am.getConfiguration();
        config.locale = locale;
        // indicate this isn't some passing default - the user wants this remembered
        config.userSetLocale = true;
        am.updateConfiguration(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 69 with IActivityManager

use of android.app.IActivityManager in project XobotOS by xamarin.

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) {
                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)

Example 70 with IActivityManager

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

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)

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