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

Commit 3460bad0 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6038280 from aee82bf0 to rvc-release

Change-Id: I08a059b7dcae80b25294add1452665d47bc35ea4
parents b11d0125 aee82bf0
Loading
Loading
Loading
Loading
+38 −0
Original line number Original line Diff line number Diff line
@@ -254,6 +254,44 @@ public final class Utils {
        Utils.sForegroundUserId = uid;
        Utils.sForegroundUserId = uid;
    }
    }


    public static void enforceBluetoothPermission(Context context) {
        context.enforceCallingOrSelfPermission(
                android.Manifest.permission.BLUETOOTH,
                "Need BLUETOOTH permission");
    }

    public static void enforceBluetoothAdminPermission(Context context) {
        context.enforceCallingOrSelfPermission(
                android.Manifest.permission.BLUETOOTH_ADMIN,
                "Need BLUETOOTH ADMIN permission");
    }

    public static void enforceBluetoothPrivilegedPermission(Context context) {
        context.enforceCallingOrSelfPermission(
                android.Manifest.permission.BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH PRIVILEGED permission");
    }

    public static void enforceLocalMacAddressPermission(Context context) {
        context.enforceCallingOrSelfPermission(
                android.Manifest.permission.LOCAL_MAC_ADDRESS,
                "Need LOCAL_MAC_ADDRESS permission");
    }

    public static void enforceDumpPermission(Context context) {
        context.enforceCallingOrSelfPermission(
                android.Manifest.permission.DUMP,
                "Need DUMP permission");
    }

    public static boolean callerIsSystemOrActiveUser(String tag, String method) {
        if (!checkCaller()) {
          Log.w(TAG, method + "() - Not allowed for non-active user and non system user");
          return false;
        }
        return true;
    }

    public static boolean checkCaller() {
    public static boolean checkCaller() {
        int callingUser = UserHandle.getCallingUserId();
        int callingUser = UserHandle.getCallingUserId();
        int callingUid = Binder.getCallingUid();
        int callingUid = Binder.getCallingUid();
+163 −390

File changed.

Preview size limit exceeded, changes collapsed.

+0 −70
Original line number Original line Diff line number Diff line
package com.android.bluetooth.btservice;

import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.os.Handler;
import android.provider.Settings;

/**
 * This helper class monitors the state of the enabled profiles and will update and restart
 * the adapter when necessary.
 */
public class ProfileObserver extends ContentObserver {
    private Context mContext;
    private AdapterService mService;
    private AdapterStateObserver mStateObserver;

    public ProfileObserver(Context context, AdapterService service, Handler handler) {
        super(handler);
        mContext = context;
        mService = service;
        mStateObserver = new AdapterStateObserver(this);
    }

    public void start() {
        mContext.getContentResolver()
                .registerContentObserver(
                        Settings.Global.getUriFor(Settings.Global.BLUETOOTH_DISABLED_PROFILES),
                        false, this);
    }

    private void onBluetoothOff() {
        mContext.unregisterReceiver(mStateObserver);
        Config.init(mContext);
        mService.enable();
    }

    public void stop() {
        mContext.getContentResolver().unregisterContentObserver(this);
    }

    @Override
    public void onChange(boolean selfChange) {
        if (mService.isEnabled()) {
            mContext.registerReceiver(mStateObserver,
                    new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
            mService.disable();
        }
    }

    private static class AdapterStateObserver extends BroadcastReceiver {
        private ProfileObserver mProfileObserver;

        AdapterStateObserver(ProfileObserver observer) {
            mProfileObserver = observer;
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())
                    && intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1)
                    == BluetoothAdapter.STATE_OFF) {
                mProfileObserver.onBluetoothOff();
            }
        }
    }
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -91,7 +91,7 @@ public class BluetoothMapConvoListing {
     */
     */
    public byte[] encode() throws UnsupportedEncodingException {
    public byte[] encode() throws UnsupportedEncodingException {
        StringWriter sw = new StringWriter();
        StringWriter sw = new StringWriter();
        XmlSerializer xmlConvoElement = new FastXmlSerializer();
        XmlSerializer xmlConvoElement = new FastXmlSerializer(0);
        try {
        try {
            xmlConvoElement.setOutput(sw);
            xmlConvoElement.setOutput(sw);
            xmlConvoElement.startDocument("UTF-8", true);
            xmlConvoElement.startDocument("UTF-8", true);
+1 −1
Original line number Original line Diff line number Diff line
@@ -266,7 +266,7 @@ public class BluetoothMapFolderElement implements Comparable<BluetoothMapFolderE


    public byte[] encode(int offset, int count) throws UnsupportedEncodingException {
    public byte[] encode(int offset, int count) throws UnsupportedEncodingException {
        StringWriter sw = new StringWriter();
        StringWriter sw = new StringWriter();
        XmlSerializer xmlMsgElement = new FastXmlSerializer();
        XmlSerializer xmlMsgElement = new FastXmlSerializer(0);
        int i, stopIndex;
        int i, stopIndex;
        // We need index based access to the subFolders
        // We need index based access to the subFolders
        BluetoothMapFolderElement[] folders =
        BluetoothMapFolderElement[] folders =
Loading