android.util.ArrayMap Java Examples

The following examples show how to use android.util.ArrayMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OC_2dShapes_S2f.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public void prepare()
{
    setStatus(STATUS_BUSY);
    super.prepare();
    loadFingers();
    loadEvent("master2");
    this.localisations = loadLocalisations(getLocalPath("_localisations.xml"));
    textColour = OBUtils.colorFromRGBString(eventAttributes.get("colour_text"));
    dropObjs = new ArrayMap<>();
    events = Arrays.asList(eventAttributes.get("scenes").split(","));
    OBPath box = (OBPath)objectDict.get("box");

    box.setProperty("start_loc", OBMisc.copyPoint(box.position()));
    OBPath dot = (OBPath)objectDict.get("dot");
    dot.sizeToBoundingBoxInset(-applyGraphicScale(2));
    setSceneXX(currentEvent());
    box.sizeToBoundingBoxIncludingStroke();
}
 
Example #2
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
Example #3
Source File: UsageStatsManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * A convenience method that queries for all stats in the given range (using the best interval
 * for that range), merges the resulting data, and keys it by package name.
 * See {@link #queryUsageStats(int, long, long)}.
 * <p> The caller must have {@link android.Manifest.permission#PACKAGE_USAGE_STATS} </p>
 *
 * @param beginTime The inclusive beginning of the range of stats to include in the results.
 * @param endTime The exclusive end of the range of stats to include in the results.
 * @return A {@link java.util.Map} keyed by package name
 */
public Map<String, UsageStats> queryAndAggregateUsageStats(long beginTime, long endTime) {
    List<UsageStats> stats = queryUsageStats(INTERVAL_BEST, beginTime, endTime);
    if (stats.isEmpty()) {
        return Collections.emptyMap();
    }

    ArrayMap<String, UsageStats> aggregatedStats = new ArrayMap<>();
    final int statCount = stats.size();
    for (int i = 0; i < statCount; i++) {
        UsageStats newStat = stats.get(i);
        UsageStats existingStat = aggregatedStats.get(newStat.getPackageName());
        if (existingStat == null) {
            aggregatedStats.put(newStat.mPackageName, newStat);
        } else {
            existingStat.add(newStat);
        }
    }
    return aggregatedStats;
}
 
Example #4
Source File: Parcel.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void readArrayMapSafelyInternal(ArrayMap outVal, int N,
    ClassLoader loader) {
    if (DEBUG_ARRAY_MAP) {
        RuntimeException here =  new RuntimeException("here");
        here.fillInStackTrace();
        Log.d(TAG, "Reading safely " + N + " ArrayMap entries", here);
    }
    while (N > 0) {
        String key = readString();
        if (DEBUG_ARRAY_MAP) Log.d(TAG, "  Read safe #" + (N-1) + ": key=0x"
                + (key != null ? key.hashCode() : 0) + " " + key);
        Object value = readValue(loader);
        outVal.put(key, value);
        N--;
    }
}
 
Example #5
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
    // At least one application in the world actually passes in a null
    // name.  This happened to work because when we generated the file name
    // we would stringify it to "null.xml".  Nice.
    if (mPackageInfo.getApplicationInfo().targetSdkVersion <
            Build.VERSION_CODES.KITKAT) {
        if (name == null) {
            name = "null";
        }
    }

    File file;
    synchronized (ContextImpl.class) {
        if (mSharedPrefsPaths == null) {
            mSharedPrefsPaths = new ArrayMap<>();
        }
        file = mSharedPrefsPaths.get(name);
        if (file == null) {
            file = getSharedPreferencesPath(name);
            mSharedPrefsPaths.put(name, file);
        }
    }
    return getSharedPreferences(file, mode);
}
 
Example #6
Source File: FileUpdater.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Write values to files. (Note the actual writes happen ASAP but asynchronously.)
 */
public void writeFiles(ArrayMap<String, String> fileValues) {
    synchronized (mLock) {
        for (int i = fileValues.size() - 1; i >= 0; i--) {
            final String file = fileValues.keyAt(i);
            final String value = fileValues.valueAt(i);

            if (DEBUG) {
                Slog.d(TAG, "Scheduling write: '" + value + "' to '" + file + "'");
            }

            mPendingWrites.put(file, value);

        }
        mRetries = 0;

        mHandler.removeCallbacks(mHandleWriteOnHandlerRunnable);
        mHandler.post(mHandleWriteOnHandlerRunnable);
    }
}
 
Example #7
Source File: OC_Pws.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public void prepare()
{
    setStatus(STATUS_BUSY);
    super.prepare();
    loadFingers();
    loadEvent("master");
    showDemo = OBUtils.getBooleanValue(parameters.get("demo"));
    eventColours = new ArrayMap<>();
    eventColours = OBMisc.loadEventColours(this);
    componentDict = OBUtils.LoadWordComponentsXML(true);
    loadEvent(eventName());
    eventColours.putAll(OBMisc.loadEventColours(this));
    wordBag = new OC_WordBag((OBGroup)objectDict.get("word_bag"),this);
    setSceneXX(currentEvent());

    animateWobble = false;
    boxTouchMode = true;
    currentMode = MODE_BAG;
}
 
Example #8
Source File: AccessibilityManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Notifies the registered {@link HighTextContrastChangeListener}s.
 */
private void notifyHighTextContrastStateChanged() {
    final boolean isHighTextContrastEnabled;
    final ArrayMap<HighTextContrastChangeListener, Handler> listeners;
    synchronized (mLock) {
        if (mHighTextContrastStateChangeListeners.isEmpty()) {
            return;
        }
        isHighTextContrastEnabled = mIsHighTextContrastEnabled;
        listeners = new ArrayMap<>(mHighTextContrastStateChangeListeners);
    }

    final int numListeners = listeners.size();
    for (int i = 0; i < numListeners; i++) {
        final HighTextContrastChangeListener listener = listeners.keyAt(i);
        listeners.valueAt(i).post(() ->
                listener.onHighTextContrastStateChanged(isHighTextContrastEnabled));
    }
}
 
Example #9
Source File: ScrollingHelper.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public static void prepareForScrollMeasureTickValue(OBControl con, float tickValue,double decay,float minSpeedX, float minSpeedY)
{
    Object data = con.propertyValue("scrolling_data");
    Map<String,Object> scrollingData;
    if(data == null)
        scrollingData = new ArrayMap<String,Object>();
    else
        scrollingData = (ArrayMap<String,Object>)data;

    scrollingData.put("last_action",SystemClock.uptimeMillis());
    scrollingData.put("last_loc",OBMisc.copyPoint(con.position()));
    scrollingData.put("speed_x",0.0f);
    scrollingData.put("speed_y",0.0f);
    scrollingData.put("min_speed_x",minSpeedX);
    scrollingData.put("min_speed_y",minSpeedY);
    scrollingData.put("decay",decay);
    scrollingData.put("tick",tickValue);
    con.setProperty("scrolling_data", scrollingData);
}
 
Example #10
Source File: EnterTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void triggerViewsReady(final ArrayMap<String, View> sharedElements) {
    if (mAreViewsReady) {
        return;
    }
    mAreViewsReady = true;
    final ViewGroup decor = getDecor();
    // Ensure the views have been laid out before capturing the views -- we need the epicenter.
    if (decor == null || (decor.isAttachedToWindow() &&
            (sharedElements.isEmpty() || !sharedElements.valueAt(0).isLayoutRequested()))) {
        viewsReady(sharedElements);
    } else {
        mViewsReadyListener = OneShotPreDrawListener.add(decor, () -> {
            mViewsReadyListener = null;
            viewsReady(sharedElements);
        });
        decor.invalidate();
    }
}
 
Example #11
Source File: IntentResolver.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private final void addFilter(ArrayMap<String, F[]> map, String name, F filter) {
    F[] array = map.get(name);
    if (array == null) {
        array = newArray(2);
        map.put(name,  array);
        array[0] = filter;
    } else {
        final int N = array.length;
        int i = N;
        while (i > 0 && array[i-1] == null) {
            i--;
        }
        if (i < N) {
            array[i] = filter;
        } else {
            F[] newa = newArray((N*3)/2);
            System.arraycopy(array, 0, newa, 0, N);
            newa[N] = filter;
            map.put(name, newa);
        }
    }
}
 
Example #12
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
    synchronized (ContextImpl.class) {
        final File source = sourceContext.getSharedPreferencesPath(name);
        final File target = getSharedPreferencesPath(name);

        final int res = moveFiles(source.getParentFile(), target.getParentFile(),
                source.getName());
        if (res > 0) {
            // We moved at least one file, so evict any in-memory caches for
            // either location
            final ArrayMap<File, SharedPreferencesImpl> cache =
                    getSharedPreferencesCacheLocked();
            cache.remove(source);
            cache.remove(target);
        }
        return res != -1;
    }
}
 
Example #13
Source File: AccessibilityManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyServicesStateChanged() {
    final ArrayMap<AccessibilityServicesStateChangeListener, Handler> listeners;
    synchronized (mLock) {
        if (mServicesStateChangeListeners.isEmpty()) {
            return;
        }
        listeners = new ArrayMap<>(mServicesStateChangeListeners);
    }

    int numListeners = listeners.size();
    for (int i = 0; i < numListeners; i++) {
        final AccessibilityServicesStateChangeListener listener =
                mServicesStateChangeListeners.keyAt(i);
        mServicesStateChangeListeners.valueAt(i).post(() -> listener
                .onAccessibilityServicesStateChanged(AccessibilityManager.this));
    }
}
 
Example #14
Source File: ContentService.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@RequiresPermission(android.Manifest.permission.CACHE_CONTENT)
public Bundle getCache(String packageName, Uri key, int userId) {
    enforceCrossUserPermission(userId, TAG);
    mContext.enforceCallingOrSelfPermission(android.Manifest.permission.CACHE_CONTENT, TAG);
    mContext.getSystemService(AppOpsManager.class).checkPackage(Binder.getCallingUid(),
            packageName);

    final String providerPackageName = getProviderPackageName(key);
    final Pair<String, Uri> fullKey = Pair.create(packageName, key);

    synchronized (mCache) {
        final ArrayMap<Pair<String, Uri>, Bundle> cache = findOrCreateCacheLocked(userId,
                providerPackageName);
        return cache.get(fullKey);
    }
}
 
Example #15
Source File: AccessibilityManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Notifies the registered {@link AccessibilityStateChangeListener}s.
 */
private void notifyAccessibilityStateChanged() {
    final boolean isEnabled;
    final ArrayMap<AccessibilityStateChangeListener, Handler> listeners;
    synchronized (mLock) {
        if (mAccessibilityStateChangeListeners.isEmpty()) {
            return;
        }
        isEnabled = isEnabled();
        listeners = new ArrayMap<>(mAccessibilityStateChangeListeners);
    }

    final int numListeners = listeners.size();
    for (int i = 0; i < numListeners; i++) {
        final AccessibilityStateChangeListener listener = listeners.keyAt(i);
        listeners.valueAt(i).post(() ->
                listener.onAccessibilityStateChanged(isEnabled));
    }
}
 
Example #16
Source File: SnoozeHelper.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void dump(PrintWriter pw, NotificationManagerService.DumpFilter filter) {
    pw.println("\n  Snoozed notifications:");
    for (int userId : mSnoozedNotifications.keySet()) {
        pw.print(INDENT);
        pw.println("user: " + userId);
        ArrayMap<String, ArrayMap<String, NotificationRecord>> snoozedPkgs =
                mSnoozedNotifications.get(userId);
        for (String pkg : snoozedPkgs.keySet()) {
            pw.print(INDENT);
            pw.print(INDENT);
            pw.println("package: " + pkg);
            Set<String> snoozedKeys = snoozedPkgs.get(pkg).keySet();
            for (String key : snoozedKeys) {
                pw.print(INDENT);
                pw.print(INDENT);
                pw.print(INDENT);
                pw.println(key);
            }
        }
    }
}
 
Example #17
Source File: ShortcutPackage.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Build a list of shortcuts for each target activity and return as a map. The result won't
 * contain "floating" shortcuts because they don't belong on any activities.
 */
private ArrayMap<ComponentName, ArrayList<ShortcutInfo>> sortShortcutsToActivities() {
    final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> activitiesToShortcuts
            = new ArrayMap<>();
    for (int i = mShortcuts.size() - 1; i >= 0; i--) {
        final ShortcutInfo si = mShortcuts.valueAt(i);
        if (si.isFloating()) {
            continue; // Ignore floating shortcuts, which are not tied to any activities.
        }

        final ComponentName activity = si.getActivity();
        if (activity == null) {
            mShortcutUser.mService.wtf("null activity detected.");
            continue;
        }

        ArrayList<ShortcutInfo> list = activitiesToShortcuts.get(activity);
        if (list == null) {
            list = new ArrayList<>();
            activitiesToShortcuts.put(activity, list);
        }
        list.add(si);
    }
    return activitiesToShortcuts;
}
 
Example #18
Source File: ScrollingHelper.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public static void measureScrollSpeed(OBControl con)
{
    Object data = con.propertyValue("scrolling_data");
    if(data == null)
        return;
    Map<String,Object> scrollingData = (ArrayMap<String,Object>)data;

    long currentTime = SystemClock.uptimeMillis();
    long lastTime = (long)scrollingData.get("last_action");
    if(currentTime == lastTime)
        return;
    float lastSpeedX = (float)scrollingData.get("speed_x");
    float lastSpeedY = (float)scrollingData.get("speed_y");
    float tick = (float)scrollingData.get("tick") ;
    PointF lastLoc = (PointF)scrollingData.get("last_loc");
    PointF currentLoc = OBMisc.copyPoint(con.position());
    float ticks =  (currentTime - lastTime)*1.0f/(1000.0f*tick);
    float speedX = 0.8f * ((currentLoc.x - lastLoc.x) / ticks) + 0.2f * lastSpeedX;
    float speedY = 0.8f * ((currentLoc.y - lastLoc.y) / ticks) + 0.2f * lastSpeedY;
    scrollingData.put("speed_x",speedX);
    scrollingData.put("speed_y", speedY);
    scrollingData.put("last_loc",currentLoc);
    scrollingData.put("last_action",currentTime);
}
 
Example #19
Source File: EnterTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private ArrayMap<String, View> mapNamedElements(ArrayList<String> accepted,
        ArrayList<String> localNames) {
    ArrayMap<String, View> sharedElements = new ArrayMap<String, View>();
    ViewGroup decorView = getDecor();
    if (decorView != null) {
        decorView.findNamedViews(sharedElements);
    }
    if (accepted != null) {
        for (int i = 0; i < localNames.size(); i++) {
            String localName = localNames.get(i);
            String acceptedName = accepted.get(i);
            if (localName != null && !localName.equals(acceptedName)) {
                View view = sharedElements.get(localName);
                if (view != null) {
                    sharedElements.put(acceptedName, view);
                }
            }
        }
    }
    return sharedElements;
}
 
Example #20
Source File: FingerprintGestureController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Called when gesture detection becomes active or inactive
 * @hide
 */
public void onGestureDetectionActiveChanged(boolean active) {
    final ArrayMap<FingerprintGestureCallback, Handler> handlerMap;
    synchronized (mLock) {
        handlerMap = new ArrayMap<>(mCallbackHandlerMap);
    }
    int numListeners = handlerMap.size();
    for (int i = 0; i < numListeners; i++) {
        FingerprintGestureCallback callback = handlerMap.keyAt(i);
        Handler handler = handlerMap.valueAt(i);
        if (handler != null) {
            handler.post(() -> callback.onGestureDetectionAvailabilityChanged(active));
        } else {
            callback.onGestureDetectionAvailabilityChanged(active);
        }
    }
}
 
Example #21
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
    // At least one application in the world actually passes in a null
    // name.  This happened to work because when we generated the file name
    // we would stringify it to "null.xml".  Nice.
    if (mPackageInfo.getApplicationInfo().targetSdkVersion <
            Build.VERSION_CODES.KITKAT) {
        if (name == null) {
            name = "null";
        }
    }

    File file;
    synchronized (ContextImpl.class) {
        if (mSharedPrefsPaths == null) {
            mSharedPrefsPaths = new ArrayMap<>();
        }
        file = mSharedPrefsPaths.get(name);
        if (file == null) {
            file = getSharedPreferencesPath(name);
            mSharedPrefsPaths.put(name, file);
        }
    }
    return getSharedPreferences(file, mode);
}
 
Example #22
Source File: FragmentTransition.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the epicenter for the exit transition.
 *
 * @param sharedElementTransition The shared element transition
 * @param exitTransition The transition for the outgoing fragment's views
 * @param outSharedElements Shared elements in the outgoing fragment
 * @param outIsPop Is the outgoing fragment being removed as a pop transaction?
 * @param outTransaction The transaction that caused the fragment to be removed.
 */
private static void setOutEpicenter(TransitionSet sharedElementTransition,
        Transition exitTransition, ArrayMap<String, View> outSharedElements, boolean outIsPop,
        BackStackRecord outTransaction) {
    if (outTransaction.mSharedElementSourceNames != null &&
            !outTransaction.mSharedElementSourceNames.isEmpty()) {
        final String sourceName = outIsPop
                ? outTransaction.mSharedElementTargetNames.get(0)
                : outTransaction.mSharedElementSourceNames.get(0);
        final View outEpicenterView = outSharedElements.get(sourceName);
        setEpicenter(sharedElementTransition, outEpicenterView);

        if (exitTransition != null) {
            setEpicenter(exitTransition, outEpicenterView);
        }
    }
}
 
Example #23
Source File: ScrollingHelper.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public static PointF nextScrollingLocationByFrac(OBControl con, float frac, MutableBoolean finished)
{
    PointF loc = OBMisc.copyPoint(con.position());
    Object data = con.propertyValue("scrolling_data");
    if(data == null)
    {
        finished.value = true;
        return loc;
    }
    Map<String,Object> scrollingData = (ArrayMap<String,Object>)data;
    float speedX = (float)scrollingData.get("speed_x");
    float speedY = (float)scrollingData.get("speed_y");
    float minSpeedX = (float)scrollingData.get("min_speed_x");
    float minSpeedY = (float)scrollingData.get("min_speed_y");
    if(speedX == 0 && speedY == 0)
    {
        finished.value = true;
        return loc;
    }
    loc.x += speedX * frac;
    loc.y += speedY * frac;
    double decay = (double)scrollingData.get("decay");
    double decayFrac = Math.pow(decay,frac);
    speedX *= decayFrac;
    speedY *= decayFrac;
    if(minSpeedX >= Math.abs(speedX))
        speedX = 0;
    if(minSpeedY >= Math.abs(speedY))
        speedY = 0;
    scrollingData.put("speed_x", speedX);
    scrollingData.put("speed_y", speedY);
    finished.value = speedX == 0 && speedY == 0;
    return loc;
}
 
Example #24
Source File: ProxyUtils.java    From AndroidHttpCapture with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean setProxyLollipop(final Context context, String host, int port) {
    System.setProperty("http.proxyHost", host);
    System.setProperty("http.proxyPort", port + "");
    System.setProperty("https.proxyHost", host);
    System.setProperty("https.proxyPort", port + "");
    try {
        Context appContext = context.getApplicationContext();
        Class applictionClass = Class.forName("android.app.Application");
        Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk");
        mLoadedApkField.setAccessible(true);
        Object mloadedApk = mLoadedApkField.get(appContext);
        Class loadedApkClass = Class.forName("android.app.LoadedApk");
        Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers");
        mReceiversField.setAccessible(true);
        ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk);
        for (Object receiverMap : receivers.values()) {
            for (Object receiver : ((ArrayMap) receiverMap).keySet()) {
                Class clazz = receiver.getClass();
                if (clazz.getName().contains("ProxyChangeListener")) {
                    Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
                    Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
                    onReceiveMethod.invoke(receiver, appContext, intent);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
 
Example #25
Source File: OCM_MlUnitInstance.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public boolean updateDataInDB(DBSQL db)
{
    Map<String,String> whereMap = new ArrayMap<>();
    whereMap.put("userid",String.valueOf(userid));
    whereMap.put("unitid",String.valueOf(mlUnit.unitid));
    whereMap.put("seqNo",String.valueOf(seqNo));
    whereMap.put("sessionid",String.valueOf(sessionid));
    whereMap.put("typeid",String.valueOf(typeid));
    whereMap.put("extraunitid",String.valueOf(mlUnit.extraunitid));

    ContentValues contentValues = new ContentValues();
    contentValues.put("endTime",endTime);
    contentValues.put("scoreCorrect",scoreCorrect);
    contentValues.put("scoreWrong",scoreWrong);
    contentValues.put("elapsedTime",elapsedTime);
    contentValues.put("starColour",starColour);
    contentValues.put("statusid",statusid);
    contentValues.put("assetid",assetid);
    if(extraData.size() > 0)
    {
        try
        {
            Gson gson = new GsonBuilder().disableHtmlEscaping().create();
            contentValues.put("extra", gson.toJson(extraData));
        }
        catch (Exception e)
        {
            MainActivity.log("OCM_MlUnitInstance: error converting data to json: " + e.getMessage());
        }
    }
    boolean result = db.doUpdateOnTable(DBSQL.TABLE_UNIT_INSTANCES,whereMap,contentValues) > 0;
    return result;
}
 
Example #26
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(File file, int mode) {
    SharedPreferencesImpl sp;
    synchronized (ContextImpl.class) {
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        sp = cache.get(file);
        if (sp == null) {
            checkMode(mode);
            if (getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.O) {
                if (isCredentialProtectedStorage()
                        && !getSystemService(UserManager.class)
                                .isUserUnlockingOrUnlocked(UserHandle.myUserId())) {
                    throw new IllegalStateException("SharedPreferences in credential encrypted "
                            + "storage are not available until after user is unlocked");
                }
            }
            sp = new SharedPreferencesImpl(file, mode);
            cache.put(file, sp);
            return sp;
        }
    }
    if ((mode & Context.MODE_MULTI_PROCESS) != 0 ||
        getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
        // If somebody else (some other process) changed the prefs
        // file behind our back, we reload it.  This has been the
        // historical (if undocumented) behavior.
        sp.startReloadIfChangedUnexpectedly();
    }
    return sp;
}
 
Example #27
Source File: Transition.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Match start/end values by View instance. Adds matched values to mStartValuesList
 * and mEndValuesList and removes them from unmatchedStart and unmatchedEnd.
 */
private void matchInstances(ArrayMap<View, TransitionValues> unmatchedStart,
        ArrayMap<View, TransitionValues> unmatchedEnd) {
    for (int i = unmatchedStart.size() - 1; i >= 0; i--) {
        View view = unmatchedStart.keyAt(i);
        if (view != null && isValidTarget(view)) {
            TransitionValues end = unmatchedEnd.remove(view);
            if (end != null && end.view != null && isValidTarget(end.view)) {
                TransitionValues start = unmatchedStart.removeAt(i);
                mStartValuesList.add(start);
                mEndValuesList.add(end);
            }
        }
    }
}
 
Example #28
Source File: ManagedServices.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
protected List<String> getAllowedPackages(int userId) {
    final List<String> allowedPackages = new ArrayList<>();
    final ArrayMap<Boolean, ArraySet<String>> allowedByType =
            mApproved.getOrDefault(userId, new ArrayMap<>());
    for (int i = 0; i < allowedByType.size(); i++) {
        final ArraySet<String> allowed = allowedByType.valueAt(i);
        for (int j = 0; j < allowed.size(); j++) {
            String pkgName = getPackageName(allowed.valueAt(j));
            if (!TextUtils.isEmpty(pkgName)) {
                allowedPackages.add(pkgName);
            }
        }
    }
    return allowedPackages;
}
 
Example #29
Source File: OCM_MlUnit.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public static  OCM_MlUnit mlUnitforMasterlistIDFromDB(DBSQL db, int masterlistid, int unitIndex)
{
    OCM_MlUnit unit = null;
    Map<String,String> whereMap = new ArrayMap<>();
    whereMap.put("masterlistid",String.valueOf(masterlistid));
    whereMap.put("unitIndex",String.valueOf(unitIndex));
    Cursor cursor = db.doSelectOnTable(DBSQL.TABLE_UNITS,allFieldNames(stringFields,intFields,null,floatFields),whereMap);
    if(cursor.moveToFirst())
    {
        unit = mlUnitFromCursor(cursor);
    }
    cursor.close();
    return unit;
}
 
Example #30
Source File: ActivityTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
protected void viewsReady(ArrayMap<String, View> sharedElements) {
    sharedElements.retainAll(mAllSharedElementNames);
    if (mListener != null) {
        mListener.onMapSharedElements(mAllSharedElementNames, sharedElements);
    }
    setSharedElements(sharedElements);
    if (getViewsTransition() != null && mTransitioningViews != null) {
        ViewGroup decorView = getDecor();
        if (decorView != null) {
            decorView.captureTransitioningViews(mTransitioningViews);
        }
        mTransitioningViews.removeAll(mSharedElements);
    }
    setEpicenter();
}