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

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

Merge "Bluetooth: Remove use of deprecated API(s)."

parents 7ae7948f 649d1c49
Loading
Loading
Loading
Loading
+0 −24
Original line number Diff line number Diff line
@@ -401,20 +401,6 @@ public final class Utils {
                        == PackageManager.PERMISSION_GRANTED;
    }

    public static boolean isLegacyForegroundApp(Context context, String pkgName) {
        return !isMApp(context, pkgName) && isForegroundApp(context, pkgName);
    }

    private static boolean isMApp(Context context, String pkgName) {
        try {
            return context.getPackageManager().getApplicationInfo(pkgName, 0).targetSdkVersion
                    >= Build.VERSION_CODES.M;
        } catch (PackageManager.NameNotFoundException e) {
            // In case of exception, assume M app
        }
        return true;
    }

    public static boolean isQApp(Context context, String pkgName) {
        try {
            return context.getPackageManager().getApplicationInfo(pkgName, 0).targetSdkVersion
@@ -424,16 +410,6 @@ public final class Utils {
        }
        return true;
    }
    /**
     * Return true if the specified package name is a foreground app.
     *
     * @param pkgName application package name.
     */
    private static boolean isForegroundApp(Context context, String pkgName) {
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
        return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName());
    }

    private static boolean isAppOppAllowed(AppOpsManager appOps, int op, String callingPackage) {
        return appOps.noteOp(op, Binder.getCallingUid(), callingPackage)
+1 −1
Original line number Diff line number Diff line
@@ -347,7 +347,7 @@ final class BondStateMachine extends StateMachine {
        intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        // Workaround for Android Auto until pre-accepting pairing requests is added.
        intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_ADMIN_PERM);
        mAdapterService.sendOrderedBroadcast(intent, AdapterService.BLUETOOTH_ADMIN_PERM);
    }

    private void sendIntent(BluetoothDevice device, int newState, int reason) {
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ public class BluetoothMapAccountLoader {
            return children;
        } finally {
            if (mProviderClient != null) {
                mProviderClient.release();
                mProviderClient.close();
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -1054,7 +1054,7 @@ public class BluetoothMapContentObserver {
        mResolver.unregisterContentObserver(mObserver);
        mObserverRegistered = false;
        if (mProviderClient != null) {
            mProviderClient.release();
            mProviderClient.close();
            mProviderClient = null;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -974,7 +974,7 @@ public class BluetoothMapObexServer extends ServerRequestHandler {

        }
        if (mProviderClient != null) {
            mProviderClient.release();
            mProviderClient.close();
            mProviderClient = null;
        }

Loading