Search in sources :

Example 86 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by AOSPA.

the class ExifInterface method getTagDefinitionForTag.

protected int getTagDefinitionForTag(short tagId, short type, int count, int ifd) {
    int[] defs = getTagDefinitionsForTagId(tagId);
    if (defs == null) {
        return TAG_NULL;
    }
    SparseIntArray infos = getTagInfo();
    int ret = TAG_NULL;
    for (int i : defs) {
        int info = infos.get(i);
        short def_type = getTypeFromInfo(info);
        int def_count = getComponentCountFromInfo(info);
        int[] def_ifds = getAllowedIfdsFromInfo(info);
        boolean valid_ifd = false;
        for (int j : def_ifds) {
            if (j == ifd) {
                valid_ifd = true;
                break;
            }
        }
        if (valid_ifd && type == def_type && (count == def_count || def_count == ExifTag.SIZE_UNDEFINED)) {
            ret = i;
            break;
        }
    }
    return ret;
}
Also used : SparseIntArray(android.util.SparseIntArray)

Example 87 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by AOSPA.

the class AppOpsService method writeState.

void writeState() {
    synchronized (mFile) {
        List<AppOpsManager.PackageOps> allOps = getPackagesForOps(null);
        FileOutputStream stream;
        try {
            stream = mFile.startWrite();
        } catch (IOException e) {
            Slog.w(TAG, "Failed to write state: " + e);
            return;
        }
        try {
            XmlSerializer out = new FastXmlSerializer();
            out.setOutput(stream, StandardCharsets.UTF_8.name());
            out.startDocument(null, true);
            out.startTag(null, "app-ops");
            final int uidStateCount = mUidStates.size();
            for (int i = 0; i < uidStateCount; i++) {
                UidState uidState = mUidStates.valueAt(i);
                if (uidState.opModes != null && uidState.opModes.size() > 0) {
                    out.startTag(null, "uid");
                    out.attribute(null, "n", Integer.toString(uidState.uid));
                    SparseIntArray uidOpModes = uidState.opModes;
                    final int opCount = uidOpModes.size();
                    for (int j = 0; j < opCount; j++) {
                        final int op = uidOpModes.keyAt(j);
                        final int mode = uidOpModes.valueAt(j);
                        out.startTag(null, "op");
                        out.attribute(null, "n", Integer.toString(op));
                        out.attribute(null, "m", Integer.toString(mode));
                        out.endTag(null, "op");
                    }
                    out.endTag(null, "uid");
                }
            }
            if (allOps != null) {
                String lastPkg = null;
                for (int i = 0; i < allOps.size(); i++) {
                    AppOpsManager.PackageOps pkg = allOps.get(i);
                    if (!pkg.getPackageName().equals(lastPkg)) {
                        if (lastPkg != null) {
                            out.endTag(null, "pkg");
                        }
                        lastPkg = pkg.getPackageName();
                        out.startTag(null, "pkg");
                        out.attribute(null, "n", lastPkg);
                    }
                    out.startTag(null, "uid");
                    out.attribute(null, "n", Integer.toString(pkg.getUid()));
                    synchronized (this) {
                        Ops ops = getOpsRawLocked(pkg.getUid(), pkg.getPackageName(), false);
                        // from Ops.
                        if (ops != null) {
                            out.attribute(null, "p", Boolean.toString(ops.isPrivileged));
                        } else {
                            out.attribute(null, "p", Boolean.toString(false));
                        }
                    }
                    List<AppOpsManager.OpEntry> ops = pkg.getOps();
                    for (int j = 0; j < ops.size(); j++) {
                        AppOpsManager.OpEntry op = ops.get(j);
                        out.startTag(null, "op");
                        out.attribute(null, "n", Integer.toString(op.getOp()));
                        if (op.getMode() != AppOpsManager.opToDefaultMode(op.getOp())) {
                            out.attribute(null, "m", Integer.toString(op.getMode()));
                        }
                        long time = op.getTime();
                        if (time != 0) {
                            out.attribute(null, "t", Long.toString(time));
                        }
                        time = op.getRejectTime();
                        if (time != 0) {
                            out.attribute(null, "r", Long.toString(time));
                        }
                        int dur = op.getDuration();
                        if (dur != 0) {
                            out.attribute(null, "d", Integer.toString(dur));
                        }
                        int proxyUid = op.getProxyUid();
                        if (proxyUid != -1) {
                            out.attribute(null, "pu", Integer.toString(proxyUid));
                        }
                        String proxyPackageName = op.getProxyPackageName();
                        if (proxyPackageName != null) {
                            out.attribute(null, "pp", proxyPackageName);
                        }
                        out.endTag(null, "op");
                    }
                    out.endTag(null, "uid");
                }
                if (lastPkg != null) {
                    out.endTag(null, "pkg");
                }
            }
            out.endTag(null, "app-ops");
            out.endDocument();
            mFile.finishWrite(stream);
        } catch (IOException e) {
            Slog.w(TAG, "Failed to write state, restoring backup.", e);
            mFile.failWrite(stream);
        }
    }
}
Also used : IOException(java.io.IOException) AppOpsManager(android.app.AppOpsManager) FastXmlSerializer(com.android.internal.util.FastXmlSerializer) SparseIntArray(android.util.SparseIntArray) FileOutputStream(java.io.FileOutputStream) XmlSerializer(org.xmlpull.v1.XmlSerializer) FastXmlSerializer(com.android.internal.util.FastXmlSerializer)

Example 88 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by AOSPA.

the class ActivityThread method reportSizeConfigurations.

private void reportSizeConfigurations(ActivityClientRecord r) {
    Configuration[] configurations = r.activity.getResources().getSizeConfigurations();
    if (configurations == null) {
        return;
    }
    SparseIntArray horizontal = new SparseIntArray();
    SparseIntArray vertical = new SparseIntArray();
    SparseIntArray smallest = new SparseIntArray();
    for (int i = configurations.length - 1; i >= 0; i--) {
        Configuration config = configurations[i];
        if (config.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
            vertical.put(config.screenHeightDp, 0);
        }
        if (config.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
            horizontal.put(config.screenWidthDp, 0);
        }
        if (config.smallestScreenWidthDp != Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
            smallest.put(config.smallestScreenWidthDp, 0);
        }
    }
    try {
        ActivityManagerNative.getDefault().reportSizeConfigurations(r.token, horizontal.copyKeys(), vertical.copyKeys(), smallest.copyKeys());
    } catch (RemoteException ex) {
        throw ex.rethrowFromSystemServer();
    }
}
Also used : Configuration(android.content.res.Configuration) SparseIntArray(android.util.SparseIntArray) RemoteException(android.os.RemoteException)

Example 89 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by AOSPA.

the class StreamConfigurationMap method getInternalFormatSizes.

private Size[] getInternalFormatSizes(int format, int dataspace, boolean output, boolean highRes) {
    // All depth formats are non-high-res.
    if (dataspace == HAL_DATASPACE_DEPTH && highRes) {
        return new Size[0];
    }
    SparseIntArray formatsMap = !output ? mInputFormats : dataspace == HAL_DATASPACE_DEPTH ? mDepthOutputFormats : highRes ? mHighResOutputFormats : mOutputFormats;
    int sizesCount = formatsMap.get(format);
    if (((!output || dataspace == HAL_DATASPACE_DEPTH) && sizesCount == 0) || (output && dataspace != HAL_DATASPACE_DEPTH && mAllOutputFormats.get(format) == 0)) {
        // Only throw if this is really not supported at all
        throw new IllegalArgumentException("format not available");
    }
    Size[] sizes = new Size[sizesCount];
    int sizeIndex = 0;
    StreamConfiguration[] configurations = (dataspace == HAL_DATASPACE_DEPTH) ? mDepthConfigurations : mConfigurations;
    StreamConfigurationDuration[] minFrameDurations = (dataspace == HAL_DATASPACE_DEPTH) ? mDepthMinFrameDurations : mMinFrameDurations;
    for (StreamConfiguration config : configurations) {
        int fmt = config.getFormat();
        if (fmt == format && config.isOutput() == output) {
            if (output && mListHighResolution) {
                // Filter slow high-res output formats; include for
                // highRes, remove for !highRes
                long duration = 0;
                for (int i = 0; i < minFrameDurations.length; i++) {
                    StreamConfigurationDuration d = minFrameDurations[i];
                    if (d.getFormat() == fmt && d.getWidth() == config.getSize().getWidth() && d.getHeight() == config.getSize().getHeight()) {
                        duration = d.getDuration();
                        break;
                    }
                }
                if (dataspace != HAL_DATASPACE_DEPTH && highRes != (duration > DURATION_20FPS_NS)) {
                    continue;
                }
            }
            sizes[sizeIndex++] = config.getSize();
        }
    }
    if (sizeIndex != sizesCount) {
        throw new AssertionError("Too few sizes (expected " + sizesCount + ", actual " + sizeIndex + ")");
    }
    return sizes;
}
Also used : SparseIntArray(android.util.SparseIntArray) Size(android.util.Size)

Example 90 with SparseIntArray

use of android.util.SparseIntArray in project android_frameworks_base by AOSPA.

the class RecentsTaskLoadPlan method preloadPlan.

/**
     * Preloads the list of recent tasks from the system. After this call, the TaskStack will
     * have a list of all the recent tasks with their metadata, not including icons or
     * thumbnails which were not cached and have to be loaded.
     *
     * The tasks will be ordered by:
     * - least-recent to most-recent stack tasks
     * - least-recent to most-recent freeform tasks
     */
public synchronized void preloadPlan(RecentsTaskLoader loader, int runningTaskId, boolean includeFrontMostExcludedTask) {
    Resources res = mContext.getResources();
    ArrayList<Task> allTasks = new ArrayList<>();
    if (mRawTasks == null) {
        preloadRawTasks(includeFrontMostExcludedTask);
    }
    SystemServicesProxy ssp = SystemServicesProxy.getInstance(mContext);
    SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>();
    SparseIntArray affiliatedTaskCounts = new SparseIntArray();
    String dismissDescFormat = mContext.getString(R.string.accessibility_recents_item_will_be_dismissed);
    String appInfoDescFormat = mContext.getString(R.string.accessibility_recents_item_open_app_info);
    int currentUserId = ssp.getCurrentUser();
    long legacyLastStackActiveTime = migrateLegacyLastStackActiveTime(currentUserId);
    long lastStackActiveTime = Settings.Secure.getLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, legacyLastStackActiveTime, currentUserId);
    if (RecentsDebugFlags.Static.EnableMockTasks) {
        lastStackActiveTime = 0;
    }
    long newLastStackActiveTime = -1;
    int taskCount = mRawTasks.size();
    for (int i = 0; i < taskCount; i++) {
        ActivityManager.RecentTaskInfo t = mRawTasks.get(i);
        // Compose the task key
        Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent, t.userId, t.firstActiveTime, t.lastActiveTime);
        // This task is only shown in the stack if it satisfies the historical time or min
        // number of tasks constraints. Freeform tasks are also always shown.
        boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
        boolean isStackTask;
        if (Recents.getConfiguration().isGridEnabled) {
            // When grid layout is enabled, we only show the first
            // TaskGridLayoutAlgorithm.MAX_LAYOUT_TASK_COUNT} tasks.
            isStackTask = t.lastActiveTime >= lastStackActiveTime && i >= taskCount - TaskGridLayoutAlgorithm.MAX_LAYOUT_TASK_COUNT;
        } else {
            isStackTask = isFreeformTask || !isHistoricalTask(t) || (t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS));
        }
        boolean isLaunchTarget = taskKey.id == runningTaskId;
        // the other stack-task constraints.
        if (isStackTask && newLastStackActiveTime < 0) {
            newLastStackActiveTime = t.lastActiveTime;
        }
        // Load the title, icon, and color
        ActivityInfo info = loader.getAndUpdateActivityInfo(taskKey);
        String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription);
        String titleDescription = loader.getAndUpdateContentDescription(taskKey, res);
        String dismissDescription = String.format(dismissDescFormat, titleDescription);
        String appInfoDescription = String.format(appInfoDescFormat, titleDescription);
        Drawable icon = isStackTask ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false) : null;
        Bitmap thumbnail = loader.getAndUpdateThumbnail(taskKey, false);
        int activityColor = loader.getActivityPrimaryColor(t.taskDescription);
        int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription);
        boolean isSystemApp = (info != null) && ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
        // Add the task to the stack
        Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon, thumbnail, title, titleDescription, dismissDescription, appInfoDescription, activityColor, backgroundColor, isLaunchTarget, isStackTask, isSystemApp, t.isDockable, t.bounds, t.taskDescription, t.resizeMode, t.topActivity);
        allTasks.add(task);
        affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
        affiliatedTasks.put(taskKey.id, taskKey);
    }
    if (newLastStackActiveTime != -1) {
        Settings.Secure.putLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, newLastStackActiveTime, currentUserId);
    }
    // Initialize the stacks
    mStack = new TaskStack();
    mStack.setTasks(mContext, allTasks, false);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) ActivityManager(android.app.ActivityManager) SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) SparseArray(android.util.SparseArray) Bitmap(android.graphics.Bitmap) SparseIntArray(android.util.SparseIntArray) Resources(android.content.res.Resources)

Aggregations

SparseIntArray (android.util.SparseIntArray)249 RemoteException (android.os.RemoteException)40 ArrayList (java.util.ArrayList)28 HashMap (java.util.HashMap)20 IAppOpsCallback (com.android.internal.app.IAppOpsCallback)15 IOException (java.io.IOException)12 Point (android.graphics.Point)11 SparseArray (android.util.SparseArray)11 UserInfo (android.content.pm.UserInfo)10 ArraySet (android.util.ArraySet)10 Map (java.util.Map)10 HashSet (java.util.HashSet)9 Cursor (android.database.Cursor)8 View (android.view.View)7 SparseBooleanArray (android.util.SparseBooleanArray)6 ActivityManager (android.app.ActivityManager)5 Context (android.content.Context)5 ActivityInfo (android.content.pm.ActivityInfo)5 Configuration (android.content.res.Configuration)5 Resources (android.content.res.Resources)5