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

Commit f424801b authored by Chen Chen's avatar Chen Chen Committed by Gerrit Code Review
Browse files

Merge "Updateability: Find alternatives for APIs in android/content"

parents d515c4d0 561a4d33
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -489,9 +489,9 @@ public class AdapterService extends Service {
        }.execute();

        try {
            int systemUiUid = getApplicationContext().getPackageManager().getPackageUidAsUser(
                    "com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY,
                    UserHandle.USER_SYSTEM);
            int systemUiUid = getApplicationContext().getPackageManager().getPackageUid(
                    "com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY);

            Utils.setSystemUiUid(systemUiUid);
        } catch (PackageManager.NameNotFoundException e) {
            // Some platforms, such as wearables do not have a system ui.
@@ -499,8 +499,7 @@ public class AdapterService extends Service {
        }

        IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
        getApplicationContext().registerReceiverAsUser(sUserSwitchedReceiver, UserHandle.ALL,
                filter, null, null);
        getApplicationContext().registerReceiverForAllUsers(sUserSwitchedReceiver, filter, null, null);
        int fuid = ActivityManager.getCurrentUser();
        Utils.setForegroundUserId(fuid);
    }
+41 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.bluetooth.hfp;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.IBluetoothHeadsetPhone;
@@ -24,6 +26,9 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.media.AudioManager;
import android.os.IBinder;
import android.os.PowerManager;
@@ -32,6 +37,8 @@ import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;

import java.util.List;

/**
 * Defines system calls that is used by state machine/service to either send or receive
 * messages from the Android System.
@@ -88,7 +95,7 @@ public class HeadsetSystemInterface {
    public synchronized void init() {
        // Bind to Telecom phone proxy service
        Intent intent = new Intent(IBluetoothHeadsetPhone.class.getName());
        intent.setComponent(intent.resolveSystemService(mHeadsetService.getPackageManager(), 0));
        intent.setComponent(resolveSystemService(mHeadsetService.getPackageManager(), 0, intent));
        if (intent.getComponent() == null || !mHeadsetService.bindService(intent,
                mPhoneProxyConnection, 0)) {
            // Crash the stack if cannot bind to Telecom
@@ -96,6 +103,39 @@ public class HeadsetSystemInterface {
        }
    }

    /**
     * Special function for use by the system to resolve service
     * intents to system apps.  Throws an exception if there are
     * multiple potential matches to the Intent.  Returns null if
     * there are no matches.
     */
    private @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
            @PackageManager.ComponentInfoFlags int flags, Intent intent) {
        if (intent.getComponent() != null) {
            return intent.getComponent();
        }

        List<ResolveInfo> results = pm.queryIntentServices(intent, flags);
        if (results == null) {
            return null;
        }
        ComponentName comp = null;
        for (int i = 0; i < results.size(); i++) {
            ResolveInfo ri = results.get(i);
            if ((ri.serviceInfo.applicationInfo.flags& ApplicationInfo.FLAG_SYSTEM) == 0) {
                continue;
            }
            ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
                    ri.serviceInfo.name);
            if (comp != null) {
                throw new IllegalStateException("Multiple system services handle " + this
                        + ": " + comp + ", " + foundComp);
            }
            comp = foundComp;
        }
        return comp;
    }

    /**
     * Stop this system interface
     */
+1 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ProviderInfo;
import android.net.Uri;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;

@@ -68,8 +67,7 @@ public class BluetoothOppFileProvider extends FileProvider {
            if (!mRegisteredReceiver) {
                IntentFilter userFilter = new IntentFilter();
                userFilter.addAction(Intent.ACTION_USER_UNLOCKED);
                mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.CURRENT, userFilter,
                        null, null);
                mContext.registerReceiver(mBroadcastReceiver, userFilter, null, null);
                mRegisteredReceiver = true;
            }
            UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public final class DevicePolicyUtils {

        // Check each user.
        for (UserInfo ui : userInfoList) {
            if (!ui.isManagedProfile()) {
            if (!userManager.isManagedProfile(ui.id)) {
                continue; // Not a managed user.
            }
            return dpm.getBluetoothContactSharingDisabled(new UserHandle(ui.id));