Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java

Issue 29453722: Noissue - Lint adjustments and optimizations (Closed)
Patch Set: Adjustments based on review comments Created June 13, 2017, 9:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 16 matching lines...) Expand all
27 27
28 import android.content.ContentProvider; 28 import android.content.ContentProvider;
29 import android.content.ContentValues; 29 import android.content.ContentValues;
30 import android.content.Intent; 30 import android.content.Intent;
31 import android.content.SharedPreferences; 31 import android.content.SharedPreferences;
32 import android.database.Cursor; 32 import android.database.Cursor;
33 import android.net.Uri; 33 import android.net.Uri;
34 import android.os.Bundle; 34 import android.os.Bundle;
35 import android.os.ParcelFileDescriptor; 35 import android.os.ParcelFileDescriptor;
36 import android.preference.PreferenceManager; 36 import android.preference.PreferenceManager;
37 import android.support.annotation.NonNull;
37 import android.util.Log; 38 import android.util.Log;
38 39
39 public class ContentBlockerContentProvider extends ContentProvider 40 public class ContentBlockerContentProvider extends ContentProvider
40 { 41 {
41 private static final String TAG = ContentBlockerContentProvider.class.getSimpl eName(); 42 private static final String TAG = ContentBlockerContentProvider.class.getSimpl eName();
42 43
43 @Override 44 @Override
44 public Bundle call(String method, String arg, Bundle extras) 45 public Bundle call(@NonNull String method, String arg, Bundle extras)
45 { 46 {
46 // As of SBC interface v1.4 we return `null` here to signal that we do not 47 // As of SBC interface v1.4 we return `null` here to signal that we do not
47 // use encryption 48 // use encryption
48 return null; 49 return null;
49 } 50 }
50 51
51 private static boolean getBooleanPref(final SharedPreferences prefs, final Str ing key, 52 private static boolean getBooleanPref(final SharedPreferences prefs, final Str ing key,
52 final boolean defValue) 53 final boolean defValue)
53 { 54 {
54 try 55 try
55 { 56 {
56 return prefs.getBoolean(key, defValue); 57 return prefs.getBoolean(key, defValue);
57 } 58 }
58 catch (final Throwable t) 59 catch (final Throwable t)
59 { 60 {
60 return defValue; 61 return defValue;
61 } 62 }
62 } 63 }
63 64
64 private void setApplicationActivated() 65 private void setApplicationActivated()
65 { 66 {
66 final SharedPreferences prefs = PreferenceManager 67 final SharedPreferences prefs = PreferenceManager
67 .getDefaultSharedPreferences(this.getContext().getApplicationContext()); 68 .getDefaultSharedPreferences(this.getContext().getApplicationContext());
68 final String key = this.getContext().getString(R.string.key_application_acti vated); 69 final String key = this.getContext().getString(R.string.key_application_acti vated);
69 final boolean applicationActived = getBooleanPref(prefs, key, false); 70 final boolean applicationActivated = getBooleanPref(prefs, key, false);
70 if (!applicationActived) 71 if (!applicationActivated)
71 { 72 {
72 prefs.edit() 73 prefs.edit()
73 .putBoolean(key, true) 74 .putBoolean(key, true)
74 .commit(); 75 .commit();
75 } 76 }
76 } 77 }
77 78
78 @Override 79 @Override
79 public ParcelFileDescriptor openFile(final Uri uri, final String mode) 80 public ParcelFileDescriptor openFile(@NonNull final Uri uri, @NonNull final St ring mode)
80 throws FileNotFoundException 81 throws FileNotFoundException
81 { 82 {
82 try 83 try
83 { 84 {
84 this.setApplicationActivated(); 85 this.setApplicationActivated();
85 Log.d(TAG, "Writing filters..."); 86 Log.d(TAG, "Writing filters...");
86 final File filterFile = Engine.getOrCreateCachedFilterFile(getContext()); 87 final File filterFile = Engine.getOrCreateCachedFilterFile(getContext());
87 Log.d(TAG, "Delivering filters..."); 88 Log.d(TAG, "Delivering filters...");
88 return ParcelFileDescriptor.open(filterFile, ParcelFileDescriptor.MODE_REA D_ONLY); 89 return ParcelFileDescriptor.open(filterFile, ParcelFileDescriptor.MODE_REA D_ONLY);
89 } 90 }
90 catch (IOException e) 91 catch (IOException e)
91 { 92 {
92 Log.e(TAG, "File creation failed: " + e.getMessage(), e); 93 Log.e(TAG, "File creation failed: " + e.getMessage(), e);
93 return null; 94 return null;
94 } 95 }
95 } 96 }
96 97
97 @Override 98 @Override
98 public boolean onCreate() 99 public boolean onCreate()
99 { 100 {
100 Log.i(TAG, "onCreate() called"); 101 Log.i(TAG, "onCreate() called");
101 getContext().startService(new Intent(getContext(), EngineService.class)); 102 getContext().startService(new Intent(getContext(), EngineService.class));
102 Log.i(TAG, "Requested service startup"); 103 Log.i(TAG, "Requested service startup");
103 return true; 104 return true;
104 } 105 }
105 106
106 @Override 107 @Override
107 public Cursor query(final Uri uri, final String[] projection, final String sel ection, 108 public Cursor query(@NonNull final Uri uri, final String[] projection, final S tring selection,
108 final String[] selectionArgs, final String sortOrder) 109 final String[] selectionArgs, final String sortOrder)
109 { 110 {
110 return null; 111 return null;
111 } 112 }
112 113
113 @Override 114 @Override
114 public String getType(final Uri uri) 115 public String getType(@NonNull final Uri uri)
115 { 116 {
116 return null; 117 return null;
117 } 118 }
118 119
119 @Override 120 @Override
120 public Uri insert(final Uri uri, final ContentValues values) 121 public Uri insert(@NonNull final Uri uri, final ContentValues values)
121 { 122 {
122 return null; 123 return null;
123 } 124 }
124 125
125 @Override 126 @Override
126 public int delete(final Uri uri, final String selection, final String[] select ionArgs) 127 public int delete(@NonNull final Uri uri, final String selection, final String [] selectionArgs)
127 { 128 {
128 return 0; 129 return 0;
129 } 130 }
130 131
131 @Override 132 @Override
132 public int update(final Uri uri, final ContentValues values, final String sele ction, 133 public int update(@NonNull final Uri uri, final ContentValues values, final St ring selection,
133 final String[] selectionArgs) 134 final String[] selectionArgs)
134 { 135 {
135 return 0; 136 return 0;
136 } 137 }
137 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld