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

Commit 17e9266c authored by Sumedh Sen's avatar Sumedh Sen
Browse files

Replace hidden APIs with new SystemAPIs

In order to make PackageInstaller an updatable app, we need to migrate
it away from any hidden APIs and implement new SystemApis.

Test: atest CtsContentTestCases:PackageManagerTest
Bug: 239722738

Change-Id: I26f6d153035e25ab2d1e74452962863f6772df34
parent 1c6b5ff5
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
import android.util.Log;

/**
@@ -33,8 +32,7 @@ public class PackageInstalledReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Settings.Global.getInt(context.getContentResolver(),
                Settings.Global.SHOW_NEW_APP_INSTALLED_NOTIFICATION_ENABLED, 0) == 0) {
        if (!context.getPackageManager().shouldShowNewAppInstalledNotification()) {
            return;
        }

+5 −3
Original line number Diff line number Diff line
@@ -332,21 +332,23 @@ public class PackageInstallerActivity extends AlertActivity {
            final int sessionId = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID,
                    -1 /* defaultValue */);
            final SessionInfo info = mInstaller.getSessionInfo(sessionId);
            if (info == null || !info.sealed || info.resolvedBaseCodePath == null) {
            final String resolvedBaseCodePath = intent.getStringExtra(
                    PackageInstaller.EXTRA_RESOLVED_BASE_PATH);
            if (info == null || !info.isSealed() || resolvedBaseCodePath == null) {
                Log.w(TAG, "Session " + mSessionId + " in funky state; ignoring");
                finish();
                return;
            }

            mSessionId = sessionId;
            packageSource = Uri.fromFile(new File(info.resolvedBaseCodePath));
            packageSource = Uri.fromFile(new File(resolvedBaseCodePath));
            mOriginatingURI = null;
            mReferrerURI = null;
        } else if (PackageInstaller.ACTION_CONFIRM_PRE_APPROVAL.equals(action)) {
            final int sessionId = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID,
                    -1 /* defaultValue */);
            final SessionInfo info = mInstaller.getSessionInfo(sessionId);
            if (info == null || !info.isPreapprovalRequested) {
            if (info == null || !info.getIsPreApprovalRequested()) {
                Log.w(TAG, "Session " + mSessionId + " in funky state; ignoring");
                finish();
                return;
+1 −2
Original line number Diff line number Diff line
@@ -135,8 +135,7 @@ public class UninstallFinish extends BroadcastReceiver {
                        UserHandle otherBlockingUserHandle = null;
                        for (int i = 0; i < userHandles.size(); ++i) {
                            final UserHandle handle = userHandles.get(i);
                            if (packageManager.getBlockUninstallForUser(appInfo.packageName,
                                    handle.getIdentifier())) {
                            if (packageManager.canUserUninstall(appInfo.packageName, handle)) {
                                otherBlockingUserHandle = handle;
                                break;
                            }
+1 −2
Original line number Diff line number Diff line
@@ -190,8 +190,7 @@ public class UninstallAppProgress extends Activity {
                        UserHandle otherBlockingUserHandle = null;
                        for (int i = 0; i < userHandles.size(); ++i) {
                            final UserHandle handle = userHandles.get(i);
                            if (packageManager.getBlockUninstallForUser(packageName,
                                    handle.getIdentifier())) {
                            if (packageManager.canUserUninstall(packageName, handle)) {
                                otherBlockingUserHandle = handle;
                                break;
                            }
+4 −0
Original line number Diff line number Diff line
@@ -2579,6 +2579,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                        : PackageInstaller.ACTION_CONFIRM_INSTALL);
        intent.setPackage(mPm.getPackageInstallerPackageName());
        intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, sessionId);
        synchronized (mLock) {
            intent.putExtra(PackageInstaller.EXTRA_RESOLVED_BASE_PATH,
                    mResolvedBaseFile != null ? mResolvedBaseFile.getAbsolutePath() : null);
        }

        sendOnUserActionRequired(mContext, target, sessionId, intent);
    }