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

Commit c3fdc3e8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add number of enterprise-installed apps to Privacy Settings page"

parents f665025d 13f569eb
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -8015,6 +8015,11 @@
    <string name="enterprise_privacy_always_on_vpn_work">Always-on VPN turned on in your work profile</string>
    <!-- Label explaining that a global HTTP proxy was set by the admin. [CHAR LIMIT=NONE] -->
    <string name="enterprise_privacy_global_http_proxy">Global HTTP proxy set</string>
    <!-- Label indicating how many apps were installed on the device by the admin. [CHAR LIMIT=NONE] -->
    <plurals name="enterprise_privacy_number_enterprise_installed_packages">
        <item quantity="one"><xliff:g id="count">%d</xliff:g> app installed by your admin</item>
        <item quantity="other"><xliff:g id="count">%d</xliff:g> apps installed by your admin</item>
    </plurals>
    <!-- Preference label for the Photos & Videos storage section. [CHAR LIMIT=50] -->
    <string name="storage_photos_videos">Photos &amp; Videos</string>
+4 −0
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@
                android:title="@string/enterprise_privacy_global_http_proxy"
                settings:allowDividerBelow="true"
                settings:multiLine="true"/>
        <com.android.settings.DividerPreference
                android:key="number_enterprise_installed_packages"
                settings:allowDividerBelow="true"
                settings:multiLine="true"/>
    </PreferenceCategory>

    <PreferenceCategory android:title="@string/enterprise_privacy_device_access_category">
+11 −1
Original line number Diff line number Diff line
@@ -26,11 +26,21 @@ public interface ApplicationFeatureProvider {
     */
    AppHeaderController newAppHeaderController(Fragment fragment, View appHeader);

    /**
     * Count all installed packages, irrespective of install reason.
     */
    public static final int IGNORE_INSTALL_REASON = -1;

    /**
     * Asynchronously calculates the total number of apps installed on the device, across all users
     * and managed profiles.
     *
     * @param installReason Only consider packages with this install reason; may be any install
     *         reason defined in {@link android.content.pm.PackageManager} or
     *         {@link #IGNORE_INSTALL_REASON} to count all packages, irrespective of install reason.
     * @param callback The callback to invoke with the result
     */
    void calculateNumberOfInstalledApps(NumberOfInstalledAppsCallback callback);
    void calculateNumberOfInstalledApps(int installReason, NumberOfInstalledAppsCallback callback);

    /**
     * Callback that receives the total number of packages installed on the device.
+5 −4
Original line number Diff line number Diff line
@@ -42,15 +42,16 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
    }

    @Override
    public void calculateNumberOfInstalledApps(NumberOfInstalledAppsCallback callback) {
        new AllUserInstalledAppCounter(callback).execute();
    public void calculateNumberOfInstalledApps(int installReason,
            NumberOfInstalledAppsCallback callback) {
        new AllUserInstalledAppCounter(installReason, callback).execute();
    }

    private class AllUserInstalledAppCounter extends InstalledAppCounter {
        private NumberOfInstalledAppsCallback mCallback;

        AllUserInstalledAppCounter(NumberOfInstalledAppsCallback callback) {
            super(mContext, ApplicationFeatureProviderImpl.this.mPm);
        AllUserInstalledAppCounter(int installReason, NumberOfInstalledAppsCallback callback) {
            super(mContext, installReason, ApplicationFeatureProviderImpl.this.mPm);
            mCallback = callback;
        }

+13 −2
Original line number Diff line number Diff line
@@ -25,12 +25,24 @@ import java.util.List;

public abstract class InstalledAppCounter extends AppCounter {

    public InstalledAppCounter(Context context, PackageManagerWrapper packageManager) {
    private final int mInstallReason;
    private final PackageManagerWrapper mPackageManager;

    public InstalledAppCounter(Context context, int installReason,
            PackageManagerWrapper packageManager) {
        super(context, packageManager);
        mInstallReason = installReason;
        mPackageManager = packageManager;
    }

    @Override
    protected boolean includeInCount(ApplicationInfo info) {
        final int userId = UserHandle.getUserId(info.uid);
        if (mInstallReason != ApplicationFeatureProvider.IGNORE_INSTALL_REASON
                && mPackageManager.getInstallReason(info.packageName,
                        new UserHandle(userId)) != mInstallReason) {
            return false;
        }
        if ((info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
            return true;
        }
@@ -40,7 +52,6 @@ public abstract class InstalledAppCounter extends AppCounter {
        Intent launchIntent = new Intent(Intent.ACTION_MAIN, null)
                .addCategory(Intent.CATEGORY_LAUNCHER)
                .setPackage(info.packageName);
        int userId = UserHandle.getUserId(info.uid);
        List<ResolveInfo> intents = mPm.queryIntentActivitiesAsUser(
                launchIntent,
                PackageManager.GET_DISABLED_COMPONENTS
Loading