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

Commit 747cbec1 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Clear calling identity from location providers

Location providers that call into system server need their identity
removed at some point so that system server can perform protected
operations on their behalf.

Bug: 141325704
Test: Manual
Change-Id: Iabd3a76cbe96473604923a772146c8c7a65cd076
parent d4718e18
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.location;

import android.content.Context;
import android.location.Location;
import android.os.Binder;
import android.os.Bundle;
import android.os.WorkSource;

@@ -80,7 +81,12 @@ public abstract class AbstractLocationProvider {
     * any thread.
     */
    protected void setEnabled(boolean enabled) {
        long identity = Binder.clearCallingIdentity();
        try {
            mLocationProviderManager.onSetEnabled(enabled);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }

    /**
@@ -88,21 +94,36 @@ public abstract class AbstractLocationProvider {
     * any thread.
     */
    protected void setProperties(ProviderProperties properties) {
        long identity = Binder.clearCallingIdentity();
        try {
            mLocationProviderManager.onSetProperties(properties);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }

    /**
     * Call this method to report a new location. May be called from any thread.
     */
    protected void reportLocation(Location location) {
        long identity = Binder.clearCallingIdentity();
        try {
            mLocationProviderManager.onReportLocation(location);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }

    /**
     * Call this method to report a new location. May be called from any thread.
     */
    protected void reportLocation(List<Location> locations) {
        long identity = Binder.clearCallingIdentity();
        try {
            mLocationProviderManager.onReportLocation(locations);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }

    /**