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

Commit 3c533928 authored by Chen Xu's avatar Chen Xu Committed by Gerrit Code Review
Browse files

Merge "remove hidden APIs in ResolveInfo, ComponentInfo and Bundle"

parents f8b87bf1 e7b6ac71
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ComponentInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
@@ -42,6 +43,7 @@ import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.content.PackageMonitor;

import com.android.internal.telephony.util.TelephonyUtils;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.List;
@@ -228,8 +230,9 @@ public class CarrierServiceBindHelper {
            String candidateServiceClass = null;
            if (carrierResolveInfo != null) {
                metadata = carrierResolveInfo.serviceInfo.metaData;
                candidateServiceClass =
                        carrierResolveInfo.getComponentInfo().getComponentName().getClassName();
                ComponentInfo componentInfo = TelephonyUtils.getComponentInfo(carrierResolveInfo);
                candidateServiceClass = new ComponentName(componentInfo.packageName,
                    componentInfo.name).getClassName();
            }

            // Only bind if the service wants it
+3 −1
Original line number Diff line number Diff line
@@ -964,7 +964,9 @@ public class DcTracker extends Handler {

        private void enableMobileProvisioning() {
            final Message msg = obtainMessage(DctConstants.CMD_ENABLE_MOBILE_PROVISIONING);
            msg.setData(Bundle.forPair(DctConstants.PROVISIONING_URL_KEY, mProvisionUrl));
            Bundle bundle = new Bundle(1);
            bundle.putString(DctConstants.PROVISIONING_URL_KEY, mProvisionUrl);
            msg.setData(bundle);
            sendMessage(msg);
        }

+10 −7
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.content.PackageMonitor;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.internal.util.IState;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -634,9 +635,9 @@ public class EuiccConnector extends StateMachine implements ServiceConnection {
                    isSameComponent = mSelectedComponent != null;
                } else {
                    isSameComponent = mSelectedComponent == null
                            || Objects.equals(
                                    bestComponent.getComponentName(),
                                    mSelectedComponent.getComponentName());
                            || Objects.equals(new ComponentName(bestComponent.packageName,
                            bestComponent.name),
                        new ComponentName(mSelectedComponent.packageName, mSelectedComponent.name));
                }
                boolean forceRebind = bestComponent != null
                        && Objects.equals(bestComponent.packageName, affectedPackage);
@@ -1041,7 +1042,8 @@ public class EuiccConnector extends StateMachine implements ServiceConnection {
            return false;
        }
        Intent intent = new Intent(EuiccService.EUICC_SERVICE_INTERFACE);
        intent.setComponent(mSelectedComponent.getComponentName());
        intent.setComponent(new ComponentName(mSelectedComponent.packageName,
            mSelectedComponent.name));
        // We bind this as a foreground service because it is operating directly on the SIM, and we
        // do not want it subjected to power-savings restrictions while doing so.
        return mContext.bindService(intent, this,
@@ -1065,7 +1067,7 @@ public class EuiccConnector extends StateMachine implements ServiceConnection {

                if (resolveInfo.filter.getPriority() > bestPriority) {
                    bestPriority = resolveInfo.filter.getPriority();
                    bestComponent = resolveInfo.getComponentInfo();
                    bestComponent = TelephonyUtils.getComponentInfo(resolveInfo);
                }
            }
        }
@@ -1075,8 +1077,9 @@ public class EuiccConnector extends StateMachine implements ServiceConnection {

    private static boolean isValidEuiccComponent(
            PackageManager packageManager, ResolveInfo resolveInfo) {
        ComponentInfo componentInfo = resolveInfo.getComponentInfo();
        String packageName = componentInfo.getComponentName().getPackageName();
        ComponentInfo componentInfo = TelephonyUtils.getComponentInfo(resolveInfo);
        String packageName = new ComponentName(componentInfo.packageName, componentInfo.name)
            .getPackageName();

        // Verify that the app is privileged (via granting of a privileged permission).
        if (packageManager.checkPermission(
+10 −0
Original line number Diff line number Diff line
@@ -15,8 +15,11 @@
 */
package com.android.internal.telephony.util;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.SystemProperties;
import android.content.pm.ComponentInfo;
import android.content.pm.ResolveInfo;

/**
 * This class provides various util functions
@@ -29,4 +32,11 @@ public final class TelephonyUtils {

    public static boolean IS_DEBUGGABLE =
            SystemProperties.getInt("ro.debuggable", 0) == 1;

    public static ComponentInfo getComponentInfo(@NonNull ResolveInfo resolveInfo) {
        if (resolveInfo.activityInfo != null) return resolveInfo.activityInfo;
        if (resolveInfo.serviceInfo != null) return resolveInfo.serviceInfo;
        if (resolveInfo.providerInfo != null) return resolveInfo.providerInfo;
        throw new IllegalStateException("Missing ComponentInfo!");
    }
  }