Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc5ff39e authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Myles Watson
Browse files

Revert "Cache results of isLocationEnabledForUser calls"

This reverts commit e0534ac9.
Reason: upcoming Binder cache will make this code obsolete
Bug: 125739276
parent 58cd5f9a
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ LOCAL_JAVA_LIBRARIES := javax.obex telephony-common services.net
LOCAL_STATIC_JAVA_LIBRARIES := \
LOCAL_STATIC_JAVA_LIBRARIES := \
        com.android.vcard \
        com.android.vcard \
        bluetooth.mapsapi \
        bluetooth.mapsapi \
        guava \
        sap-api-java-static \
        sap-api-java-static \
        services.net \
        services.net \
        libprotobuf-java-lite \
        libprotobuf-java-lite \
+1 −26
Original line number Original line Diff line number Diff line
@@ -34,10 +34,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
import android.util.Log;
import android.util.Log;


import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;

import java.io.IOException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStream;
@@ -305,30 +301,9 @@ public final class Utils {
     * Checks whether location is off and must be on for us to perform some operation
     * Checks whether location is off and must be on for us to perform some operation
     */
     */
    public static boolean blockedByLocationOff(Context context, UserHandle userHandle) {
    public static boolean blockedByLocationOff(Context context, UserHandle userHandle) {
        if (mBlockedByLocationOffContext == null)
        return !context.getSystemService(LocationManager.class)
            mBlockedByLocationOffContext = context;

        try {
            return mBlockedByLocationOffCache.get(userHandle);
        } catch (java.util.concurrent.ExecutionException e) {
            Log.e(TAG, "blockedByLocationOff: " + e);
            return context.getSystemService(LocationManager.class)
                .isLocationEnabledForUser(userHandle);
        }
    }

   static Context mBlockedByLocationOffContext = null;
   // Cache location off for 10 users, cache is valid for 2 seconds.
   static LoadingCache<UserHandle, Boolean> mBlockedByLocationOffCache = CacheBuilder.newBuilder()
       .maximumSize(10)
       .expireAfterWrite(2, TimeUnit.SECONDS)
       .build(
           new CacheLoader<UserHandle, Boolean>() {
             public Boolean load(UserHandle userHandle) {
               return !mBlockedByLocationOffContext.getSystemService(LocationManager.class)
                .isLocationEnabledForUser(userHandle);
                .isLocationEnabledForUser(userHandle);
    }
    }
           });


    /**
    /**
     * Checks that calling process has android.Manifest.permission.ACCESS_COARSE_LOCATION and
     * Checks that calling process has android.Manifest.permission.ACCESS_COARSE_LOCATION and