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

Commit 32bee192 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Remove dead code

Bug: 118883513
Test: manually
Change-Id: I0bbdfac91cbe26d08445178b5690c2e9171a39c8
parent d73433cf
Loading
Loading
Loading
Loading
+8 −20
Original line number Original line Diff line number Diff line
@@ -56,37 +56,25 @@ public class Utils {


    public static void updateLocationEnabled(Context context, boolean enabled, int userId,
    public static void updateLocationEnabled(Context context, boolean enabled, int userId,
            int source) {
            int source) {
        LocationManager locationManager = context.getSystemService(LocationManager.class);

        Settings.Secure.putIntForUser(
        Settings.Secure.putIntForUser(
                context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source,
                context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source,
                userId);
                userId);
        Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION);


        final int oldMode = Settings.Secure.getIntForUser(context.getContentResolver(),
        Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION);
                Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, userId);
        final int oldMode = locationManager.isLocationEnabled()
                ? Settings.Secure.LOCATION_MODE_ON
                : Settings.Secure.LOCATION_MODE_OFF;
        final int newMode = enabled
        final int newMode = enabled
                ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY
                ? Settings.Secure.LOCATION_MODE_ON
                : Settings.Secure.LOCATION_MODE_OFF;
                : Settings.Secure.LOCATION_MODE_OFF;
        intent.putExtra(CURRENT_MODE_KEY, oldMode);
        intent.putExtra(CURRENT_MODE_KEY, oldMode);
        intent.putExtra(NEW_MODE_KEY, newMode);
        intent.putExtra(NEW_MODE_KEY, newMode);
        context.sendBroadcastAsUser(
        context.sendBroadcastAsUser(
                intent, UserHandle.of(userId), android.Manifest.permission.WRITE_SECURE_SETTINGS);
                intent, UserHandle.of(userId), android.Manifest.permission.WRITE_SECURE_SETTINGS);
        LocationManager locationManager =
                (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        locationManager.setLocationEnabledForUser(enabled, UserHandle.of(userId));
    }


    public static boolean updateLocationMode(Context context, int oldMode, int newMode, int userId,
        locationManager.setLocationEnabledForUser(enabled, UserHandle.of(userId));
            int source) {
        Settings.Secure.putIntForUser(
                context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source,
                userId);
        Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION);
        intent.putExtra(CURRENT_MODE_KEY, oldMode);
        intent.putExtra(NEW_MODE_KEY, newMode);
        context.sendBroadcastAsUser(
                intent, UserHandle.of(userId), android.Manifest.permission.WRITE_SECURE_SETTINGS);
        return Settings.Secure.putIntForUser(
                context.getContentResolver(), Settings.Secure.LOCATION_MODE, newMode, userId);
    }
    }


    /**
    /**
+0 −20
Original line number Original line Diff line number Diff line
@@ -38,7 +38,6 @@ import android.media.AudioManager;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.text.TextUtils;
import android.text.TextUtils;


@@ -85,25 +84,6 @@ public class UtilsTest {
        mAudioManager = mContext.getSystemService(AudioManager.class);
        mAudioManager = mContext.getSystemService(AudioManager.class);
    }
    }


    @Test
    public void testUpdateLocationMode_sendBroadcast() {
        int currentUserId = ActivityManager.getCurrentUser();
        Utils.updateLocationMode(
                mContext,
                Secure.LOCATION_MODE_OFF,
                Secure.LOCATION_MODE_HIGH_ACCURACY,
                currentUserId,
                Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS);

        verify(mContext).sendBroadcastAsUser(
                argThat(actionMatches(LocationManager.MODE_CHANGING_ACTION)),
                ArgumentMatchers.eq(UserHandle.of(currentUserId)),
                ArgumentMatchers.eq(WRITE_SECURE_SETTINGS));
        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_CHANGER_UNKNOWN))
                .isEqualTo(Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS);
    }

    @Test
    @Test
    public void testUpdateLocationEnabled_sendBroadcast() {
    public void testUpdateLocationEnabled_sendBroadcast() {
        int currentUserId = ActivityManager.getCurrentUser();
        int currentUserId = ActivityManager.getCurrentUser();