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

Commit e740d343 authored by Ricky Wai's avatar Ricky Wai
Browse files

Make PackageInstaller able to receive app installed broadcast

Now system will send an explicit new app installed broadcast
to PackageInstaller.

Bug: 111214100
Test: Able to receive broadcast when new app is installed
Change-Id: I0242f992fd06cc148554bc46d6119c897e03432c
parent b6a2cfbd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -106,6 +106,14 @@
            </intent-filter>
        </receiver>

        <receiver android:name=".PackageInstalledReceiver"
                android:exported="true">
            <intent-filter android:priority="1">
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <data android:scheme="package" />
            </intent-filter>
        </receiver>

        <activity android:name=".UninstallUninstalling"
            android:excludeFromRecents="true"
            android:exported="false" />
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 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 com.android.packageinstaller;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Receive new app installed broadcast and notify user new app installed.
 */
public class PackageInstalledReceiver extends BroadcastReceiver {

    private static final String TAG = "PackageInstalledReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO: Add logic to handle new app installed.
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -1988,6 +1988,14 @@ public class PackageManagerService extends IPackageManager.Stub
                            mRequiredVerifierPackage, null /*finishedReceiver*/,
                            updateUserIds, instantUserIds);
                }
                // If package installer is defined, notify package installer about new
                // app installed
                if (mRequiredInstallerPackage != null) {
                    sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
                            extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND /*flags*/,
                            mRequiredInstallerPackage, null /*finishedReceiver*/,
                            firstUserIds, instantUserIds);
                }
                // Send replaced for users that don't see the package for the first time
                if (update) {