Search in sources :

Example 1 with TrustDatabaseHelper

use of com.android.launcher3.lineage.trust.db.TrustDatabaseHelper in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepModelDelegate method recreatePredictors.

@WorkerThread
private void recreatePredictors() {
    destroyPredictors();
    if (!mActive) {
        return;
    }
    Context context = mApp.getContext();
    AppPredictionManager apm = context.getSystemService(AppPredictionManager.class);
    if (apm == null) {
        return;
    }
    TrustDatabaseHelper trustData = mApp.getTrustData();
    int totalPackageHidden = trustData != null ? trustData.getTotalPackageHidden() : 0;
    registerPredictor(mAllAppsState, apm.createAppPredictionSession(new AppPredictionContext.Builder(context).setUiSurface("home").setPredictedTargetCount(mIDP.numDatabaseAllAppsColumns + totalPackageHidden).build()));
    // TODO: get bundle
    registerPredictor(mHotseatState, apm.createAppPredictionSession(new AppPredictionContext.Builder(context).setUiSurface("hotseat").setPredictedTargetCount(mIDP.numDatabaseHotseatIcons + totalPackageHidden).setExtras(convertDataModelToAppTargetBundle(context, mDataModel)).build()));
    registerWidgetsPredictor(apm.createAppPredictionSession(new AppPredictionContext.Builder(context).setUiSurface("widgets").setPredictedTargetCount(NUM_OF_RECOMMENDED_WIDGETS_PREDICATION).build()));
}
Also used : Context(android.content.Context) AppPredictionContext(android.app.prediction.AppPredictionContext) TrustDatabaseHelper(com.android.launcher3.lineage.trust.db.TrustDatabaseHelper) AppPredictionManager(android.app.prediction.AppPredictionManager) AppPredictionContext(android.app.prediction.AppPredictionContext) WorkerThread(androidx.annotation.WorkerThread)

Example 2 with TrustDatabaseHelper

use of com.android.launcher3.lineage.trust.db.TrustDatabaseHelper in project android_packages_apps_Launcher3 by crdroidandroid.

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    TrustDatabaseHelper db = TrustDatabaseHelper.getInstance(launcher);
    ComponentName cn = item.getTargetComponent();
    boolean isProtected = cn != null && db.isPackageProtected(cn.getPackageName());
    if (isProtected) {
        launcher.startActivitySafelyAuth(v, intent, item);
    } else {
        launcher.startActivitySafely(v, intent, item);
    }
}
Also used : TrustDatabaseHelper(com.android.launcher3.lineage.trust.db.TrustDatabaseHelper) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ComponentName(android.content.ComponentName) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

TrustDatabaseHelper (com.android.launcher3.lineage.trust.db.TrustDatabaseHelper)2 PendingIntent (android.app.PendingIntent)1 AppPredictionContext (android.app.prediction.AppPredictionContext)1 AppPredictionManager (android.app.prediction.AppPredictionManager)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 WorkerThread (androidx.annotation.WorkerThread)1 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)1 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)1 PackageManagerHelper (com.android.launcher3.util.PackageManagerHelper)1