Search in sources :

Example 6 with ActivityContainer

use of com.android.server.am.ActivityStackSupervisor.ActivityContainer in project android_frameworks_base by AOSPA.

the class PendingIntentRecord method sendInner.

int sendInner(int code, Intent intent, String resolvedType, IIntentReceiver finishedReceiver, String requiredPermission, IBinder resultTo, String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle options, IActivityContainer container) {
    if (intent != null)
        intent.setDefusable(true);
    if (options != null)
        options.setDefusable(true);
    if (whitelistDuration > 0 && !canceled) {
        // Must call before acquiring the lock. It's possible the method return before sending
        // the intent due to some validations inside the lock, in which case the UID shouldn't
        // be whitelisted, but since the whitelist is temporary, that would be ok.
        owner.tempWhitelistAppForPowerSave(Binder.getCallingPid(), Binder.getCallingUid(), uid, whitelistDuration);
    }
    synchronized (owner) {
        final ActivityContainer activityContainer = (ActivityContainer) container;
        if (activityContainer != null && activityContainer.mParentActivity != null && activityContainer.mParentActivity.state != ActivityStack.ActivityState.RESUMED) {
            // Cannot start a child activity if the parent is not resumed.
            return ActivityManager.START_CANCELED;
        }
        if (!canceled) {
            sent = true;
            if ((key.flags & PendingIntent.FLAG_ONE_SHOT) != 0) {
                owner.cancelIntentSenderLocked(this, true);
                canceled = true;
            }
            Intent finalIntent = key.requestIntent != null ? new Intent(key.requestIntent) : new Intent();
            final boolean immutable = (key.flags & PendingIntent.FLAG_IMMUTABLE) != 0;
            if (!immutable) {
                if (intent != null) {
                    int changes = finalIntent.fillIn(intent, key.flags);
                    if ((changes & Intent.FILL_IN_DATA) == 0) {
                        resolvedType = key.requestResolvedType;
                    }
                } else {
                    resolvedType = key.requestResolvedType;
                }
                flagsMask &= ~Intent.IMMUTABLE_FLAGS;
                flagsValues &= flagsMask;
                finalIntent.setFlags((finalIntent.getFlags() & ~flagsMask) | flagsValues);
            } else {
                resolvedType = key.requestResolvedType;
            }
            final long origId = Binder.clearCallingIdentity();
            boolean sendFinish = finishedReceiver != null;
            int userId = key.userId;
            if (userId == UserHandle.USER_CURRENT) {
                userId = owner.mUserController.getCurrentOrTargetUserIdLocked();
            }
            int res = 0;
            switch(key.type) {
                case ActivityManager.INTENT_SENDER_ACTIVITY:
                    if (options == null) {
                        options = key.options;
                    } else if (key.options != null) {
                        Bundle opts = new Bundle(key.options);
                        opts.putAll(options);
                        options = opts;
                    }
                    try {
                        if (key.allIntents != null && key.allIntents.length > 1) {
                            Intent[] allIntents = new Intent[key.allIntents.length];
                            String[] allResolvedTypes = new String[key.allIntents.length];
                            System.arraycopy(key.allIntents, 0, allIntents, 0, key.allIntents.length);
                            if (key.allResolvedTypes != null) {
                                System.arraycopy(key.allResolvedTypes, 0, allResolvedTypes, 0, key.allResolvedTypes.length);
                            }
                            allIntents[allIntents.length - 1] = finalIntent;
                            allResolvedTypes[allResolvedTypes.length - 1] = resolvedType;
                            owner.startActivitiesInPackage(uid, key.packageName, allIntents, allResolvedTypes, resultTo, options, userId);
                        } else {
                            owner.startActivityInPackage(uid, key.packageName, finalIntent, resolvedType, resultTo, resultWho, requestCode, 0, options, userId, container, null);
                        }
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startActivity intent", e);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
                    if (key.activity.task.stack != null) {
                        key.activity.task.stack.sendActivityResultLocked(-1, key.activity, key.who, key.requestCode, code, finalIntent);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_BROADCAST:
                    try {
                        // If a completion callback has been requested, require
                        // that the broadcast be delivered synchronously
                        int sent = owner.broadcastIntentInPackage(key.packageName, uid, finalIntent, resolvedType, finishedReceiver, code, null, null, requiredPermission, options, (finishedReceiver != null), false, userId);
                        if (sent == ActivityManager.BROADCAST_SUCCESS) {
                            sendFinish = false;
                        }
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startActivity intent", e);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_SERVICE:
                    try {
                        owner.startServiceInPackage(uid, finalIntent, resolvedType, key.packageName, userId);
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startService intent", e);
                    } catch (TransactionTooLargeException e) {
                        res = ActivityManager.START_CANCELED;
                    }
                    break;
            }
            if (sendFinish && res != ActivityManager.START_CANCELED) {
                try {
                    finishedReceiver.performReceive(new Intent(finalIntent), 0, null, null, false, false, key.userId);
                } catch (RemoteException e) {
                }
            }
            Binder.restoreCallingIdentity(origId);
            return res;
        }
    }
    return ActivityManager.START_CANCELED;
}
Also used : Bundle(android.os.Bundle) ActivityContainer(com.android.server.am.ActivityStackSupervisor.ActivityContainer) IActivityContainer(android.app.IActivityContainer) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TransactionTooLargeException(android.os.TransactionTooLargeException) RemoteException(android.os.RemoteException)

Example 7 with ActivityContainer

use of com.android.server.am.ActivityStackSupervisor.ActivityContainer in project platform_frameworks_base by android.

the class ActivityStack method setVisible.

private void setVisible(ActivityRecord r, boolean visible) {
    r.visible = visible;
    if (!visible && r.mUpdateTaskThumbnailWhenHidden) {
        r.updateThumbnailLocked(r.task.stack.screenshotActivitiesLocked(r), null);
        r.mUpdateTaskThumbnailWhenHidden = false;
    }
    mWindowManager.setAppVisibility(r.appToken, visible);
    final ArrayList<ActivityContainer> containers = r.mChildContainers;
    for (int containerNdx = containers.size() - 1; containerNdx >= 0; --containerNdx) {
        ActivityContainer container = containers.get(containerNdx);
        container.setVisible(visible);
    }
    mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
}
Also used : ActivityContainer(com.android.server.am.ActivityStackSupervisor.ActivityContainer) Point(android.graphics.Point)

Example 8 with ActivityContainer

use of com.android.server.am.ActivityStackSupervisor.ActivityContainer in project android_frameworks_base by AOSPA.

the class ActivityStack method setVisible.

private void setVisible(ActivityRecord r, boolean visible) {
    r.visible = visible;
    if (!visible && r.mUpdateTaskThumbnailWhenHidden) {
        r.updateThumbnailLocked(r.task.stack.screenshotActivitiesLocked(r), null);
        r.mUpdateTaskThumbnailWhenHidden = false;
    }
    mWindowManager.setAppVisibility(r.appToken, visible);
    final ArrayList<ActivityContainer> containers = r.mChildContainers;
    for (int containerNdx = containers.size() - 1; containerNdx >= 0; --containerNdx) {
        ActivityContainer container = containers.get(containerNdx);
        container.setVisible(visible);
    }
    mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
}
Also used : ActivityContainer(com.android.server.am.ActivityStackSupervisor.ActivityContainer) Point(android.graphics.Point)

Example 9 with ActivityContainer

use of com.android.server.am.ActivityStackSupervisor.ActivityContainer in project android_frameworks_base by ResurrectionRemix.

the class PendingIntentRecord method sendInner.

int sendInner(int code, Intent intent, String resolvedType, IIntentReceiver finishedReceiver, String requiredPermission, IBinder resultTo, String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle options, IActivityContainer container) {
    if (intent != null)
        intent.setDefusable(true);
    if (options != null)
        options.setDefusable(true);
    if (whitelistDuration > 0 && !canceled) {
        // Must call before acquiring the lock. It's possible the method return before sending
        // the intent due to some validations inside the lock, in which case the UID shouldn't
        // be whitelisted, but since the whitelist is temporary, that would be ok.
        owner.tempWhitelistAppForPowerSave(Binder.getCallingPid(), Binder.getCallingUid(), uid, whitelistDuration);
    }
    synchronized (owner) {
        final ActivityContainer activityContainer = (ActivityContainer) container;
        if (activityContainer != null && activityContainer.mParentActivity != null && activityContainer.mParentActivity.state != ActivityStack.ActivityState.RESUMED) {
            // Cannot start a child activity if the parent is not resumed.
            return ActivityManager.START_CANCELED;
        }
        if (!canceled) {
            sent = true;
            if ((key.flags & PendingIntent.FLAG_ONE_SHOT) != 0) {
                owner.cancelIntentSenderLocked(this, true);
                canceled = true;
            }
            Intent finalIntent = key.requestIntent != null ? new Intent(key.requestIntent) : new Intent();
            final boolean immutable = (key.flags & PendingIntent.FLAG_IMMUTABLE) != 0;
            if (!immutable) {
                if (intent != null) {
                    int changes = finalIntent.fillIn(intent, key.flags);
                    if ((changes & Intent.FILL_IN_DATA) == 0) {
                        resolvedType = key.requestResolvedType;
                    }
                } else {
                    resolvedType = key.requestResolvedType;
                }
                flagsMask &= ~Intent.IMMUTABLE_FLAGS;
                flagsValues &= flagsMask;
                finalIntent.setFlags((finalIntent.getFlags() & ~flagsMask) | flagsValues);
            } else {
                resolvedType = key.requestResolvedType;
            }
            final long origId = Binder.clearCallingIdentity();
            boolean sendFinish = finishedReceiver != null;
            int userId = key.userId;
            if (userId == UserHandle.USER_CURRENT) {
                userId = owner.mUserController.getCurrentOrTargetUserIdLocked();
            }
            int res = 0;
            switch(key.type) {
                case ActivityManager.INTENT_SENDER_ACTIVITY:
                    if (options == null) {
                        options = key.options;
                    } else if (key.options != null) {
                        Bundle opts = new Bundle(key.options);
                        opts.putAll(options);
                        options = opts;
                    }
                    try {
                        if (key.allIntents != null && key.allIntents.length > 1) {
                            Intent[] allIntents = new Intent[key.allIntents.length];
                            String[] allResolvedTypes = new String[key.allIntents.length];
                            System.arraycopy(key.allIntents, 0, allIntents, 0, key.allIntents.length);
                            if (key.allResolvedTypes != null) {
                                System.arraycopy(key.allResolvedTypes, 0, allResolvedTypes, 0, key.allResolvedTypes.length);
                            }
                            allIntents[allIntents.length - 1] = finalIntent;
                            allResolvedTypes[allResolvedTypes.length - 1] = resolvedType;
                            owner.startActivitiesInPackage(uid, key.packageName, allIntents, allResolvedTypes, resultTo, options, userId);
                        } else {
                            owner.startActivityInPackage(uid, key.packageName, finalIntent, resolvedType, resultTo, resultWho, requestCode, 0, options, userId, container, null);
                        }
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startActivity intent", e);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
                    if (key.activity.task.stack != null) {
                        key.activity.task.stack.sendActivityResultLocked(-1, key.activity, key.who, key.requestCode, code, finalIntent);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_BROADCAST:
                    try {
                        // If a completion callback has been requested, require
                        // that the broadcast be delivered synchronously
                        int sent = owner.broadcastIntentInPackage(key.packageName, uid, finalIntent, resolvedType, finishedReceiver, code, null, null, requiredPermission, options, (finishedReceiver != null), false, userId);
                        if (sent == ActivityManager.BROADCAST_SUCCESS) {
                            sendFinish = false;
                        }
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startActivity intent", e);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_SERVICE:
                    try {
                        owner.startServiceInPackage(uid, finalIntent, resolvedType, key.packageName, userId);
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startService intent", e);
                    } catch (TransactionTooLargeException e) {
                        res = ActivityManager.START_CANCELED;
                    }
                    break;
            }
            if (sendFinish && res != ActivityManager.START_CANCELED) {
                try {
                    finishedReceiver.performReceive(new Intent(finalIntent), 0, null, null, false, false, key.userId);
                } catch (RemoteException e) {
                }
            }
            Binder.restoreCallingIdentity(origId);
            return res;
        }
    }
    return ActivityManager.START_CANCELED;
}
Also used : Bundle(android.os.Bundle) ActivityContainer(com.android.server.am.ActivityStackSupervisor.ActivityContainer) IActivityContainer(android.app.IActivityContainer) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TransactionTooLargeException(android.os.TransactionTooLargeException) RemoteException(android.os.RemoteException)

Example 10 with ActivityContainer

use of com.android.server.am.ActivityStackSupervisor.ActivityContainer in project android_frameworks_base by ResurrectionRemix.

the class ActivityStack method setVisible.

private void setVisible(ActivityRecord r, boolean visible) {
    r.visible = visible;
    if (!visible && r.mUpdateTaskThumbnailWhenHidden) {
        r.updateThumbnailLocked(r.task.stack.screenshotActivitiesLocked(r), null);
        r.mUpdateTaskThumbnailWhenHidden = false;
    }
    mWindowManager.setAppVisibility(r.appToken, visible);
    final ArrayList<ActivityContainer> containers = r.mChildContainers;
    for (int containerNdx = containers.size() - 1; containerNdx >= 0; --containerNdx) {
        ActivityContainer container = containers.get(containerNdx);
        container.setVisible(visible);
    }
    mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
}
Also used : ActivityContainer(com.android.server.am.ActivityStackSupervisor.ActivityContainer) Point(android.graphics.Point)

Aggregations

ActivityContainer (com.android.server.am.ActivityStackSupervisor.ActivityContainer)10 IActivityContainer (android.app.IActivityContainer)5 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 Point (android.graphics.Point)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 TransactionTooLargeException (android.os.TransactionTooLargeException)5