Search in sources :

Example 41 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class GuestResumeSessionReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (Intent.ACTION_USER_SWITCHED.equals(action)) {
        cancelDialog();
        int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
        if (userId == UserHandle.USER_NULL) {
            Log.e(TAG, intent + " sent to " + TAG + " without EXTRA_USER_HANDLE");
            return;
        }
        UserInfo currentUser;
        try {
            currentUser = ActivityManagerNative.getDefault().getCurrentUser();
        } catch (RemoteException e) {
            return;
        }
        if (!currentUser.isGuest()) {
            return;
        }
        ContentResolver cr = context.getContentResolver();
        int notFirstLogin = Settings.System.getIntForUser(cr, SETTING_GUEST_HAS_LOGGED_IN, 0, userId);
        if (notFirstLogin != 0) {
            mNewSessionDialog = new ResetSessionDialog(context, userId);
            mNewSessionDialog.show();
        } else {
            Settings.System.putIntForUser(cr, SETTING_GUEST_HAS_LOGGED_IN, 1, userId);
        }
    }
}
Also used : UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException) ContentResolver(android.content.ContentResolver)

Example 42 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class BaseStatusBar method start.

public void start() {
    mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
    mDisplay = mWindowManager.getDefaultDisplay();
    mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
    mNotificationData = new NotificationData(this);
    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    mDreamManager = IDreamManager.Stub.asInterface(ServiceManager.checkService(DreamService.DREAM_SERVICE));
    mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, mSettingsObserver);
    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false, mSettingsObserver);
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false, mSettingsObserver, UserHandle.USER_ALL);
    if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) {
        mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT), false, mSettingsObserver, UserHandle.USER_ALL);
    }
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS), true, mLockscreenSettingsObserver, UserHandle.USER_ALL);
    mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    mRecents = getComponent(Recents.class);
    final Configuration currentConfig = mContext.getResources().getConfiguration();
    mLocale = currentConfig.locale;
    mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);
    mFontScale = currentConfig.fontScale;
    mDensity = currentConfig.densityDpi;
    mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
    mLockPatternUtils = new LockPatternUtils(mContext);
    // Connect in to the status bar manager service
    mCommandQueue = new CommandQueue(this);
    int[] switches = new int[9];
    ArrayList<IBinder> binders = new ArrayList<IBinder>();
    ArrayList<String> iconSlots = new ArrayList<>();
    ArrayList<StatusBarIcon> icons = new ArrayList<>();
    Rect fullscreenStackBounds = new Rect();
    Rect dockedStackBounds = new Rect();
    try {
        mBarService.registerStatusBar(mCommandQueue, iconSlots, icons, switches, binders, fullscreenStackBounds, dockedStackBounds);
    } catch (RemoteException ex) {
    // If the system process isn't there we're doomed anyway.
    }
    createAndAddWindows();
    // set up
    mSettingsObserver.onChange(false);
    disable(switches[0], switches[6], false);
    setSystemUiVisibility(switches[1], switches[7], switches[8], 0xffffffff, fullscreenStackBounds, dockedStackBounds);
    topAppWindowChanged(switches[2] != 0);
    // StatusBarManagerService has a back up of IME token and it's restored here.
    setImeWindowStatus(binders.get(0), switches[3], switches[4], switches[5] != 0);
    // Set up the initial icon state
    int N = iconSlots.size();
    int viewIndex = 0;
    for (int i = 0; i < N; i++) {
        setIcon(iconSlots.get(i), icons.get(i));
    }
    // Set up the initial notification state.
    try {
        mNotificationListener.registerAsSystemService(mContext, new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()), UserHandle.USER_ALL);
    } catch (RemoteException e) {
        Log.e(TAG, "Unable to register notification listener", e);
    }
    if (DEBUG) {
        Log.d(TAG, String.format("init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x", icons.size(), switches[0], switches[1], switches[2], switches[3]));
    }
    mCurrentUserId = ActivityManager.getCurrentUser();
    setHeadsUpUser(mCurrentUserId);
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_SWITCHED);
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    mContext.registerReceiver(mBroadcastReceiver, filter);
    IntentFilter internalFilter = new IntentFilter();
    internalFilter.addAction(WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION);
    internalFilter.addAction(BANNER_ACTION_CANCEL);
    internalFilter.addAction(BANNER_ACTION_SETUP);
    mContext.registerReceiver(mBroadcastReceiver, internalFilter, PERMISSION_SELF, null);
    IntentFilter allUsersFilter = new IntentFilter();
    allUsersFilter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
    mContext.registerReceiverAsUser(mAllUsersReceiver, UserHandle.ALL, allUsersFilter, null, null);
    updateCurrentProfilesCache();
    IVrManager vrManager = IVrManager.Stub.asInterface(ServiceManager.getService("vrmanager"));
    try {
        vrManager.registerListener(mVrStateCallbacks);
    } catch (RemoteException e) {
        Slog.e(TAG, "Failed to register VR mode state listener: " + e);
    }
    mNonBlockablePkgs = new ArraySet<String>();
    Collections.addAll(mNonBlockablePkgs, mContext.getResources().getStringArray(com.android.internal.R.array.config_nonBlockableNotificationPackages));
}
Also used : IntentFilter(android.content.IntentFilter) Rect(android.graphics.Rect) Recents(com.android.systemui.recents.Recents) Configuration(android.content.res.Configuration) LockPatternUtils(com.android.internal.widget.LockPatternUtils) ArrayList(java.util.ArrayList) IBinder(android.os.IBinder) ComponentName(android.content.ComponentName) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException) IVrManager(android.service.vr.IVrManager)

Example 43 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class BaseStatusBar method startWorkChallengeIfNecessary.

protected boolean startWorkChallengeIfNecessary(int userId, IntentSender intendSender, String notificationKey) {
    final Intent newIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null, null, userId);
    if (newIntent == null) {
        return false;
    }
    final Intent callBackIntent = new Intent(WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION);
    callBackIntent.putExtra(Intent.EXTRA_INTENT, intendSender);
    callBackIntent.putExtra(Intent.EXTRA_INDEX, notificationKey);
    callBackIntent.setPackage(mContext.getPackageName());
    PendingIntent callBackPendingIntent = PendingIntent.getBroadcast(mContext, 0, callBackIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
    newIntent.putExtra(Intent.EXTRA_INTENT, callBackPendingIntent.getIntentSender());
    try {
        ActivityManagerNative.getDefault().startConfirmDeviceCredentialIntent(newIntent);
    } catch (RemoteException ex) {
    // ignore
    }
    return true;
}
Also used : PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RemoteException(android.os.RemoteException)

Example 44 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class BaseStatusBar method startPendingIntentDismissingKeyguard.

public void startPendingIntentDismissingKeyguard(final PendingIntent intent) {
    if (!isDeviceProvisioned())
        return;
    final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
    final boolean afterKeyguardGone = intent.isActivity() && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(), mCurrentUserId);
    dismissKeyguardThenExecute(new OnDismissAction() {

        public boolean onDismiss() {
            new Thread() {

                @Override
                public void run() {
                    try {
                        if (keyguardShowing && !afterKeyguardGone) {
                            ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
                        }
                        // The intent we are sending is for the application, which
                        // won't have permission to immediately start an activity after
                        // the user switches to home.  We know it is safe to do at this
                        // point, so make sure new activity switches are now allowed.
                        ActivityManagerNative.getDefault().resumeAppSwitches();
                    } catch (RemoteException e) {
                    }
                    try {
                        intent.send(null, 0, null, null, null, null, getActivityOptions());
                    } catch (PendingIntent.CanceledException e) {
                        // the stack trace isn't very helpful here.
                        // Just log the exception message.
                        Log.w(TAG, "Sending intent failed: " + e);
                    // TODO: Dismiss Keyguard.
                    }
                    if (intent.isActivity()) {
                        mAssistManager.hideAssist();
                        overrideActivityPendingAppTransition(keyguardShowing && !afterKeyguardGone);
                    }
                }
            }.start();
            // close the shade if it was open
            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, /* force */
            true);
            visibilityChanged(false);
            return true;
        }
    }, afterKeyguardGone);
}
Also used : OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) PendingIntent(android.app.PendingIntent) RemoteException(android.os.RemoteException)

Example 45 with RemoteException

use of android.os.RemoteException in project platform_frameworks_base by android.

the class BaseStatusBar method startNotificationGutsIntent.

private void startNotificationGutsIntent(final Intent intent, final int appUid) {
    final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
    dismissKeyguardThenExecute(new OnDismissAction() {

        @Override
        public boolean onDismiss() {
            AsyncTask.execute(new Runnable() {

                public void run() {
                    try {
                        if (keyguardShowing) {
                            ActivityManagerNative.getDefault().keyguardWaitingForActivityDrawn();
                        }
                        TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities(getActivityOptions(), new UserHandle(UserHandle.getUserId(appUid)));
                        overrideActivityPendingAppTransition(keyguardShowing);
                    } catch (RemoteException e) {
                    }
                }
            });
            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true);
            return true;
        }
    }, false);
}
Also used : UserHandle(android.os.UserHandle) OnDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)4527 Intent (android.content.Intent)595 IBinder (android.os.IBinder)480 Bundle (android.os.Bundle)461 Point (android.graphics.Point)423 IOException (java.io.IOException)381 PendingIntent (android.app.PendingIntent)274 ComponentName (android.content.ComponentName)265 ArrayList (java.util.ArrayList)248 ApplicationInfo (android.content.pm.ApplicationInfo)190 IPackageManager (android.content.pm.IPackageManager)190 Message (android.os.Message)184 Uri (android.net.Uri)157 UserHandle (android.os.UserHandle)154 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)151 Cursor (android.database.Cursor)150 Configuration (android.content.res.Configuration)133 UserInfo (android.content.pm.UserInfo)129 AndroidRuntimeException (android.util.AndroidRuntimeException)128 ParcelFileDescriptor (android.os.ParcelFileDescriptor)126