mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-06-16 21:10:57 +08:00
Add apps loading in progress message
This commit is contained in:
parent
f862e8fe05
commit
13706f8baa
@ -154,7 +154,8 @@ public class CaptureService extends VpnService implements Runnable {
|
||||
try {
|
||||
builder.addAllowedApplication(app_filter);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Toast.makeText(this, "Could not find the specified app: " + app_filter, Toast.LENGTH_SHORT).show();
|
||||
String msg = String.format(getResources().getString(R.string.app_not_found), app_filter);
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
}
|
||||
@ -162,7 +163,7 @@ public class CaptureService extends VpnService implements Runnable {
|
||||
try {
|
||||
mParcelFileDescriptor = builder.setSession(CaptureService.VpnSessionName).establish();
|
||||
} catch (IllegalArgumentException | IllegalStateException e) {
|
||||
Toast.makeText(this, "VPN setup failed", Toast.LENGTH_SHORT).show();
|
||||
Utils.showToast(this, R.string.vpn_setup_failed);
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
@ -441,6 +442,7 @@ public class MainActivity extends AppCompatActivity implements LoaderManager.Loa
|
||||
if(mInstalledApps == null) {
|
||||
/* The applications loader has not finished yet. */
|
||||
mOpenAppsWhenDone = true;
|
||||
Utils.showToast(this, R.string.apps_loading_please_wait);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
@ -93,6 +94,7 @@ public class Utils {
|
||||
apps.add(new AppDescriptor("", icon, context.getResources().getString(R.string.no_filter), -1, false));
|
||||
|
||||
Log.d("APPS", "num apps (system+user): " + packs.size());
|
||||
long tstart = now();
|
||||
|
||||
for (int i = 0; i < packs.size(); i++) {
|
||||
PackageInfo p = packs.get(i);
|
||||
@ -102,13 +104,18 @@ public class Utils {
|
||||
|
||||
if(!package_name.equals("com.emanuelef.remote_capture")) {
|
||||
String appName = p.applicationInfo.loadLabel(pm).toString();
|
||||
|
||||
// NOTE: this call is expensive
|
||||
icon = p.applicationInfo.loadIcon(pm);
|
||||
|
||||
int uid = p.applicationInfo.uid;
|
||||
apps.add(new AppDescriptor(appName, icon, package_name, uid, is_system));
|
||||
|
||||
Log.d("APPS", appName + " - " + package_name + " [" + uid + "]" + (is_system ? " - SYS" : " - USR"));
|
||||
}
|
||||
}
|
||||
|
||||
Log.d("APPS", packs.size() + " apps loaded in " + (now() - tstart) +" seconds");
|
||||
return apps;
|
||||
}
|
||||
|
||||
@ -218,6 +225,7 @@ public class Utils {
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
// returns current timestamp in seconds
|
||||
public static long now() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
return(calendar.getTimeInMillis() / 1000);
|
||||
@ -251,4 +259,9 @@ public class Utils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void showToast(Context context, int id) {
|
||||
String msg = context.getResources().getString(id);
|
||||
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,5 +65,8 @@
|
||||
<string name="yes">YES</string>
|
||||
<string name="no">NO</string>
|
||||
<string name="existing_vpn_confirm">The currently active VPN app will be disconnected. Do you want to proceed?</string>
|
||||
<string name="vpn_setup_failed">VPN setup failed</string>
|
||||
<string name="app_not_found">App "%1$s" not found</string>
|
||||
<string name="apps_loading_please_wait">Apps loading in progress, please wait</string>
|
||||
</resources>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user