am 7560c256
: Merge "Add hidden API for querying available \'home\' activities" into klp-dev
* commit '7560c256ecacb5fa3904ec5c957e88331328f38b': Add hidden API for querying available 'home' activities
This commit is contained in:
@ -1250,6 +1250,16 @@ final class ApplicationPackageManager extends PackageManager {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName getHomeActivities(List<ResolveInfo> outActivities) {
|
||||
try {
|
||||
return mPM.getHomeActivities(outActivities);
|
||||
} catch (RemoteException e) {
|
||||
// Should never happen!
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComponentEnabledSetting(ComponentName componentName,
|
||||
int newState, int flags) {
|
||||
|
@ -233,6 +233,12 @@ interface IPackageManager {
|
||||
int getPreferredActivities(out List<IntentFilter> outFilters,
|
||||
out List<ComponentName> outActivities, String packageName);
|
||||
|
||||
/**
|
||||
* Report the set of 'Home' activity candidates, plus (if any) which of them
|
||||
* is the current "always use this one" setting.
|
||||
*/
|
||||
ComponentName getHomeActivities(out List<ResolveInfo> outHomeCandidates);
|
||||
|
||||
/**
|
||||
* As per {@link android.content.pm.PackageManager#setComponentEnabledSetting}.
|
||||
*/
|
||||
|
@ -3026,6 +3026,13 @@ public abstract class PackageManager {
|
||||
public abstract int getPreferredActivities(List<IntentFilter> outFilters,
|
||||
List<ComponentName> outActivities, String packageName);
|
||||
|
||||
/**
|
||||
* Ask for the set of available 'home' activities and the current explicit
|
||||
* default, if any.
|
||||
* @hide
|
||||
*/
|
||||
public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
|
||||
|
||||
/**
|
||||
* Set the enabled setting for a package component (activity, receiver, service, provider).
|
||||
* This setting will override any enabled state which may have been set by the component in its
|
||||
|
@ -2466,10 +2466,17 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
}
|
||||
|
||||
String getHomePackageName() {
|
||||
Intent getHomeIntent() {
|
||||
Intent intent = new Intent(mTopAction, mTopData != null ? Uri.parse(mTopData) : null);
|
||||
intent.setComponent(mTopComponent);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
|
||||
String getHomePackageName() {
|
||||
Intent intent = getHomeIntent();
|
||||
ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, mCurrentUserId);
|
||||
if (aInfo != null) {
|
||||
final String homePackageName = aInfo.applicationInfo.packageName;
|
||||
@ -2495,13 +2502,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
// error message and don't try to start anything.
|
||||
return false;
|
||||
}
|
||||
Intent intent = new Intent(
|
||||
mTopAction,
|
||||
mTopData != null ? Uri.parse(mTopData) : null);
|
||||
intent.setComponent(mTopComponent);
|
||||
if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
}
|
||||
Intent intent = getHomeIntent();
|
||||
ActivityInfo aInfo =
|
||||
resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
|
||||
if (aInfo != null) {
|
||||
|
@ -9716,10 +9716,6 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
throw new IllegalArgumentException(
|
||||
"replacePreferredActivity expects filter to have only 1 action.");
|
||||
}
|
||||
if (filter.countCategories() != 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"replacePreferredActivity expects filter to have only 1 category.");
|
||||
}
|
||||
if (filter.countDataAuthorities() != 0
|
||||
|| filter.countDataPaths() != 0
|
||||
|| filter.countDataSchemes() != 0
|
||||
@ -9756,8 +9752,11 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
removed = new ArrayList<PreferredActivity>();
|
||||
}
|
||||
removed.add(pa);
|
||||
Log.i(TAG, "Removing preferred activity " + pa.mPref.mComponent + ":");
|
||||
filter.dump(new LogPrinter(Log.INFO, TAG), " ");
|
||||
if (DEBUG_PREFERRED) {
|
||||
Slog.i(TAG, "Removing preferred activity "
|
||||
+ pa.mPref.mComponent + ":");
|
||||
filter.dump(new LogPrinter(Log.INFO, TAG), " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removed != null) {
|
||||
@ -9876,6 +9875,28 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName getHomeActivities(List<ResolveInfo> allHomeCandidates) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
|
||||
final int callingUserId = UserHandle.getCallingUserId();
|
||||
List<ResolveInfo> list = queryIntentActivities(intent, null, 0, callingUserId);
|
||||
ResolveInfo preferred = findPreferredActivity(intent, null, 0, list, 0,
|
||||
true, false, callingUserId);
|
||||
|
||||
allHomeCandidates.clear();
|
||||
if (list != null) {
|
||||
for (ResolveInfo ri : list) {
|
||||
allHomeCandidates.add(ri);
|
||||
}
|
||||
}
|
||||
return (preferred == null || preferred.activityInfo == null)
|
||||
? null
|
||||
: new ComponentName(preferred.activityInfo.packageName,
|
||||
preferred.activityInfo.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationEnabledSetting(String appPackageName,
|
||||
int newState, int flags, int userId, String callingPackage) {
|
||||
|
@ -46,6 +46,7 @@ import android.content.res.XmlResourceParser;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import java.util.List;
|
||||
@ -543,6 +544,12 @@ public class MockPackageManager extends PackageManager {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide - hidden in superclass */
|
||||
@Override
|
||||
public ComponentName getHomeActivities(List<ResolveInfo> outActivities) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSystemSharedLibraryNames() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
Reference in New Issue
Block a user