Search in sources :

Example 21 with WorkerThread

use of android.annotation.WorkerThread in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VpnSettings method handleMessage.

@Override
@WorkerThread
public boolean handleMessage(Message message) {
    // Return if activity has been recycled
    final Activity activity = getActivity();
    if (activity == null) {
        return true;
    }
    final Context context = activity.getApplicationContext();
    // Run heavy RPCs before switching to UI thread
    final List<VpnProfile> vpnProfiles = loadVpnProfiles(mKeyStore);
    final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */
    true);
    final Map<String, LegacyVpnInfo> connectedLegacyVpns = getConnectedLegacyVpns();
    final Set<AppVpnInfo> connectedAppVpns = getConnectedAppVpns();
    final Set<AppVpnInfo> alwaysOnAppVpnInfos = getAlwaysOnAppVpnInfos();
    final String lockdownVpnKey = VpnUtils.getLockdownVpn();
    // Refresh list of VPNs
    activity.runOnUiThread(new UpdatePreferences(this).legacyVpns(vpnProfiles, connectedLegacyVpns, lockdownVpnKey).appVpns(vpnApps, connectedAppVpns, alwaysOnAppVpnInfos));
    synchronized (this) {
        if (mUpdater != null) {
            mUpdater.removeMessages(RESCAN_MESSAGE);
            mUpdater.sendEmptyMessageDelayed(RESCAN_MESSAGE, RESCAN_INTERVAL_MS);
        }
    }
    return true;
}
Also used : Context(android.content.Context) VpnProfile(com.android.internal.net.VpnProfile) Activity(android.app.Activity) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) WorkerThread(android.annotation.WorkerThread)

Example 22 with WorkerThread

use of android.annotation.WorkerThread in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VpnSettings method getAlwaysOnAppVpnInfos.

@WorkerThread
private Set<AppVpnInfo> getAlwaysOnAppVpnInfos() {
    Set<AppVpnInfo> result = new ArraySet<>();
    for (UserHandle profile : mUserManager.getUserProfiles()) {
        final int profileId = profile.getIdentifier();
        final String packageName = mConnectivityManager.getAlwaysOnVpnPackageForUser(profileId);
        if (packageName != null) {
            result.add(new AppVpnInfo(profileId, packageName));
        }
    }
    return result;
}
Also used : ArraySet(android.util.ArraySet) UserHandle(android.os.UserHandle) WorkerThread(android.annotation.WorkerThread)

Example 23 with WorkerThread

use of android.annotation.WorkerThread in project android_packages_apps_Settings by omnirom.

the class VpnSettings method handleMessage.

@Override
@WorkerThread
public boolean handleMessage(Message message) {
    // Return if activity has been recycled
    final Activity activity = getActivity();
    if (activity == null) {
        return true;
    }
    final Context context = activity.getApplicationContext();
    // Run heavy RPCs before switching to UI thread
    final List<VpnProfile> vpnProfiles = loadVpnProfiles();
    final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */
    true);
    final Map<String, LegacyVpnInfo> connectedLegacyVpns = getConnectedLegacyVpns();
    final Set<AppVpnInfo> connectedAppVpns = getConnectedAppVpns();
    final Set<AppVpnInfo> alwaysOnAppVpnInfos = getAlwaysOnAppVpnInfos();
    final String lockdownVpnKey = VpnUtils.getLockdownVpn();
    // Refresh list of VPNs
    activity.runOnUiThread(new UpdatePreferences(this).legacyVpns(vpnProfiles, connectedLegacyVpns, lockdownVpnKey).appVpns(vpnApps, connectedAppVpns, alwaysOnAppVpnInfos));
    synchronized (this) {
        if (mUpdater != null) {
            mUpdater.removeMessages(RESCAN_MESSAGE);
            mUpdater.sendEmptyMessageDelayed(RESCAN_MESSAGE, RESCAN_INTERVAL_MS);
        }
    }
    return true;
}
Also used : Context(android.content.Context) VpnProfile(com.android.internal.net.VpnProfile) Activity(android.app.Activity) LegacyVpnInfo(com.android.internal.net.LegacyVpnInfo) WorkerThread(android.annotation.WorkerThread)

Example 24 with WorkerThread

use of android.annotation.WorkerThread in project android_packages_apps_Settings by omnirom.

the class VpnSettings method getAlwaysOnAppVpnInfos.

@WorkerThread
private Set<AppVpnInfo> getAlwaysOnAppVpnInfos() {
    Set<AppVpnInfo> result = new ArraySet<>();
    for (UserHandle profile : mUserManager.getUserProfiles()) {
        final int profileId = profile.getIdentifier();
        final String packageName = mVpnManager.getAlwaysOnVpnPackageForUser(profileId);
        if (packageName != null) {
            result.add(new AppVpnInfo(profileId, packageName));
        }
    }
    return result;
}
Also used : ArraySet(android.util.ArraySet) UserHandle(android.os.UserHandle) WorkerThread(android.annotation.WorkerThread)

Aggregations

WorkerThread (android.annotation.WorkerThread)24 Activity (android.app.Activity)7 Context (android.content.Context)7 UserHandle (android.os.UserHandle)7 ArraySet (android.util.ArraySet)7 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)7 VpnProfile (com.android.internal.net.VpnProfile)7 Nullable (android.annotation.Nullable)5 PendingIntent (android.app.PendingIntent)5 ComponentName (android.content.ComponentName)5 Intent (android.content.Intent)5 ServiceConnection (android.content.ServiceConnection)5 IBinder (android.os.IBinder)5 RemoteException (android.os.RemoteException)5 TrustedCertificateStore (com.android.org.conscrypt.TrustedCertificateStore)5 CertificateException (java.security.cert.CertificateException)5 X509Certificate (java.security.cert.X509Certificate)5 ArrayList (java.util.ArrayList)5 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)5