Search in sources :

Example 56 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class ActivityManagerService method updateConfigurationLocked.

/**
     * Do either or both things: (1) change the current configuration, and (2)
     * make sure the given activity is running with the (now) current
     * configuration.  Returns true if the activity has been left running, or
     * false if <var>starting</var> is being destroyed to match the new
     * configuration.
     *
     * @param userId is only used when persistent parameter is set to true to persist configuration
     *               for that particular user
     */
private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting, boolean initLocale, boolean persistent, int userId, boolean deferResume) {
    int changes = 0;
    if (mWindowManager != null) {
        mWindowManager.deferSurfaceLayout();
    }
    if (values != null) {
        Configuration newConfig = new Configuration(mConfiguration);
        changes = newConfig.updateFrom(values);
        if (changes != 0) {
            if (DEBUG_SWITCH || DEBUG_CONFIGURATION)
                Slog.i(TAG_CONFIGURATION, "Updating configuration to: " + values);
            EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
            if (!initLocale && !values.getLocales().isEmpty() && values.userSetLocale) {
                final LocaleList locales = values.getLocales();
                int bestLocaleIndex = 0;
                if (locales.size() > 1) {
                    if (mSupportedSystemLocales == null) {
                        mSupportedSystemLocales = Resources.getSystem().getAssets().getLocales();
                    }
                    bestLocaleIndex = Math.max(0, locales.getFirstMatchIndex(mSupportedSystemLocales));
                }
                SystemProperties.set("persist.sys.locale", locales.get(bestLocaleIndex).toLanguageTag());
                LocaleList.setDefault(locales, bestLocaleIndex);
                mHandler.sendMessage(mHandler.obtainMessage(SEND_LOCALE_TO_MOUNT_DAEMON_MSG, locales.get(bestLocaleIndex)));
            }
            mConfigurationSeq++;
            if (mConfigurationSeq <= 0) {
                mConfigurationSeq = 1;
            }
            newConfig.seq = mConfigurationSeq;
            mConfiguration = newConfig;
            Slog.i(TAG, "Config changes=" + Integer.toHexString(changes) + " " + newConfig);
            mUsageStatsService.reportConfigurationChange(newConfig, mUserController.getCurrentUserIdLocked());
            //mUsageStatsService.noteStartConfig(newConfig);
            final Configuration configCopy = new Configuration(mConfiguration);
            // TODO: If our config changes, should we auto dismiss any currently
            // showing dialogs?
            mShowDialogs = shouldShowDialogs(newConfig, mInVrMode);
            AttributeCache ac = AttributeCache.instance();
            if (ac != null) {
                ac.updateConfiguration(configCopy);
            }
            // Make sure all resources in our process are updated
            // right now, so that anyone who is going to retrieve
            // resource values after we return will be sure to get
            // the new ones.  This is especially important during
            // boot, where the first config change needs to guarantee
            // all resources have that config before following boot
            // code is executed.
            mSystemThread.applyConfigurationToResources(configCopy);
            if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) {
                Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
                msg.obj = new Configuration(configCopy);
                msg.arg1 = userId;
                mHandler.sendMessage(msg);
            }
            final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0;
            if (isDensityChange) {
                // Reset the unsupported display size dialog.
                mUiHandler.sendEmptyMessage(SHOW_UNSUPPORTED_DISPLAY_SIZE_DIALOG_MSG);
                killAllBackgroundProcessesExcept(Build.VERSION_CODES.N, ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE);
            }
            for (int i = mLruProcesses.size() - 1; i >= 0; i--) {
                ProcessRecord app = mLruProcesses.get(i);
                try {
                    if (app.thread != null) {
                        if (DEBUG_CONFIGURATION)
                            Slog.v(TAG_CONFIGURATION, "Sending to proc " + app.processName + " new config " + mConfiguration);
                        app.thread.scheduleConfigurationChanged(configCopy);
                    }
                } catch (Exception e) {
                }
            }
            Intent intent = new Intent(Intent.ACTION_CONFIGURATION_CHANGED);
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_FOREGROUND);
            broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
            if ((changes & ActivityInfo.CONFIG_LOCALE) != 0) {
                intent = new Intent(Intent.ACTION_LOCALE_CHANGED);
                intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                if (initLocale || !mProcessesReady) {
                    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
                }
                broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
            }
        }
        // ensureActivityConfigurationLocked().
        if (mWindowManager != null) {
            final int[] resizedStacks = mWindowManager.setNewConfiguration(mConfiguration);
            if (resizedStacks != null) {
                for (int stackId : resizedStacks) {
                    final Rect newBounds = mWindowManager.getBoundsForNewConfiguration(stackId);
                    mStackSupervisor.resizeStackLocked(stackId, newBounds, null, null, false, false, deferResume);
                }
            }
        }
    }
    boolean kept = true;
    final ActivityStack mainStack = mStackSupervisor.getFocusedStack();
    // mainStack is null during startup.
    if (mainStack != null) {
        if (changes != 0 && starting == null) {
            // If the configuration changed, and the caller is not already
            // in the process of starting an activity, then find the top
            // activity to check if its configuration needs to change.
            starting = mainStack.topRunningActivityLocked();
        }
        if (starting != null) {
            kept = mainStack.ensureActivityConfigurationLocked(starting, changes, false);
            // And we need to make sure at this point that all other activities
            // are made visible with the correct configuration.
            mStackSupervisor.ensureActivitiesVisibleLocked(starting, changes, !PRESERVE_WINDOWS);
        }
    }
    if (mWindowManager != null) {
        mWindowManager.continueSurfaceLayout();
    }
    return kept;
}
Also used : LocaleList(android.os.LocaleList) Rect(android.graphics.Rect) Configuration(android.content.res.Configuration) Message(android.os.Message) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) AttributeCache(com.android.server.AttributeCache) Point(android.graphics.Point) RemoteException(android.os.RemoteException) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) ActivityNotFoundException(android.content.ActivityNotFoundException) TransactionTooLargeException(android.os.TransactionTooLargeException) InstallerException(com.android.server.pm.Installer.InstallerException) FileNotFoundException(java.io.FileNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 57 with Point

use of android.graphics.Point in project PocketHub by pockethub.

the class ImageUtils method getSize.

/**
     * Get size of image
     *
     * @param image
     * @return size
     */
public static Point getSize(final byte[] image) {
    final Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeByteArray(image, 0, image.length, options);
    return new Point(options.outWidth, options.outHeight);
}
Also used : Options(android.graphics.BitmapFactory.Options) Point(android.graphics.Point)

Example 58 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class TaskRecord method setLastThumbnailLocked.

/**
     * Sets the last thumbnail with the current task bounds and the system orientation.
     * @return whether the thumbnail was set
     */
boolean setLastThumbnailLocked(Bitmap thumbnail) {
    final Configuration serviceConfig = mService.mConfiguration;
    int taskWidth = 0;
    int taskHeight = 0;
    if (mBounds != null) {
        // Non-fullscreen tasks
        taskWidth = mBounds.width();
        taskHeight = mBounds.height();
    } else if (stack != null) {
        // Fullscreen tasks
        final Point displaySize = new Point();
        stack.getDisplaySize(displaySize);
        taskWidth = displaySize.x;
        taskHeight = displaySize.y;
    } else {
        Slog.e(TAG, "setLastThumbnailLocked() called on Task without stack");
    }
    return setLastThumbnailLocked(thumbnail, taskWidth, taskHeight, serviceConfig.orientation);
}
Also used : Configuration(android.content.res.Configuration) Point(android.graphics.Point) Point(android.graphics.Point)

Example 59 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class TouchUtils method dragQuarterScreenUp.

/**
     * Simulate touching in the center of the screen and dragging one quarter of the way up
     * @param test The test case that is being run
     * @param activity The activity that is in the foreground of the test case
     */
public static void dragQuarterScreenUp(InstrumentationTestCase test, Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    final Point size = new Point();
    display.getSize(size);
    final float x = size.x / 2.0f;
    final float fromY = size.y * 0.5f;
    final float toY = size.y * 0.25f;
    drag(test, x, x, fromY, toY, 4);
}
Also used : Point(android.graphics.Point) Display(android.view.Display)

Example 60 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class DragState method notifyLocationLw.

void notifyLocationLw(float x, float y) {
    // Tell the affected window
    WindowState touchedWin = mDisplayContent.getTouchableWinAtPointLocked(x, y);
    if (touchedWin != null && !isWindowNotified(touchedWin)) {
        // The drag point is over a window which was not notified about a drag start.
        // Pretend it's over empty space.
        touchedWin = null;
    }
    try {
        final int myPid = Process.myPid();
        // have we dragged over a new window?
        if ((touchedWin != mTargetWindow) && (mTargetWindow != null)) {
            if (DEBUG_DRAG) {
                Slog.d(TAG_WM, "sending DRAG_EXITED to " + mTargetWindow);
            }
            // force DRAG_EXITED_EVENT if appropriate
            DragEvent evt = obtainDragEvent(mTargetWindow, DragEvent.ACTION_DRAG_EXITED, 0, 0, null, null, null, null, false);
            mTargetWindow.mClient.dispatchDragEvent(evt);
            if (myPid != mTargetWindow.mSession.mPid) {
                evt.recycle();
            }
        }
        if (touchedWin != null) {
            if (false && DEBUG_DRAG) {
                Slog.d(TAG_WM, "sending DRAG_LOCATION to " + touchedWin);
            }
            DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DRAG_LOCATION, x, y, null, null, null, null, false);
            touchedWin.mClient.dispatchDragEvent(evt);
            if (myPid != touchedWin.mSession.mPid) {
                evt.recycle();
            }
        }
    } catch (RemoteException e) {
        Slog.w(TAG_WM, "can't send drag notification to windows");
    }
    mTargetWindow = touchedWin;
}
Also used : DragEvent(android.view.DragEvent) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)1151 Display (android.view.Display)217 Rect (android.graphics.Rect)194 Paint (android.graphics.Paint)170 WindowManager (android.view.WindowManager)138 RemoteException (android.os.RemoteException)76 RectF (android.graphics.RectF)62 Bitmap (android.graphics.Bitmap)54 Resources (android.content.res.Resources)41 View (android.view.View)41 ArrayList (java.util.ArrayList)40 ImageView (android.widget.ImageView)37 Camera (android.hardware.Camera)36 Canvas (android.graphics.Canvas)31 Matrix (android.graphics.Matrix)29 Animator (android.animation.Animator)27 SuppressLint (android.annotation.SuppressLint)27 Configuration (android.content.res.Configuration)26 IOException (java.io.IOException)24 Message (android.os.Message)22