2014-04-30 03:02:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2014 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.launcher3.compat;
|
|
|
|
|
|
|
|
|
|
import android.content.ComponentName;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
2016-05-19 11:19:39 -07:00
|
|
|
import android.content.pm.LauncherApps;
|
2014-04-30 03:02:21 +01:00
|
|
|
import android.graphics.Rect;
|
2016-05-19 11:19:39 -07:00
|
|
|
import android.graphics.drawable.Drawable;
|
2014-04-30 03:02:21 +01:00
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
2014-09-16 15:17:58 +01:00
|
|
|
import com.android.launcher3.Utilities;
|
2016-05-19 11:19:39 -07:00
|
|
|
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
2014-09-16 15:17:58 +01:00
|
|
|
|
2014-04-30 03:02:21 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public abstract class LauncherAppsCompat {
|
|
|
|
|
|
2014-05-02 13:47:11 -07:00
|
|
|
public static final String ACTION_MANAGED_PROFILE_ADDED =
|
|
|
|
|
"android.intent.action.MANAGED_PROFILE_ADDED";
|
|
|
|
|
public static final String ACTION_MANAGED_PROFILE_REMOVED =
|
|
|
|
|
"android.intent.action.MANAGED_PROFILE_REMOVED";
|
2016-04-04 16:13:35 +01:00
|
|
|
public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
|
|
|
|
|
"android.intent.action.MANAGED_PROFILE_AVAILABLE";
|
|
|
|
|
public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
|
|
|
|
|
"android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
|
2014-05-02 13:47:11 -07:00
|
|
|
|
2014-06-30 12:30:31 +01:00
|
|
|
public interface OnAppsChangedCallbackCompat {
|
|
|
|
|
void onPackageRemoved(String packageName, UserHandleCompat user);
|
|
|
|
|
void onPackageAdded(String packageName, UserHandleCompat user);
|
|
|
|
|
void onPackageChanged(String packageName, UserHandleCompat user);
|
|
|
|
|
void onPackagesAvailable(String[] packageNames, UserHandleCompat user, boolean replacing);
|
|
|
|
|
void onPackagesUnavailable(String[] packageNames, UserHandleCompat user, boolean replacing);
|
2016-01-21 19:50:02 +00:00
|
|
|
void onPackagesSuspended(String[] packageNames, UserHandleCompat user);
|
|
|
|
|
void onPackagesUnsuspended(String[] packageNames, UserHandleCompat user);
|
2016-05-19 11:19:39 -07:00
|
|
|
void onShortcutsChanged(String packageName, List<ShortcutInfoCompat> shortcuts,
|
|
|
|
|
UserHandleCompat user);
|
2014-04-30 03:02:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected LauncherAppsCompat() {
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 12:30:31 +01:00
|
|
|
private static LauncherAppsCompat sInstance;
|
|
|
|
|
private static Object sInstanceLock = new Object();
|
|
|
|
|
|
2014-04-30 03:02:21 +01:00
|
|
|
public static LauncherAppsCompat getInstance(Context context) {
|
2014-06-30 12:30:31 +01:00
|
|
|
synchronized (sInstanceLock) {
|
|
|
|
|
if (sInstance == null) {
|
2016-06-23 14:17:24 -07:00
|
|
|
if (Utilities.ATLEAST_LOLLIPOP) {
|
2014-09-15 11:35:00 -07:00
|
|
|
sInstance = new LauncherAppsCompatVL(context.getApplicationContext());
|
2014-06-30 12:30:31 +01:00
|
|
|
} else {
|
2014-09-15 11:35:00 -07:00
|
|
|
sInstance = new LauncherAppsCompatV16(context.getApplicationContext());
|
2014-04-30 03:02:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
2014-06-30 12:30:31 +01:00
|
|
|
return sInstance;
|
2014-04-30 03:02:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract List<LauncherActivityInfoCompat> getActivityList(String packageName,
|
|
|
|
|
UserHandleCompat user);
|
|
|
|
|
public abstract LauncherActivityInfoCompat resolveActivity(Intent intent,
|
|
|
|
|
UserHandleCompat user);
|
2014-06-30 12:30:31 +01:00
|
|
|
public abstract void startActivityForProfile(ComponentName component, UserHandleCompat user,
|
|
|
|
|
Rect sourceBounds, Bundle opts);
|
2014-07-31 11:39:16 +01:00
|
|
|
public abstract void showAppDetailsForProfile(ComponentName component, UserHandleCompat user);
|
2014-06-30 12:30:31 +01:00
|
|
|
public abstract void addOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
|
|
|
|
|
public abstract void removeOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
|
2014-04-30 03:02:21 +01:00
|
|
|
public abstract boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user);
|
|
|
|
|
public abstract boolean isActivityEnabledForProfile(ComponentName component,
|
|
|
|
|
UserHandleCompat user);
|
2016-01-21 19:50:02 +00:00
|
|
|
public abstract boolean isPackageSuspendedForProfile(String packageName, UserHandleCompat user);
|
|
|
|
|
}
|