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

Commit f5ed7326 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Refine the restoreCallingIdentity and clearCallingIdentity usage"

parents 5e00ad11 8555e669
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
     */
    @Override
    public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        if (D) {
            Log.d(TAG, "openFile(): uri=" + uri.toString() + " - getLastPathSegment() = "
                    + uri.getLastPathSegment());
@@ -419,7 +419,7 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
            throw new IllegalArgumentException("Account ID missing in update values!");
        }

        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        try {
            if (table.equals(BluetoothMapContract.TABLE_MESSAGE)) {
                return deleteMessage(accountId, messageId);
@@ -463,7 +463,7 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
        }

        String id; // the id of the entry inserted into the database
        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        Log.d(TAG, "insert(): uri=" + uri.toString() + " - getLastPathSegment() = "
                + uri.getLastPathSegment());
        try {
@@ -517,7 +517,7 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
            String sortOrder) {
        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        try {
            String accountId = null;
            switch (mMatcher.match(uri)) {
@@ -606,7 +606,7 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {
                    "selection shall not be used, ContentValues shall contain the data");
        }

        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        if (D) {
            Log.w(TAG, "update(): uri=" + uri.toString() + " - getLastPathSegment() = "
                    + uri.getLastPathSegment());
@@ -669,7 +669,7 @@ public abstract class BluetoothMapEmailProvider extends ContentProvider {

    @Override
    public Bundle call(String method, String arg, Bundle extras) {
        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        if (D) {
            Log.d(TAG, "call(): method=" + method + " arg=" + arg + "ThreadId: "
                    + Thread.currentThread().getId());
+5 −5
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ public abstract class BluetoothMapIMProvider extends ContentProvider {
            throw new IllegalArgumentException("Account ID missing in update values!");
        }

        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        try {
            if (table.equals(BluetoothMapContract.TABLE_MESSAGE)) {
                return deleteMessage(accountId, messageId);
@@ -260,7 +260,7 @@ public abstract class BluetoothMapIMProvider extends ContentProvider {
        // TODO: validate values?

        String id; // the id of the entry inserted into the database
        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        Log.d(TAG, "insert(): uri=" + uri.toString() + " - getLastPathSegment() = "
                + uri.getLastPathSegment());
        try {
@@ -314,7 +314,7 @@ public abstract class BluetoothMapIMProvider extends ContentProvider {
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
            String sortOrder) {
        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        try {
            String accountId = null;
            if (D) {
@@ -503,7 +503,7 @@ public abstract class BluetoothMapIMProvider extends ContentProvider {
                    "selection shall not be used, ContentValues " + "shall contain the data");
        }

        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        if (D) {
            Log.w(TAG, "update(): uri=" + uri.toString() + " - getLastPathSegment() = "
                    + uri.getLastPathSegment());
@@ -614,7 +614,7 @@ public abstract class BluetoothMapIMProvider extends ContentProvider {

    @Override
    public Bundle call(String method, String arg, Bundle extras) {
        long callingId = Binder.clearCallingIdentity();
        final long callingId = Binder.clearCallingIdentity();
        if (D) {
            Log.w(TAG, "call(): method=" + method + " arg=" + arg + "ThreadId: "
                    + Thread.currentThread().getId());
+1 −1
Original line number Diff line number Diff line
@@ -347,7 +347,7 @@ public final class Utils {
        int callingUid = Binder.getCallingUid();

        // Use the Bluetooth process identity when making call to get parent user
        long ident = Binder.clearCallingIdentity();
        final long ident = Binder.clearCallingIdentity();
        try {
            UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
            UserInfo ui = um.getProfileParent(callingUser);
+20 −17
Original line number Diff line number Diff line
@@ -2080,7 +2080,7 @@ public class GattService extends ProfileService {
        if (mCompanionManager == null) {
            return new ArrayList<String>();
        }
        long identity = Binder.clearCallingIdentity();
        final long identity = Binder.clearCallingIdentity();
        try {
            return mCompanionManager.getAssociations(
                    callingPackage, userHandle.getIdentifier());
@@ -3333,10 +3333,10 @@ public class GattService extends ProfileService {
        }

        // Need to clear identity to pass device config permission check
        long callerToken = Binder.clearCallingIdentity();
        final long callerToken = Binder.clearCallingIdentity();
        try {
            long floor = DeviceConfig.getLong(DeviceConfig.NAMESPACE_BLUETOOTH, "report_delay",
                DEFAULT_REPORT_DELAY_FLOOR);
        Binder.restoreCallingIdentity(callerToken);

            if (settings.getReportDelayMillis() > floor) {
                return settings;
@@ -3352,6 +3352,9 @@ public class GattService extends ProfileService {
                        .setScanResultType(settings.getScanResultType())
                        .build();
            }
        } finally {
            Binder.restoreCallingIdentity(callerToken);
        }
    }

    private void stopNextService(int serverIf, int status) throws RemoteException {
+7 −3
Original line number Diff line number Diff line
@@ -438,9 +438,13 @@ public class BluetoothInCallService extends InCallService {
    public boolean processChld(int chld) {
        synchronized (LOCK) {
            enforceModifyPermission();
            long token = Binder.clearCallingIdentity();
            final long token = Binder.clearCallingIdentity();
            try {
                Log.i(TAG, "processChld " + chld);
                return _processChld(chld);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    }