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

Commit f728205c authored by Greg Kaiser's avatar Greg Kaiser Committed by Android (Google) Code Review
Browse files

Revert "Added System API client for BackgroundInstallControlService"

This reverts commit 9ba42db7.

Reason for revert: Seems suspicious for many new system crashes/reboots, b/319579008, b/319529606, b/319567367 and others

Change-Id: Ia4d7770e9f82e52b3f450333b4a7f525cb0c9dc9
parent 9ba42db7
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -862,10 +862,6 @@ package android.app {
    field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.PackageOps> CREATOR;
  }
  @FlaggedApi("android.app.bic_client") public final class BackgroundInstallControlManager {
    method @FlaggedApi("android.app.bic_client") @NonNull @RequiresPermission(android.Manifest.permission.QUERY_ALL_PACKAGES) public java.util.List<android.content.pm.PackageInfo> getBackgroundInstalledPackages(long);
  }
  public class BroadcastOptions {
    method public void clearRequireCompatChange();
    method public int getPendingIntentBackgroundActivityStartMode();
+0 −101
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app;

import static android.Manifest.permission.QUERY_ALL_PACKAGES;
import static android.annotation.SystemApi.Client.PRIVILEGED_APPS;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.content.pm.IBackgroundInstallControlService;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.ServiceManager;

import java.util.List;

/**
 * BackgroundInstallControlManager client allows apps to query apps installed in background.
 *
 * <p>Any applications that was installed without an accompanying installer UI activity paired
 * with recorded user interaction event is considered background installed. This is determined by
 * analysis of user-activity logs.
 *
 * <p>Warning: BackgroundInstallControl should not be considered a reliable or accurate
 * determination of background install application. Consumers can use this as a supplementary
 * signal, but must perform additional due diligence to confirm the install nature of the package.
 *
 * @hide
 */
@FlaggedApi(Flags.FLAG_BIC_CLIENT)
@SystemApi(client = PRIVILEGED_APPS)
@SystemService(Context.BACKGROUND_INSTALL_CONTROL_SERVICE)
public final class BackgroundInstallControlManager {

    private static final String TAG = "BackgroundInstallControlManager";
    private static IBackgroundInstallControlService sService;
    private final Context mContext;

    BackgroundInstallControlManager(Context context) {
        mContext = context;
    }

    private static IBackgroundInstallControlService getService() {
        if (sService == null) {
            sService =
                    IBackgroundInstallControlService.Stub.asInterface(
                            ServiceManager.getService(Context.BACKGROUND_INSTALL_CONTROL_SERVICE));
        }
        return sService;
    }

    /**
     * Returns a full list of {@link PackageInfo} of apps currently installed that are considered
     * installed in the background.
     *
     * <p>Refer to top level doc {@link BackgroundInstallControlManager} for more details on
     * background-installed applications.
     * <p>
     *
     * @param flags - Flags will be used to call
     * {@link PackageManager#getInstalledPackages(PackageInfoFlags)} to retrieve installed packages.
     * @return A list of packages retrieved from {@link PackageManager} with non-background
     * installed app filter applied.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_BIC_CLIENT)
    @SystemApi
    @RequiresPermission(QUERY_ALL_PACKAGES)
    public @NonNull List<PackageInfo> getBackgroundInstalledPackages(
            @PackageManager.PackageInfoFlagsBits long flags) {
        try {
            return getService()
                    .getBackgroundInstalledPackages(flags, mContext.getUserId())
                    .getList();
        } catch (SecurityException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
+0 −14
Original line number Diff line number Diff line
@@ -1603,20 +1603,6 @@ public final class SystemServiceRegistry {
                    }
                });

        // DO NOT do a flag check like this unless the flag is read-only.
        // (because this code is executed during preload in zygote.)
        // If the flag is mutable, the check should be inside CachedServiceFetcher.
        if (Flags.bicClient()) {
            registerService(Context.BACKGROUND_INSTALL_CONTROL_SERVICE,
                    BackgroundInstallControlManager.class,
                    new CachedServiceFetcher<BackgroundInstallControlManager>() {
                        @Override
                        public BackgroundInstallControlManager createService(ContextImpl ctx) {
                            return new BackgroundInstallControlManager(ctx);
                        }
                    });
        }

        sInitializing = true;
        try {
            // Note: the following functions need to be @SystemApis, once they become mainline
+0 −9
Original line number Diff line number Diff line
package: "android.app"

flag {
     namespace: "background_install_control"
     name: "bic_client"
     description: "System API for background install control."
     is_fixed_read_only: true
     bug: "287507984"
}
+1 −10
Original line number Diff line number Diff line
@@ -16,20 +16,11 @@

package android.content.pm;


import android.content.pm.ParceledListSlice;
import android.os.IRemoteCallback;

/**
 * {@hide}
 */
interface IBackgroundInstallControlService {
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest.permission.QUERY_ALL_PACKAGES)")
    ParceledListSlice getBackgroundInstalledPackages(long flags, int userId);

    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(allOf = {android.Manifest.permission.QUERY_ALL_PACKAGES, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})")
    void registerBackgroundInstallCallback(IRemoteCallback callback);

    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(allOf = {android.Manifest.permission.QUERY_ALL_PACKAGES, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})")
    void unregisterBackgroundInstallCallback(IRemoteCallback callback);
}
Loading