Skip to content

Commit 366a94c

Browse files
committed
Prevent spam of "could not retrieve package" for removed apps
1 parent 508c786 commit 366a94c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

app/src/main/java/com/emanuelef/remote_capture/AppsResolver.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with PCAPdroid. If not, see <http://www.gnu.org/licenses/>.
1616
*
17-
* Copyright 2020-21 - Emanuele Faranda
17+
* Copyright 2020-26 - Emanuele Faranda
1818
*/
1919

2020
package com.emanuelef.remote_capture;
@@ -26,6 +26,7 @@
2626
import android.graphics.drawable.Drawable;
2727
import android.util.ArrayMap;
2828
import android.util.SparseArray;
29+
import android.util.SparseBooleanArray;
2930

3031
import com.emanuelef.remote_capture.interfaces.DrawableLoader;
3132
import com.emanuelef.remote_capture.model.AppDescriptor;
@@ -41,6 +42,7 @@ public class AppsResolver {
4142
private static final SparseArray<AppDescriptor> mMappedUids = new SparseArray<>();
4243
private static final ArrayMap<String, AppDescriptor> mMappedPackages = new ArrayMap<>();
4344
private final SparseArray<AppDescriptor> mApps;
45+
private final SparseBooleanArray mUnresolvedUids = new SparseBooleanArray();
4446
private final PackageManager mPm;
4547
private final Context mContext;
4648
private Method getPackageInfoAsUser;
@@ -161,7 +163,11 @@ public static AppDescriptor resolveInstalledApp(PackageManager pm, String packag
161163
}
162164

163165
if((packages == null) || (packages.length < 1)) {
164-
Log.w(TAG, "could not retrieve package: uid=" + uid);
166+
if(!mUnresolvedUids.get(uid)) {
167+
Log.w(TAG, "could not retrieve package: uid=" + uid);
168+
mUnresolvedUids.put(uid, true);
169+
}
170+
165171
return null;
166172
}
167173

@@ -239,6 +245,7 @@ public int getUid(String package_name) {
239245

240246
public void clear() {
241247
mApps.clear();
248+
mUnresolvedUids.clear();
242249
initVirtualApps();
243250
}
244251
}

0 commit comments

Comments
 (0)