Code example for Context

Methods: getContentResolver, sleep

    public static final String PUBKEY_KEY = "pubkey_blacklist";
    public static final String SERIAL_KEY = "serial_blacklist";
    private void overrideSettings(String key, String value) throws Exception {
        Settings.Secure.putString(mContext.getContentResolver(), key, value);
    public void testClearBlacklistPubkey() throws Exception { 
        // clear the gservices setting for a clean slate 
        overrideSettings(PUBKEY_KEY, "");
        // read the contents of the pubkey blacklist 
        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
        // Verify that it's empty 
        assertEquals("", blacklist);
    public void testSetBlacklistPubkey() throws Exception { 
        // build a new thing to blacklist 
        String badPubkey = "7ccabd7db47e94a5759901b6a7dfd45d1c091ccc";