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

Commit 3e82bd5b authored by Heemin Seog's avatar Heemin Seog
Browse files

Add ability to hide certain roles and overlay car resources

Bug: 130348508
Test: manual
Change-Id: Iec392e459c7e9d863050a9e9d12b2720c034c2dd
parent 36454356
Loading
Loading
Loading
Loading

res/values/config.xml

0 → 100644
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright 2019 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.
-->

<resources>
    <bool name="config_showBrowserRole">true</bool>
    <bool name="config_showDialerRole">true</bool>
    <bool name="config_showSmsRole">true</bool>
</resources>
+25 −0
Original line number Diff line number Diff line
@@ -227,6 +227,31 @@
            <item type="style" name="PermissionDialog" />
            <!-- END THEMES -->

            <!-- START VISIBILITY CONFIGS -->
            <!-- Assistant role uses: config_showDefaultAssistant -->
            <!-- Home role uses: config_showDefaultHome -->
            <!-- Emergency role uses: config_showDefaultEmergency -->
            <item type="bool" name="config_showBrowserRole" />
            <item type="bool" name="config_showDialerRole" />
            <item type="bool" name="config_showSmsRole" />
            <!-- END VISIBILITY CONFIGS -->

            <!-- START CAR DIMENS -->
            <item type="dimen" name="car_action_bar_height" />
            <item type="dimen" name="car_margin" />
            <item type="dimen" name="car_icon_size" />
            <!-- END CAR DIMENS -->

            <!-- START CAR STYLES -->
            <item type="style" name="CarPreferenceFragment" />
            <item type="style" name="CarPreferenceFragmentList" />
            <!-- END CAR STYLES -->

            <!-- START CAR THEMES -->
            <item type="style" name="CarSettings" />
            <item type="style" name="CarPreferenceTheme" />
            <!-- END CAR THEMES -->

        </policy>

    </overlayable>
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.packageinstaller.role.utils.UserUtils;
import com.android.permissioncontroller.R;

import java.util.ArrayList;
import java.util.List;
@@ -113,4 +114,10 @@ public class BrowserRoleBehavior implements RoleBehavior {
        }
        return new ArrayList<>(packageNames);
    }

    @Override
    public boolean isVisibleAsUser(@NonNull Role role, @NonNull UserHandle user,
            @NonNull Context context) {
        return context.getResources().getBoolean(R.bool.config_showBrowserRole);
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -72,4 +72,10 @@ public class DialerRoleBehavior implements RoleBehavior {
    public String getFallbackHolder(@NonNull Role role, @NonNull Context context) {
        return ExclusiveDefaultHolderMixin.getDefaultHolder(role, "config_defaultDialer", context);
    }

    @Override
    public boolean isVisibleAsUser(@NonNull Role role, @NonNull UserHandle user,
            @NonNull Context context) {
        return context.getResources().getBoolean(R.bool.config_showDialerRole);
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.annotation.Nullable;

import com.android.packageinstaller.permission.utils.CollectionUtils;
import com.android.packageinstaller.role.utils.UserUtils;
import com.android.permissioncontroller.R;

import java.util.List;

@@ -79,4 +80,10 @@ public class SmsRoleBehavior implements RoleBehavior {
        return EncryptionUnawareConfirmationMixin.getConfirmationMessage(role, packageName,
                context);
    }

    @Override
    public boolean isVisibleAsUser(@NonNull Role role, @NonNull UserHandle user,
            @NonNull Context context) {
        return context.getResources().getBoolean(R.bool.config_showSmsRole);
    }
}