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

Commit b6375a4f authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Create AppForegroundHelper

Create a new helper to deal with application foreground state changes.

1) Rename various Helpers.
2) Move GnssManagerService into location dir.
3) Use new AppForegroundHelper everywhere.
4) Move sendNiRequest to internal API
5) Some refactoring of NetInitiatedActivity

Test: atest AppForegroundHelperTest
Change-Id: Ifffe0e6a34452a18d017c6b190547b904d77b430
parent 24e6e408
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.location.LocationManagerInternal;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -32,6 +32,7 @@ import android.widget.Toast;

import com.android.internal.R;
import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.server.LocalServices;

/**
 * This activity is shown to the user for him/her to accept or deny network-initiated
@@ -137,9 +138,8 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
    // Respond to NI Handler under GnssLocationProvider, 1 = accept, 2 = deny
    private void sendUserResponse(int response) {
        if (DEBUG) Log.d(TAG, "sendUserResponse, response: " + response);
        LocationManager locationManager = (LocationManager)
            this.getSystemService(Context.LOCATION_SERVICE);
        locationManager.sendNiResponse(notificationId, response);
        LocationManagerInternal lm = LocalServices.getService(LocationManagerInternal.class);
        lm.sendNiResponse(notificationId, response);
    }

    @UnsupportedAppUsage
+0 −2
Original line number Diff line number Diff line
@@ -69,8 +69,6 @@ interface ILocationManager
        double upperRightLatitude, double upperRightLongitude, int maxResults,
        in GeocoderParams params, out List<Address> addrs);

    boolean sendNiResponse(int notifId, int userResponse);

    boolean addGnssMeasurementsListener(in IGnssMeasurementsListener listener,
             String packageName, String featureId, String listenerIdentifier);
    void injectGnssMeasurementCorrections(in GnssMeasurementCorrections corrections,
+0 −15
Original line number Diff line number Diff line
@@ -2397,21 +2397,6 @@ public class LocationManager {
        }
    }

    /**
     * Used by NetInitiatedActivity to report user response
     * for network initiated GPS fix requests.
     *
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public boolean sendNiResponse(int notifId, int userResponse) {
        try {
            return mService.sendNiResponse(notifId, userResponse);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    private void checkPendingIntent(PendingIntent pendingIntent) {
        Preconditions.checkArgument(pendingIntent != null, "invalid null pending intent");
        if (!pendingIntent.isTargetedToPackage()) {
+15 −0
Original line number Diff line number Diff line
@@ -41,4 +41,19 @@ public abstract class LocationManagerInternal {
     * @throws IllegalArgumentException if provider is null
     */
    public abstract void requestSetProviderAllowed(@NonNull String provider, boolean allowed);

    /**
     * Returns true if the given package belongs to a location provider, and so should be afforded
     * some special privileges.
     *
     * @param packageName The package name to check
     * @return True is the given package belongs to a location provider, false otherwise
     */
    public abstract boolean isProviderPackage(@NonNull String packageName);

    /**
     * Should only be used by GNSS code.
     */
    // TODO: there is no reason for this to exist as part of any API. move all the logic into gnss
    public abstract void sendNiResponse(int notifId, int userResponse);
}
+184 −227

File changed.

Preview size limit exceeded, changes collapsed.

Loading