Search in sources :

Example 21 with UriMatcher

use of android.content.UriMatcher in project android_frameworks_base by crdroidandroid.

the class DocumentsProvider method attachInfo.

/**
     * Implementation is provided by the parent class.
     */
@Override
public void attachInfo(Context context, ProviderInfo info) {
    mAuthority = info.authority;
    mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    mMatcher.addURI(mAuthority, "root", MATCH_ROOTS);
    mMatcher.addURI(mAuthority, "root/*", MATCH_ROOT);
    mMatcher.addURI(mAuthority, "root/*/recent", MATCH_RECENT);
    mMatcher.addURI(mAuthority, "root/*/search", MATCH_SEARCH);
    mMatcher.addURI(mAuthority, "document/*", MATCH_DOCUMENT);
    mMatcher.addURI(mAuthority, "document/*/children", MATCH_CHILDREN);
    mMatcher.addURI(mAuthority, "tree/*/document/*", MATCH_DOCUMENT_TREE);
    mMatcher.addURI(mAuthority, "tree/*/document/*/children", MATCH_CHILDREN_TREE);
    // Sanity check our setup
    if (!info.exported) {
        throw new SecurityException("Provider must be exported");
    }
    if (!info.grantUriPermissions) {
        throw new SecurityException("Provider must grantUriPermissions");
    }
    if (!android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.readPermission) || !android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.writePermission)) {
        throw new SecurityException("Provider must be protected by MANAGE_DOCUMENTS");
    }
    super.attachInfo(context, info);
}
Also used : UriMatcher(android.content.UriMatcher)

Example 22 with UriMatcher

use of android.content.UriMatcher in project android_frameworks_base by crdroidandroid.

the class UriMatcherTest method testContentUrisWithLeadingSlash.

@SmallTest
public void testContentUrisWithLeadingSlash() {
    UriMatcher matcher = new UriMatcher(ROOT);
    matcher.addURI("people", null, PEOPLE);
    matcher.addURI("people", "/#", PEOPLE_ID);
    matcher.addURI("people", "/#/phones", PEOPLE_PHONES);
    matcher.addURI("people", "/#/phones/blah", PEOPLE_PHONES_ID);
    matcher.addURI("people", "/#/phones/#", PEOPLE_PHONES_ID);
    matcher.addURI("people", "/#/addresses", PEOPLE_ADDRESSES);
    matcher.addURI("people", "/#/addresses/#", PEOPLE_ADDRESSES_ID);
    matcher.addURI("people", "/#/contact-methods", PEOPLE_CONTACTMETH);
    matcher.addURI("people", "/#/contact-methods/#", PEOPLE_CONTACTMETH_ID);
    matcher.addURI("calls", null, CALLS);
    matcher.addURI("calls", "/#", CALLS_ID);
    matcher.addURI("caller-id", null, CALLERID);
    matcher.addURI("caller-id", "/*", CALLERID_TEXT);
    matcher.addURI("filter-recent", null, FILTERRECENT);
    matcher.addURI("auth", "/another/path/segment", ANOTHER_PATH_SEGMENT);
    checkAll(matcher);
}
Also used : UriMatcher(android.content.UriMatcher) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 23 with UriMatcher

use of android.content.UriMatcher in project android_frameworks_base by crdroidandroid.

the class UriMatcherTest method testContentUris.

@SmallTest
public void testContentUris() {
    UriMatcher matcher = new UriMatcher(ROOT);
    matcher.addURI("people", null, PEOPLE);
    matcher.addURI("people", "#", PEOPLE_ID);
    matcher.addURI("people", "#/phones", PEOPLE_PHONES);
    matcher.addURI("people", "#/phones/blah", PEOPLE_PHONES_ID);
    matcher.addURI("people", "#/phones/#", PEOPLE_PHONES_ID);
    matcher.addURI("people", "#/addresses", PEOPLE_ADDRESSES);
    matcher.addURI("people", "#/addresses/#", PEOPLE_ADDRESSES_ID);
    matcher.addURI("people", "#/contact-methods", PEOPLE_CONTACTMETH);
    matcher.addURI("people", "#/contact-methods/#", PEOPLE_CONTACTMETH_ID);
    matcher.addURI("calls", null, CALLS);
    matcher.addURI("calls", "#", CALLS_ID);
    matcher.addURI("caller-id", null, CALLERID);
    matcher.addURI("caller-id", "*", CALLERID_TEXT);
    matcher.addURI("filter-recent", null, FILTERRECENT);
    matcher.addURI("auth", "another/path/segment", ANOTHER_PATH_SEGMENT);
    checkAll(matcher);
}
Also used : UriMatcher(android.content.UriMatcher) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 24 with UriMatcher

use of android.content.UriMatcher in project android_frameworks_base by AOSPA.

the class SearchIndexablesProvider method attachInfo.

/**
     * Implementation is provided by the parent class.
     */
@Override
public void attachInfo(Context context, ProviderInfo info) {
    mAuthority = info.authority;
    mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    mMatcher.addURI(mAuthority, SearchIndexablesContract.INDEXABLES_XML_RES_PATH, MATCH_RES_CODE);
    mMatcher.addURI(mAuthority, SearchIndexablesContract.INDEXABLES_RAW_PATH, MATCH_RAW_CODE);
    mMatcher.addURI(mAuthority, SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH, MATCH_NON_INDEXABLE_KEYS_CODE);
    // Sanity check our setup
    if (!info.exported) {
        throw new SecurityException("Provider must be exported");
    }
    if (!info.grantUriPermissions) {
        throw new SecurityException("Provider must grantUriPermissions");
    }
    if (!android.Manifest.permission.READ_SEARCH_INDEXABLES.equals(info.readPermission)) {
        throw new SecurityException("Provider must be protected by READ_SEARCH_INDEXABLES");
    }
    super.attachInfo(context, info);
}
Also used : UriMatcher(android.content.UriMatcher)

Example 25 with UriMatcher

use of android.content.UriMatcher in project aware-client by denzilferreira.

the class TimeZone_Provider method onCreate.

@Override
public boolean onCreate() {
    AUTHORITY = getContext().getPackageName() + ".provider.timezone";
    sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    sUriMatcher.addURI(TimeZone_Provider.AUTHORITY, DATABASE_TABLES[0], TIMEZONE);
    sUriMatcher.addURI(TimeZone_Provider.AUTHORITY, DATABASE_TABLES[0] + "/#", TIMEZONE_ID);
    timeZoneMap = new HashMap<String, String>();
    timeZoneMap.put(TimeZone_Data._ID, TimeZone_Data._ID);
    timeZoneMap.put(TimeZone_Data.TIMESTAMP, TimeZone_Data.TIMESTAMP);
    timeZoneMap.put(TimeZone_Data.DEVICE_ID, TimeZone_Data.DEVICE_ID);
    timeZoneMap.put(TimeZone_Data.TIMEZONE, TimeZone_Data.TIMEZONE);
    return true;
}
Also used : UriMatcher(android.content.UriMatcher)

Aggregations

UriMatcher (android.content.UriMatcher)69 SmallTest (android.test.suitebuilder.annotation.SmallTest)13 TableDetails (me.himanshusoni.quantumflux.model.generate.TableDetails)1