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

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

Merge "Only show smart actions for whitelisted apps in lock task mode."

parents f278d267 5a4fc212
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.shared.system;

import static android.app.ActivityManager.LOCK_TASK_MODE_LOCKED;
import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
import static android.app.ActivityManager.LOCK_TASK_MODE_PINNED;
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
@@ -463,6 +464,17 @@ public class ActivityManagerWrapper {
        }
    }

    /**
     * @return whether lock task mode is active in kiosk-mode (not screen pinning).
     */
    public boolean isLockTaskKioskModeActive() {
        try {
            return ActivityTaskManager.getService().getLockTaskModeState() == LOCK_TASK_MODE_LOCKED;
        } catch (RemoteException e) {
            return false;
        }
    }

    /**
     * Shows a voice session identified by {@code token}
     * @return true if the session was shown, false otherwise
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 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.
 */

package com.android.systemui.shared.system;

import android.app.AppGlobals;
import android.app.admin.DevicePolicyManager;

/**
 * Wrapper for {@link DevicePolicyManager}.
 */
public class DevicePolicyManagerWrapper {
    private static final DevicePolicyManagerWrapper sInstance = new DevicePolicyManagerWrapper();

    private static final DevicePolicyManager sDevicePolicyManager =
            AppGlobals.getInitialApplication().getSystemService(DevicePolicyManager.class);

    private DevicePolicyManagerWrapper() { }

    public static DevicePolicyManagerWrapper getInstance() {
        return sInstance;
    }

    /**
     * Returns whether the given package is allowed to run in Lock Task mode.
     */
    public boolean isLockTaskPermitted(String pkg) {
        return sDevicePolicyManager.isLockTaskPermitted(pkg);
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.ResolveInfoFlags;
import android.content.pm.ResolveInfo;
import android.os.RemoteException;
import android.os.UserHandle;

import java.util.List;

@@ -40,6 +42,8 @@ public class PackageManagerWrapper {
        return sInstance;
    }

    private PackageManagerWrapper() {}

    /**
     * @return the activity info for a given {@param componentName} and {@param userId}.
     */
@@ -65,4 +69,19 @@ public class PackageManagerWrapper {
            return null;
        }
    }

    /**
     * Determine the best Activity to perform for a given Intent.
     */
    public ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags) {
        final String resolvedType =
                intent.resolveTypeIfNeeded(AppGlobals.getInitialApplication().getContentResolver());
        try {
            return mIPackageManager.resolveIntent(
                    intent, resolvedType, flags, UserHandle.getCallingUserId());
        } catch (RemoteException e) {
            e.printStackTrace();
            return null;
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ import com.android.systemui.power.PowerUI;
import com.android.systemui.privacy.PrivacyItemController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
import com.android.systemui.shared.system.PackageManagerWrapper;
import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.NotificationListener;
@@ -285,6 +288,9 @@ public class Dependency extends SystemUI {
    @Nullable
    @Inject @Named(LEAK_REPORT_EMAIL_NAME) Lazy<String> mLeakReportEmail;
    @Inject Lazy<ClockManager> mClockManager;
    @Inject Lazy<ActivityManagerWrapper> mActivityManagerWrapper;
    @Inject Lazy<DevicePolicyManagerWrapper> mDevicePolicyManagerWrapper;
    @Inject Lazy<PackageManagerWrapper> mPackageManagerWrapper;

    @Inject
    public Dependency() {
@@ -452,6 +458,9 @@ public class Dependency extends SystemUI {
                mForegroundServiceNotificationListener::get);
        mProviders.put(ClockManager.class, mClockManager::get);
        mProviders.put(PrivacyItemController.class, mPrivacyItemController::get);
        mProviders.put(ActivityManagerWrapper.class, mActivityManagerWrapper::get);
        mProviders.put(DevicePolicyManagerWrapper.class, mDevicePolicyManagerWrapper::get);
        mProviders.put(PackageManagerWrapper.class, mPackageManagerWrapper::get);


        // TODO(b/118592525): to support multi-display , we start to add something which is
+21 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.systemui.plugins.PluginInitializerImpl;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.shared.plugins.PluginManagerImpl;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.DevicePolicyManagerWrapper;
import com.android.systemui.shared.system.PackageManagerWrapper;
import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
@@ -181,4 +184,22 @@ public class DependencyProvider {
            @Named(MAIN_HANDLER_NAME) Handler mainHandler) {
        return new AutoHideController(context, mainHandler);
    }

    @Singleton
    @Provides
    public ActivityManagerWrapper provideActivityManagerWrapper() {
        return ActivityManagerWrapper.getInstance();
    }

    @Singleton
    @Provides
    public DevicePolicyManagerWrapper provideDevicePolicyManagerWrapper() {
        return DevicePolicyManagerWrapper.getInstance();
    }

    @Singleton
    @Provides
    public PackageManagerWrapper providePackageManagerWrapper() {
        return PackageManagerWrapper.getInstance();
    }
}
Loading