Java Code Examples for android.util.ArrayMap#put()

The following examples show how to use android.util.ArrayMap#put() . 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: RecoverySession.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** Given a map from alias to grant alias, returns a map from alias to a {@link Key} handle. */
private @NonNull Map<String, Key> getKeysFromGrants(@NonNull Map<String, String> grantAliases)
        throws InternalRecoveryServiceException {
    ArrayMap<String, Key> keysByAlias = new ArrayMap<>(grantAliases.size());
    for (String alias : grantAliases.keySet()) {
        String grantAlias = grantAliases.get(alias);
        Key key;
        try {
            key = mRecoveryController.getKeyFromGrant(grantAlias);
        } catch (UnrecoverableKeyException e) {
            throw new InternalRecoveryServiceException(
                    String.format(
                            Locale.US,
                            "Failed to get key '%s' from grant '%s'",
                            alias,
                            grantAlias), e);
        }
        keysByAlias.put(alias, key);
    }
    return keysByAlias;
}
 
Example 2
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(File file, int mode) {
    checkMode(mode);
    SharedPreferencesImpl sp;
    synchronized (ContextImpl.class) {
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        sp = cache.get(file);
        if (sp == null) {
            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 3
Source File: SimpleAuthActivity.java    From android-AutofillFramework with Apache License 2.0 6 votes vote down vote up
private void onYes() {
    Intent myIntent = getIntent();
    Intent replyIntent = new Intent();
    Dataset dataset = myIntent.getParcelableExtra(EXTRA_DATASET);
    if (dataset != null) {
        replyIntent.putExtra(EXTRA_AUTHENTICATION_RESULT, dataset);
    } else {
        String[] hints = myIntent.getStringArrayExtra(EXTRA_HINTS);
        Parcelable[] ids = myIntent.getParcelableArrayExtra(EXTRA_IDS);
        boolean authenticateDatasets = myIntent.getBooleanExtra(EXTRA_AUTH_DATASETS, false);
        int size = hints.length;
        ArrayMap<String, AutofillId> fields = new ArrayMap<>(size);
        for (int i = 0; i < size; i++) {
            fields.put(hints[i], (AutofillId) ids[i]);
        }
        FillResponse response =
                DebugService.createResponse(this, fields, 1, authenticateDatasets);
        replyIntent.putExtra(EXTRA_AUTHENTICATION_RESULT, response);

    }
    setResult(RESULT_OK, replyIntent);
    finish();
}
 
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: XmlUtils.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Like {@link #readThisMapXml}, but returns an ArrayMap instead of HashMap.
 *
 * @hide
 */
public static final ArrayMap<String, ?> readThisArrayMapXml(XmlPullParser parser, String endTag,
															String[] name, ReadMapCallback callback)
		throws XmlPullParserException, java.io.IOException {
	ArrayMap<String, Object> map = new ArrayMap<>();

	int eventType = parser.getEventType();
	do {
		if (eventType == parser.START_TAG) {
			Object val = readThisValueXml(parser, name, callback, true);
			map.put(name[0], val);
		} else if (eventType == parser.END_TAG) {
			if (parser.getName().equals(endTag)) {
				return map;
			}
			throw new XmlPullParserException(
					"Expected " + endTag + " end tag at: " + parser.getName());
		}
		eventType = parser.next();
	} while (eventType != parser.END_DOCUMENT);

	throw new XmlPullParserException(
			"Document ended before " + endTag + " end tag");
}
 
Example 6
Source File: SnoozeHelper.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the notification record so the most up to date information is shown on re-post.
 */
protected void update(int userId, NotificationRecord record) {
    ArrayMap<String, ArrayMap<String, NotificationRecord>> records =
            mSnoozedNotifications.get(userId);
    if (records == null) {
        return;
    }
    ArrayMap<String, NotificationRecord> pkgRecords = records.get(record.sbn.getPackageName());
    if (pkgRecords == null) {
        return;
    }
    NotificationRecord existing = pkgRecords.get(record.getKey());
    if (existing != null && existing.isCanceled) {
        return;
    }
    pkgRecords.put(record.getKey(), record);
}
 
Example 7
Source File: ContentService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mCache")
private ArrayMap<Pair<String, Uri>, Bundle> findOrCreateCacheLocked(int userId,
        String providerPackageName) {
    ArrayMap<String, ArrayMap<Pair<String, Uri>, Bundle>> userCache = mCache.get(userId);
    if (userCache == null) {
        userCache = new ArrayMap<>();
        mCache.put(userId, userCache);
    }
    ArrayMap<Pair<String, Uri>, Bundle> packageCache = userCache.get(providerPackageName);
    if (packageCache == null) {
        packageCache = new ArrayMap<>();
        userCache.put(providerPackageName, packageCache);
    }
    return packageCache;
}
 
Example 8
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) {
    checkMode(mode);
    if (getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.O) {
        if (isCredentialProtectedStorage()
                && !getSystemService(StorageManager.class).isUserKeyUnlocked(
                        UserHandle.myUserId())
                && !isBuggy()) {
            throw new IllegalStateException("SharedPreferences in credential encrypted "
                    + "storage are not available until after user is unlocked");
        }
    }
    SharedPreferencesImpl sp;
    synchronized (ContextImpl.class) {
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        sp = cache.get(file);
        if (sp == null) {
            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 9
Source File: SerializerUnitTest.java    From Morpheus with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Test
public void testGetFieldsAsDictionary() {
  Article article = new Article();
  article.setTitle("title");
  article.setPublicStatus(true);
  ArrayList<String> tags = new ArrayList<String>();
  tags.add("tag1");
  article.setTags(tags);
  ArrayMap<String, String> testmap = new ArrayMap<>();
  testmap.put("key", "value");
  article.setMap(testmap);
  article.setVersion(1);
  article.setPrice(1.0);

  Map<String, Object> checkMap = new HashMap<>();
  checkMap.put("price", 1.0);
  checkMap.put("public", "true");
  checkMap.put("title", "title");
  checkMap.put("map", testmap);
  checkMap.put("version", 1);
  checkMap.put("tags", tags);

  Map<String, Object> map = serializer.getFieldsAsDictionary(article);

  assertNotNull(map);
  assertEquals(checkMap.toString(), map.toString());
}
 
Example 10
Source File: AbstractReadableSensorOptions.java    From science-journal with Apache License 2.0 5 votes vote down vote up
public static TransportableSensorOptions makeTransportable(ReadableSensorOptions fromThis) {
  ArrayMap<String, String> values = new ArrayMap<>();
  for (String key : fromThis.getWrittenKeys()) {
    values.put(key, fromThis.getString(key, null));
  }
  return new TransportableSensorOptions(values);
}
 
Example 11
Source File: JobPackageTracker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private PackageEntry getOrCreateEntry(int uid, String pkg) {
    ArrayMap<String, PackageEntry> uidMap = mEntries.get(uid);
    if (uidMap == null) {
        uidMap = new ArrayMap<>();
        mEntries.put(uid, uidMap);
    }
    PackageEntry entry = uidMap.get(pkg);
    if (entry == null) {
        entry = new PackageEntry();
        uidMap.put(pkg, entry);
    }
    return entry;
}
 
Example 12
Source File: TrustedRootCertificates.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static ArrayMap<String, X509Certificate> constructRootCertificateMap() {
    ArrayMap<String, X509Certificate> certificates =
            new ArrayMap<>(NUMBER_OF_ROOT_CERTIFICATES);
    certificates.put(
            GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS,
            GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_CERTIFICATE);
    return certificates;
}
 
Example 13
Source File: ResourcesManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
final void applyNewResourceDirsLocked(@NonNull final String baseCodePath,
        @Nullable final String[] newResourceDirs) {
    try {
        Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
                "ResourcesManager#applyNewResourceDirsLocked");

        final ArrayMap<ResourcesImpl, ResourcesKey> updatedResourceKeys = new ArrayMap<>();
        final int implCount = mResourceImpls.size();
        for (int i = 0; i < implCount; i++) {
            final ResourcesKey key = mResourceImpls.keyAt(i);
            final WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
            final ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null;
            if (impl != null && (key.mResDir == null || key.mResDir.equals(baseCodePath))) {
                updatedResourceKeys.put(impl, new ResourcesKey(
                        key.mResDir,
                        key.mSplitResDirs,
                        newResourceDirs,
                        key.mLibDirs,
                        key.mDisplayId,
                        key.mOverrideConfiguration,
                        key.mCompatInfo));
            }
        }

        redirectResourcesToNewImplLocked(updatedResourceKeys);
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
    }
}
 
Example 14
Source File: CustomContextWrapper.java    From Neptune with Apache License 2.0 5 votes vote down vote up
/**
 * Android 4.4-6.0
 * <herf>http://androidxref.com/4.4_r1/xref/frameworks/base/core/java/android/app/ContextImpl.java#184</herf>
 * <href>http://androidxref.com/6.0.0_r1/xref/frameworks/base/core/java/android/app/ContextImpl.java#132</href>
 * ContextImpl.java
 * private static ArrayMap<String, ArrayMap<String, SharedPreferencesImpl>> sSharedPrefs;
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private SharedPreferences getSharedPreferencesV19(String name, int mode)
        throws Exception {
    Object sp = null;
    Class<?> clazz = Class.forName("android.app.ContextImpl");
    Class<?> SharedPreferencesImpl = Class.forName("android.app.SharedPreferencesImpl");
    Constructor<?> constructor = SharedPreferencesImpl.getDeclaredConstructor(File.class, int.class);
    constructor.setAccessible(true);
    ArrayMap<String, ArrayMap<String, Object>> oSharedPrefs = ReflectionUtils.on(this.getBaseContext())
            .<ArrayMap<String, ArrayMap<String, Object>>>get(S_SHARED_PREFS);
    synchronized (clazz) {
        if (oSharedPrefs == null) {
            oSharedPrefs = new ArrayMap<String, ArrayMap<String, Object>>();
        }

        final String packageName = getPluginPackageName();
        ArrayMap<String, Object> packagePrefs = oSharedPrefs.get(packageName);
        if (packagePrefs == null) {
            packagePrefs = new ArrayMap<String, Object>();
            oSharedPrefs.put(packageName, packagePrefs);
        }

        sp = packagePrefs.get(name);
        if (sp == null) {
            File prefsFile = getSharedPrefsFile(name);
            sp = constructor.newInstance(prefsFile, mode);
            packagePrefs.put(name, sp);
            return (SharedPreferences) sp;
        }
        if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getPluginPackageInfo()
                .getPackageInfo().applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
            ReflectionUtils.on(sp).call("startReloadIfChangedUnexpectedly", sMethods, null);
        }
    }
    return (SharedPreferences) sp;
}
 
Example 15
Source File: KeySetManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Inform the system that the given package defines the given KeySets.
 * Remove any KeySets the package no longer defines.
 */
void addDefinedKeySetsToPackageLPw(PackageSetting pkg,
        ArrayMap<String, ArraySet<PublicKey>> definedMapping) {
    ArrayMap<String, Long> prevDefinedKeySets = pkg.keySetData.getAliases();

    /* add all of the newly defined KeySets */
    ArrayMap<String, Long> newKeySetAliases = new ArrayMap<String, Long>();
    final int defMapSize = definedMapping.size();
    for (int i = 0; i < defMapSize; i++) {
        String alias = definedMapping.keyAt(i);
        ArraySet<PublicKey> pubKeys = definedMapping.valueAt(i);
        if (alias != null && pubKeys != null && pubKeys.size() > 0) {
            KeySetHandle ks = addKeySetLPw(pubKeys);
            newKeySetAliases.put(alias, ks.getId());
        }
    }

    /* remove each of the old references */
    final int prevDefSize = prevDefinedKeySets.size();
    for (int i = 0; i < prevDefSize; i++) {
        decrementKeySetLPw(prevDefinedKeySets.valueAt(i));
    }
    pkg.keySetData.removeAllUpgradeKeySets();

    /* switch to the just-added */
    pkg.keySetData.setAliases(newKeySetAliases);
    return;
}
 
Example 16
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
    SharedPreferencesImpl sp;
    synchronized (ContextImpl.class) {
        if (sSharedPrefs == null) {
            sSharedPrefs = new ArrayMap<String, ArrayMap<String, SharedPreferencesImpl>>();
        }

        final String packageName = getPackageName();
        ArrayMap<String, SharedPreferencesImpl> packagePrefs = sSharedPrefs.get(packageName);
        if (packagePrefs == null) {
            packagePrefs = new ArrayMap<String, SharedPreferencesImpl>();
            sSharedPrefs.put(packageName, packagePrefs);
        }

        // 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";
            }
        }

        sp = packagePrefs.get(name);
        if (sp == null) {
            File prefsFile = getSharedPrefsFile(name);
            sp = new SharedPreferencesImpl(prefsFile, mode);
            packagePrefs.put(name, 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 17
Source File: FragmentTransition.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Finds the shared elements in the outgoing fragment. It also calls
 * {@link SharedElementCallback#onMapSharedElements(List, Map)} to allow more control
 * of the shared element mapping. {@code nameOverrides} is updated to match the
 * actual transition name of the mapped shared elements.
 *
 * @param nameOverrides A map of the shared element names from the starting fragment to
 *                      the final fragment's Views as given in
 *                      {@link FragmentTransaction#addSharedElement(View, String)}.
 * @param sharedElementTransition The shared element transition
 * @param fragments A structure holding the transitioning fragments in this container.
 * @return The mapping of shared element names to the Views in the hierarchy or null
 * if there is no shared element transition.
 */
private static ArrayMap<String, View> captureOutSharedElements(
        ArrayMap<String, String> nameOverrides, TransitionSet sharedElementTransition,
        FragmentContainerTransition fragments) {
    if (nameOverrides.isEmpty() || sharedElementTransition == null) {
        nameOverrides.clear();
        return null;
    }
    final Fragment outFragment = fragments.firstOut;
    final ArrayMap<String, View> outSharedElements = new ArrayMap<>();
    outFragment.getView().findNamedViews(outSharedElements);

    final SharedElementCallback sharedElementCallback;
    final ArrayList<String> names;
    final BackStackRecord outTransaction = fragments.firstOutTransaction;
    if (fragments.firstOutIsPop) {
        sharedElementCallback = outFragment.getEnterTransitionCallback();
        names = outTransaction.mSharedElementTargetNames;
    } else {
        sharedElementCallback = outFragment.getExitTransitionCallback();
        names = outTransaction.mSharedElementSourceNames;
    }

    outSharedElements.retainAll(names);
    if (sharedElementCallback != null) {
        sharedElementCallback.onMapSharedElements(names, outSharedElements);
        for (int i = names.size() - 1; i >= 0; i--) {
            String name = names.get(i);
            View view = outSharedElements.get(name);
            if (view == null) {
                nameOverrides.remove(name);
            } else if (!name.equals(view.getTransitionName())) {
                String targetValue = nameOverrides.remove(name);
                nameOverrides.put(view.getTransitionName(), targetValue);
            }
        }
    } else {
        nameOverrides.retainAll(outSharedElements.keySet());
    }
    return outSharedElements;
}
 
Example 18
Source File: AutofillManager.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void autofill(int sessionId, List<AutofillId> ids, List<AutofillValue> values) {
    synchronized (mLock) {
        if (sessionId != mSessionId) {
            return;
        }

        final AutofillClient client = getClient();
        if (client == null) {
            return;
        }

        final int itemCount = ids.size();
        int numApplied = 0;
        ArrayMap<View, SparseArray<AutofillValue>> virtualValues = null;
        final View[] views = client.autofillClientFindViewsByAutofillIdTraversal(
                Helper.toArray(ids));

        ArrayList<AutofillId> failedIds = null;

        for (int i = 0; i < itemCount; i++) {
            final AutofillId id = ids.get(i);
            final AutofillValue value = values.get(i);
            final int viewId = id.getViewId();
            final View view = views[i];
            if (view == null) {
                // Most likely view has been removed after the initial request was sent to the
                // the service; this is fine, but we need to update the view status in the
                // server side so it can be triggered again.
                Log.d(TAG, "autofill(): no View with id " + id);
                if (failedIds == null) {
                    failedIds = new ArrayList<>();
                }
                failedIds.add(id);
                continue;
            }
            if (id.isVirtual()) {
                if (virtualValues == null) {
                    // Most likely there will be just one view with virtual children.
                    virtualValues = new ArrayMap<>(1);
                }
                SparseArray<AutofillValue> valuesByParent = virtualValues.get(view);
                if (valuesByParent == null) {
                    // We don't know the size yet, but usually it will be just a few fields...
                    valuesByParent = new SparseArray<>(5);
                    virtualValues.put(view, valuesByParent);
                }
                valuesByParent.put(id.getVirtualChildId(), value);
            } else {
                // Mark the view as to be autofilled with 'value'
                if (mLastAutofilledData == null) {
                    mLastAutofilledData = new ParcelableMap(itemCount - i);
                }
                mLastAutofilledData.put(id, value);

                view.autofill(value);

                // Set as autofilled if the values match now, e.g. when the value was updated
                // synchronously.
                // If autofill happens async, the view is set to autofilled in
                // notifyValueChanged.
                setAutofilledIfValuesIs(view, value);

                numApplied++;
            }
        }

        if (failedIds != null) {
            if (sVerbose) {
                Log.v(TAG, "autofill(): total failed views: " + failedIds);
            }
            try {
                mService.setAutofillFailure(mSessionId, failedIds, mContext.getUserId());
            } catch (RemoteException e) {
                // In theory, we could ignore this error since it's not a big deal, but
                // in reality, we rather crash the app anyways, as the failure could be
                // a consequence of something going wrong on the server side...
                e.rethrowFromSystemServer();
            }
        }

        if (virtualValues != null) {
            for (int i = 0; i < virtualValues.size(); i++) {
                final View parent = virtualValues.keyAt(i);
                final SparseArray<AutofillValue> childrenValues = virtualValues.valueAt(i);
                parent.autofill(childrenValues);
                numApplied += childrenValues.size();
                // TODO: we should provide a callback so the parent can call failures; something
                // like notifyAutofillFailed(View view, int[] childrenIds);
            }
        }

        mMetricsLogger.write(newLog(MetricsEvent.AUTOFILL_DATASET_APPLIED)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VALUES, itemCount)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VIEWS_FILLED, numApplied));
    }
}
 
Example 19
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
    SharedPreferencesImpl sp;
    synchronized (ContextImpl.class) {
        if (sSharedPrefs == null) {
            sSharedPrefs = new ArrayMap<String, ArrayMap<String, SharedPreferencesImpl>>();
        }

        final String packageName = getPackageName();
        ArrayMap<String, SharedPreferencesImpl> packagePrefs = sSharedPrefs.get(packageName);
        if (packagePrefs == null) {
            packagePrefs = new ArrayMap<String, SharedPreferencesImpl>();
            sSharedPrefs.put(packageName, packagePrefs);
        }

        // 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";
            }
        }

        sp = packagePrefs.get(name);
        if (sp == null) {
            File prefsFile = getSharedPrefsFile(name);
            sp = new SharedPreferencesImpl(prefsFile, mode);
            packagePrefs.put(name, 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 20
Source File: TransitionManager.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Sets a specific transition to occur when the given pair of scenes is
 * exited/entered.
 *
 * @param fromScene The scene being exited when the given transition will
 * be run
 * @param toScene The scene being entered when the given transition will
 * be run
 * @param transition The transition that will play when the given scene is
 * entered. A value of null will result in the default behavior of
 * using the default transition instead.
 */
public void setTransition(Scene fromScene, Scene toScene, Transition transition) {
    ArrayMap<Scene, Transition> sceneTransitionMap = mScenePairTransitions.get(toScene);
    if (sceneTransitionMap == null) {
        sceneTransitionMap = new ArrayMap<Scene, Transition>();
        mScenePairTransitions.put(toScene, sceneTransitionMap);
    }
    sceneTransitionMap.put(fromScene, transition);
}