127 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
887f53cf95
stop crash in TreeUriScannerIntentService.onActivityResult()
This might happen if the user denies storage permission.

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=16613, result=0, data=null} to activity {org.fdroid.fdroid/org.fdroid.fdroid.views.main.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference
	at android.app.ActivityThread.deliverResults(ActivityThread.java:4612)
	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4654)
	at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:214)
	at android.app.ActivityThread.main(ActivityThread.java:7073)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference
	at org.fdroid.fdroid.nearby.TreeUriScannerIntentService.onActivityResult(TreeUriScannerIntentService.java:99)
	at org.fdroid.fdroid.views.main.MainActivity.onActivityResult(MainActivity.java:270)
	at android.app.Activity.dispatchActivityResult(Activity.java:7759)
	at android.app.ActivityThread.deliverResults(ActivityThread.java:4605)
	... 11 more
java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference
	at org.fdroid.fdroid.nearby.TreeUriScannerIntentService.onActivityResult(TreeUriScannerIntentService.java:99)
	at org.fdroid.fdroid.views.main.MainActivity.onActivityResult(MainActivity.java:270)
	at android.app.Activity.dispatchActivityResult(Activity.java:7759)
	at android.app.ActivityThread.deliverResults(ActivityThread.java:4605)
	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4654)
	at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:214)
	at android.app.ActivityThread.main(ActivityThread.java:7073)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
2019-10-14 15:19:15 +02:00
Hans-Christoph Steiner
df818b0aed
fix crash in SwapView on android < 21
In order to support Android < 21, this calls `super` rather than `this`.
RelativeLayout}'s methods just use a 0 for the fourth argument, just like
this used to.
2019-10-14 15:19:13 +02:00
Hans-Christoph Steiner
f5a5805610
stop crash if hotspot returns null WifiConfiguration
java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.net.wifi.WifiConfiguration.SSID' on a null object reference
	at org.fdroid.fdroid.nearby.StartSwapView.uiUpdateWifiNetwork(StartSwapView.java:226)
	at org.fdroid.fdroid.nearby.StartSwapView.uiInitWifi(StartSwapView.java:211)
	at org.fdroid.fdroid.nearby.StartSwapView.onFinishInflate(StartSwapView.java:111)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:876)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
	at org.fdroid.fdroid.nearby.SwapWorkflowActivity.inflateSwapView(SwapWorkflowActivity.java:488)
	at org.fdroid.fdroid.nearby.SwapWorkflowActivity.showIntro(SwapWorkflowActivity.java:541)
	at org.fdroid.fdroid.nearby.SwapWorkflowActivity.showRelevantView(SwapWorkflowActivity.java:468)
	at org.fdroid.fdroid.nearby.SwapWorkflowActivity.access$100(SwapWorkflowActivity.java:86)
	at org.fdroid.fdroid.nearby.SwapWorkflowActivity$1.onServiceConnected(SwapWorkflowActivity.java:135)
	at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1652)
	at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1681)
	at android.os.Handler.handleCallback(Handler.java:790)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
2019-10-14 15:19:11 +02:00
Hans-Christoph Steiner
d233b03029
WifiStateChangeService: handle BSSID when WifiConfiguration is null
fixes:

java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.net.wifi.WifiConfiguration.BSSID' on a null object reference
 at org.fdroid.fdroid.nearby.WifiStateChangeService.setSsid(WifiStateChangeService.java:265)
 at org.fdroid.fdroid.nearby.WifiStateChangeService.access$100(WifiStateChangeService.java:59)
 at org.fdroid.fdroid.nearby.WifiStateChangeService$WifiInfoThread.run(WifiStateChangeService.java:174)
2019-10-14 15:19:09 +02:00
Hans-Christoph Steiner
1e29c281c6
catch random NullPointerExceptions related to WifiApControl
java.lang.NullPointerException: Attempt to read from field 'boolean android.net.wifi.WifiConfiguration.hiddenSSID' on a null object reference
at org.fdroid.fdroid.nearby.WifiStateChangeService.setSsid(WifiStateChangeService.java:252)
at org.fdroid.fdroid.nearby.WifiStateChangeService.access$100(WifiStateChangeService.java:59)
at org.fdroid.fdroid.nearby.WifiStateChangeService$WifiInfoThread.run(WifiStateChangeService.java:174)


java.lang.NullPointerException: null receiver
	at java.lang.reflect.Method.invoke(Native Method)
	at cc.mvdan.accesspoint.WifiApControl.invokeQuietly(WifiApControl.java:178)
	at cc.mvdan.accesspoint.WifiApControl.isWifiApEnabled(WifiApControl.java:189)
	at cc.mvdan.accesspoint.WifiApControl.isEnabled(WifiApControl.java:198)
	at org.fdroid.fdroid.nearby.WifiStateChangeService.setSsid(WifiStateChangeService.java:249)
	at org.fdroid.fdroid.nearby.WifiStateChangeService.access$100(WifiStateChangeService.java:59)
	at org.fdroid.fdroid.nearby.WifiStateChangeService$WifiInfoThread.run(WifiStateChangeService.java:133)

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.app.AppOpsManager.checkOpNoThrow(int, int, java.lang.String)' on a null object reference
 at android.provider.Settings.isCallingPackageAllowedToPerformAppOpsProtectedOperation(Settings.java:13730)
 at android.provider.Settings.isCallingPackageAllowedToWriteSettings(Settings.java:13634)
 at android.provider.Settings$System.canWrite(Settings.java:4793)
 at cc.mvdan.accesspoint.WifiApControl.getInstance(WifiApControl.java:122)
 at org.fdroid.fdroid.nearby.WifiStateChangeService.setSsid(WifiStateChangeService.java:240)
 at org.fdroid.fdroid.nearby.WifiStateChangeService.access$100(WifiStateChangeService.java:59)
 at org.fdroid.fdroid.nearby.WifiStateChangeService$WifiInfoThread.run(WifiStateChangeService.java:133)
2019-07-06 00:12:30 +02:00
Hans-Christoph Steiner
bfcc5c974e
fix crash in Panic Settings
This got missed in ef90fd2dfdb0b07aca21f4be34e2c418f092bf06
fdroid/fdroidclient!829

for f in `find app/src/ -type f -name \*.xml|xargs grep --no-filename -F '<org.fdroid.fdroid' | awk '{ print $1}' |sort -u`; do test -e app/src/*/java/`echo $f | sed -e 's,<,,' -e 's,\.,/,g'`.java || echo FAIL $f; done
2019-07-06 00:12:28 +02:00
Hans-Christoph Steiner
6c9afd823e speed up repo searchs by using "depth last"
Recursively search for index-v1.jar starting from the given directory,
looking at files first before recursing into directories.  This is
"depth last" since the index file is much more likely to be shallow
than deep, and there can be a lot of files to search through starting
at 4 or more levels deep, like the fdroid icons dirs and the per-app
"external storage" dirs.
2019-06-18 15:55:19 +02:00
Hans-Christoph Steiner
ca5996c5b3 detect when USB OTG device is plugged in and show Nearby tab 2019-06-17 18:37:26 +02:00
Hans-Christoph Steiner
525f99b056 implement mirror/repos on USB OTG via Storage Access Framework
* https://developer.android.com/training/articles/scoped-directory-access

One potential future direction, if this proves too limiting:
https://github.com/magnusja/libaums
2019-06-17 18:36:58 +02:00
Hans-Christoph Steiner
1ce70d3703 remove mistaken Service entry from full AndroidManifest.xml
LocalHTTPDManager is not a Service subclass.

79e7e78e7f69fc7dbe47684ee102c930e2c3a13f
2019-06-17 16:59:42 +02:00
Hans-Christoph Steiner
02669ea31f move WifiStateChangeReceiver into ".nearby" package 2019-06-17 11:28:52 +02:00
Hans-Christoph Steiner
842db03d8a fold ".views.hiding" into ".panic", it is only use there 2019-06-17 11:28:52 +02:00
Hans-Christoph Steiner
ef90fd2dfd move ".views.panic" to ".panic", it has more than just Views 2019-06-17 11:28:52 +02:00
Hans-Christoph Steiner
32aad6b562 move ".net.bluetooth" into ".nearby" package 2019-06-17 11:18:07 +02:00
Hans-Christoph Steiner
15d349f863 move LocalHTTPD and WifiStateChangeService into ".nearby" package 2019-06-17 11:18:07 +02:00
Hans-Christoph Steiner
43c7574228 fold ".views.swap" package into ".nearby" class 2019-06-17 10:50:56 +02:00
Hans-Christoph Steiner
790b5ab27d rename 'localrepo' package to 'nearby' to cover the whole thing 2019-06-17 10:50:56 +02:00
Hans-Christoph Steiner
ec6f9cef2b allow SwapService to start SwapWorkflowActivity on Android < 7.0
https://stackoverflow.com/a/50833599
2019-06-13 21:17:31 +02:00
Hans-Christoph Steiner
679820c0b2 get the SSID info when hotspot is active 2019-06-13 21:17:31 +02:00
Hans-Christoph Steiner
9db9f32bf1 show hotspot-specific status messages when hotspot is active 2019-06-13 21:17:31 +02:00
Hans-Christoph Steiner
b11ac7a64a set min width of Wi-Fi SSID field to keep it easily clickable 2019-06-13 21:17:31 +02:00
Hans-Christoph Steiner
abd61208d4 remember Hotspot state when using swap, restore on return 2019-06-13 21:17:31 +02:00
Hans-Christoph Steiner
bac0ae8f25 show all installed apps as possibilities for panic uninstall
F-Droid should be able to uninstall any app, in theory, not just the apps
that are listed in the index.

This lays some groundwork for moving swap's SelectAppsView to the standard
AppList elements used everywhere else.  It also does a little bit towards
getting rid of InstalledApp in favor of just reusing App.
2019-06-12 14:48:50 +02:00
Hans-Christoph Steiner
89140d5334 InstalledAppProvider: use Android sematics for query methods
Throughout Android, a null projection means return the full record.  This
is well documented.

Also, null sortOrder means use default sort order.
2019-06-12 14:48:50 +02:00
Hans-Christoph Steiner
4c352aeadc color destructive panic prefs with red background 2019-06-12 14:48:50 +02:00
Hans-Christoph Steiner
3b53af0657 panic: add destructive option to reset repos to defaults 2019-06-12 14:48:50 +02:00
Hans-Christoph Steiner
72f5398b79 panic: uninstall apps based destructive panic trigger
This will uninstall the list of apps that the user has setup in the Panic
Settings if Privileged Extension is installed.  This also requires that the
user set up a trusted connection between a panic trigger app (e.g. Ripple)
and F-Droid.
2019-06-12 14:48:50 +02:00
Hans-Christoph Steiner
d762e187dc update to PanicKit v1.0 2019-06-12 14:48:50 +02:00
Hans-Christoph Steiner
515b5b08f0 set up Panic preference to choose apps to uninstall on trigger 2019-06-12 14:48:50 +02:00
Hans-Christoph Steiner
301c2fff2d remove redundant preference constants 2019-06-12 14:48:50 +02:00
Yoginth
0851fea8eb
Fix Typos 2019-06-05 03:52:40 +00:00
Hans-Christoph Steiner
6d3a7d4537 move all QR Code related classes to .qr package 2019-05-24 15:47:48 +02:00
Hans-Christoph Steiner
23fc17ba5f purge confusing, unused duplicate string/icon assignment in bottom nav
fdroid/fdroidclient#1785
2019-05-24 15:47:48 +02:00
Hans-Christoph Steiner
051d58acaf start LocalRepoService once SelectApps is shown to speed up connecting 2019-05-24 13:36:47 +02:00
Hans-Christoph Steiner
6e8c4eb1bf store the current Bluetooth name and restore it when swap is done
fdroid/fdroidclient#1669
2019-05-24 13:36:47 +02:00
Hans-Christoph Steiner
7f35420e37 purge last RxAndroid code, replace with good ol' Intents
Rx needs to be used as the basis of the whole system, it doesn't make sense
to just have one small part handled by Rx.

RxJava is still used in InstallAppProviderService, so that would have to be
tackled separately.
2019-05-24 13:36:47 +02:00
Hans-Christoph Steiner
18a7690758 track all successful peers, and remove all unsuccessful peers
Since it is possible to connect to a peer via NFC, "Swap back", QR Code,
etc. once a peer is successfully used, it can show up in the StartSwapView
list of peers.
2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
0727787713 make BonjourPeer and WifiPeer equals if they point to the same device 2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
74c3c24f0a reset idle timer each time a new swap screen is loaded
This means that as long as the user is using swap, it'll stay running.
2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
e02bc4134a fix display of swap cancel button and installing progress
closes #1612
2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
fea778793c replace BluetoothSwap with BluetoothManager, using HandlerThread
This is the last of the SwapType stuff!

fdroid/fdroidclient#1723
fdroid/fdroidclient#1669
2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
ddbe93aeb4 SwapWorkflowActivity: save BluetoothAdapter instance for reuse 2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
da66949b9e turn LocalRepoService Intents into status Intents like other Services 2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
effcf4bfa9 purge WifiSwap class in favor of Intents and Services 2019-05-24 13:35:56 +02:00
Hans-Christoph Steiner
46472ba7a4 create BonjourManager to manage jmdns in HandlerThread, with tests 2019-05-24 13:35:55 +02:00
Hans-Christoph Steiner
79e7e78e7f create testable LocalHTTPDManager for controlling the webserver
The RxJava tricks were a nightmare...
2019-05-24 10:02:22 +02:00
Hans-Christoph Steiner
5b610798c2 more reliably set WiFi SSID in nearby/swap interfaces
Often times, the WiFi is properly setup, the IP address is showing, but the
SSID is showing as "No network yet".
2019-05-24 10:02:22 +02:00
Hans-Christoph Steiner
11e0c1926c move swap repo polling to SwapService
SwapService is the long lived background service, and it was already doing
the core work anyway.
2019-05-24 10:02:22 +02:00
Hans-Christoph Steiner
6c1375bf3a quick hack to show "Installing..." when swap install process runs 2019-05-24 10:02:22 +02:00
Hans-Christoph Steiner
e7979fca48 name all SwapService getters properly: getSwapService()
This also switches to always using getActivity().getSwapService() to make
it easily traceable where that is happening.  It shouldn't be happening in
SwapViews...
2019-05-24 10:02:22 +02:00