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

Commit 91a79398 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5616725 from ec50d8a6 to qt-qpr1-release

Change-Id: I1559250bff165526822f319b6a5d7659490b0aa6
parents 181fd7c1 ec50d8a6
Loading
Loading
Loading
Loading
+41 −36
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class RuntimePermissionsUpgradeController {
    private static final String LOG_TAG = RuntimePermissionsUpgradeController.class.getSimpleName();

    // The latest version of the runtime permissions database
    private static final int LATEST_VERSION = 4;
    private static final int LATEST_VERSION = 5;

    private RuntimePermissionsUpgradeController() {
        /* do nothing - hide constructor */
@@ -116,41 +116,7 @@ class RuntimePermissionsUpgradeController {
        }

        if (currentVersion == 1) {
            if (sdkUpgradedFromP) {
                Log.i(LOG_TAG, "Expanding location permissions");

                for (int i = 0; i < appCount; i++) {
                    final PackageInfo app = apps.get(i);
                    if (app.requestedPermissions == null) {
                        continue;
                    }

                    for (String perm : app.requestedPermissions) {
                        String groupName = Utils.getGroupOfPlatformPermission(perm);

                        if (!TextUtils.equals(groupName, Manifest.permission_group.LOCATION)) {
                            continue;
                        }

                        final AppPermissionGroup group = AppPermissionGroup.create(context, app,
                                perm, false);
                        final AppPermissionGroup bgGroup = group.getBackgroundPermissions();

                        if (group.areRuntimePermissionsGranted()
                                && bgGroup != null
                                && !bgGroup.isUserSet() && !bgGroup.isSystemFixed()
                                && !bgGroup.isPolicyFixed()) {
                            bgGroup.grantRuntimePermissions(group.isUserFixed());
                        }

                        break;
                    }
                }
            } else {
                Log.i(LOG_TAG, "Not expanding location permissions as this is not an upgrade "
                        + "from Android P");
            }

            // moved to step 4->5 as it has to be after the grandfathering of loc bg perms
            currentVersion = 2;
        }

@@ -201,6 +167,45 @@ class RuntimePermissionsUpgradeController {
            currentVersion = 4;
        }

        if (currentVersion == 4) {
            if (sdkUpgradedFromP) {
                Log.i(LOG_TAG, "Expanding location permissions");

                for (int i = 0; i < appCount; i++) {
                    final PackageInfo app = apps.get(i);
                    if (app.requestedPermissions == null) {
                        continue;
                    }

                    for (String perm : app.requestedPermissions) {
                        String groupName = Utils.getGroupOfPlatformPermission(perm);

                        if (!TextUtils.equals(groupName, Manifest.permission_group.LOCATION)) {
                            continue;
                        }

                        final AppPermissionGroup group = AppPermissionGroup.create(context, app,
                                perm, false);
                        final AppPermissionGroup bgGroup = group.getBackgroundPermissions();

                        if (group.areRuntimePermissionsGranted()
                                && bgGroup != null
                                && !bgGroup.isUserSet() && !bgGroup.isSystemFixed()
                                && !bgGroup.isPolicyFixed()) {
                            bgGroup.grantRuntimePermissions(group.isUserFixed());
                        }

                        break;
                    }
                }
            } else {
                Log.i(LOG_TAG, "Not expanding location permissions as this is not an upgrade "
                        + "from Android P");
            }

            currentVersion = 5;
        }

        // XXX: Add new upgrade steps above this point.

        return currentVersion;
+16 −4
Original line number Diff line number Diff line
@@ -24,11 +24,15 @@ import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import com.android.packageinstaller.DeviceUtils;
import com.android.packageinstaller.role.model.Role;
import com.android.packageinstaller.role.model.Roles;
import com.android.packageinstaller.role.ui.auto.AutoSpecialAppAccessFragment;
import com.android.packageinstaller.role.ui.handheld.HandheldSpecialAppAccessFragment;
import com.android.permissioncontroller.R;

/**
 * Activity for a special app access.
@@ -42,7 +46,6 @@ public class SpecialAppAccessActivity extends FragmentActivity {
     *
     * @param roleName the name of the role for the special app access
     * @param context  the context to create the intent
     *
     * @return an intent to start this activity
     */
    @NonNull
@@ -53,6 +56,11 @@ public class SpecialAppAccessActivity extends FragmentActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        if (DeviceUtils.isAuto(this)) {
            // Automotive relies on a different theme. Apply before calling super so that
            // fragments are restored properly on configuration changes.
            setTheme(R.style.CarSettings);
        }
        super.onCreate(savedInstanceState);

        getWindow().addSystemFlags(
@@ -78,8 +86,12 @@ public class SpecialAppAccessActivity extends FragmentActivity {
        }

        if (savedInstanceState == null) {
            HandheldSpecialAppAccessFragment fragment =
                    HandheldSpecialAppAccessFragment.newInstance(roleName);
            Fragment fragment;
            if (DeviceUtils.isAuto(this)) {
                fragment = AutoSpecialAppAccessFragment.newInstance(roleName);
            } else {
                fragment = HandheldSpecialAppAccessFragment.newInstance(roleName);
            }
            getSupportFragmentManager().beginTransaction()
                    .add(android.R.id.content, fragment)
                    .commit();
+15 −2
Original line number Diff line number Diff line
@@ -20,9 +20,13 @@ import android.os.Bundle;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import com.android.packageinstaller.DeviceUtils;
import com.android.packageinstaller.role.ui.auto.AutoSpecialAppAccessListFragment;
import com.android.packageinstaller.role.ui.handheld.HandheldSpecialAppAccessListFragment;
import com.android.permissioncontroller.R;

/**
 * Activity for the list of special app accesses.
@@ -31,14 +35,23 @@ public class SpecialAppAccessListActivity extends FragmentActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        if (DeviceUtils.isAuto(this)) {
            // Automotive relies on a different theme. Apply before calling super so that
            // fragments are restored properly on configuration changes.
            setTheme(R.style.CarSettings);
        }
        super.onCreate(savedInstanceState);

        getWindow().addSystemFlags(
                WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);

        if (savedInstanceState == null) {
            HandheldSpecialAppAccessListFragment fragment =
                    HandheldSpecialAppAccessListFragment.newInstance();
            Fragment fragment;
            if (DeviceUtils.isAuto(this)) {
                fragment = AutoSpecialAppAccessListFragment.newInstance();
            } else {
                fragment = HandheldSpecialAppAccessListFragment.newInstance();
            }
            getSupportFragmentManager().beginTransaction()
                    .add(android.R.id.content, fragment)
                    .commit();
+7 −1
Original line number Diff line number Diff line
@@ -26,12 +26,13 @@ import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;

import com.android.packageinstaller.auto.AutoSettingsFrameFragment;
import com.android.packageinstaller.role.model.Role;
import com.android.packageinstaller.role.ui.DefaultAppChildFragment;
import com.android.permissioncontroller.R;

/** Screen to pick a default app for a particular {@link Role}. */
public class AutoDefaultAppFragment extends DefaultAppFrameFragment implements
public class AutoDefaultAppFragment extends AutoSettingsFrameFragment implements
        DefaultAppChildFragment.Parent {

    private String mRoleName;
@@ -65,6 +66,11 @@ public class AutoDefaultAppFragment extends DefaultAppFrameFragment implements
        mUser = arguments.getParcelable(Intent.EXTRA_USER);
    }

    @Override
    public void onCreatePreferences(Bundle bundle, String s) {
        // Preferences will be added via shared logic in {@link DefaultAppChildFragment}.
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
+7 −1
Original line number Diff line number Diff line
@@ -22,12 +22,13 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.packageinstaller.auto.AutoSettingsFrameFragment;
import com.android.packageinstaller.role.ui.DefaultAppListChildFragment;
import com.android.packageinstaller.role.ui.TwoTargetPreference;
import com.android.permissioncontroller.R;

/** Shows various roles for which a default app can be picked. */
public class AutoDefaultAppListFragment extends DefaultAppFrameFragment implements
public class AutoDefaultAppListFragment extends AutoSettingsFrameFragment implements
        DefaultAppListChildFragment.Parent {

    /** Create a new instance of this fragment. */
@@ -36,6 +37,11 @@ public class AutoDefaultAppListFragment extends DefaultAppFrameFragment implemen
        return new AutoDefaultAppListFragment();
    }

    @Override
    public void onCreatePreferences(Bundle bundle, String s) {
        // Preferences will be added via shared logic in {@link DefaultAppListChildFragment}.
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
Loading