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

Commit 24c007b3 authored by Sumedh Sen's avatar Sumedh Sen
Browse files

Foundation of Uninstall flow in PiaV2

This introduces the new landing activity for uninstalls and its manifest entry.

Bug: 182205982
Test: builds successfully
Test: No CTS Tests. Flag to use new app is turned off by default

Change-Id: I9f66a5d192a184f8593f7c45bcab9e712b99961a
parent ca5b5c7f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -140,6 +140,14 @@
            </intent-filter>
        </activity>

        <activity android:name=".v2.ui.UninstallLaunch"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:theme="@style/Theme.AlertDialogActivity.NoActionBar"
            android:excludeFromRecents="true"
            android:noHistory="true"
            android:exported="false">
        </activity>

        <receiver android:name=".UninstallEventReceiver"
            android:permission="android.permission.INSTALL_PACKAGES"
            android:exported="false">
+18 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.packageinstaller.television.ErrorFragment;
import com.android.packageinstaller.television.UninstallAlertFragment;
import com.android.packageinstaller.television.UninstallAppProgress;

import com.android.packageinstaller.v2.ui.UninstallLaunch;
import java.util.List;

/*
@@ -80,6 +81,9 @@ public class UninstallerActivity extends Activity {
    private String mPackageName;
    private DialogInfo mDialogInfo;

    // TODO (sumedhsen): Replace with an Android Feature Flag once implemented
    private static final boolean USE_PIA_V2 = false;

    @Override
    public void onCreate(Bundle icicle) {
        getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
@@ -88,6 +92,20 @@ public class UninstallerActivity extends Activity {
        // be stale, if e.g. the app was uninstalled while the activity was destroyed.
        super.onCreate(null);

        if (USE_PIA_V2 && !isTv()) {
            boolean returnResult = getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false);
            Intent piaV2 = new Intent(getIntent());
            piaV2.putExtra(UninstallLaunch.EXTRA_CALLING_PKG_UID, getLaunchedFromUid());
            piaV2.putExtra(UninstallLaunch.EXTRA_CALLING_ACTIVITY_NAME, getCallingActivity());
            if (returnResult) {
                piaV2.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
            }
            piaV2.setClass(this, UninstallLaunch.class);
            startActivity(piaV2);
            finish();
            return;
        }

        int callingUid = getLaunchedFromUid();
        if (callingUid == Process.INVALID_UID) {
            // Cannot reach Package/ActivityManager. Aborting uninstall.
+41 −0
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
 *
 *      https://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.v2.ui;

import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;

public class UninstallLaunch extends FragmentActivity{

    public static final String EXTRA_CALLING_PKG_UID =
        UninstallLaunch.class.getPackageName() + ".callingPkgUid";
    public static final String EXTRA_CALLING_ACTIVITY_NAME =
        UninstallLaunch.class.getPackageName() + ".callingActivityName";
    public static final String TAG = UninstallLaunch.class.getSimpleName();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);

        // Never restore any state, esp. never create any fragments. The data in the fragment might
        // be stale, if e.g. the app was uninstalled while the activity was destroyed.
        super.onCreate(null);
    }
}