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

Commit c735b2fe authored by herriojr's avatar herriojr Committed by Steve Kondik
Browse files

Added Changes for Custom Resolver Activity

In order to get a custom resolver activity working, we needed to allow
our application to be the resolver (CMResolver). Also added in extra
EventLogTag for when an intent cannot be resolved.

Change-Id: Iab3fc344b70a41e135eb295b542c0cbcf0d4d2ce

Add System Property for Resolver

In order to distribute the custom Resolver with capps, we need
a way of updating which resolver to use.  This property will do
the trick.

Change-Id: I2ba27324599df1f2bb0200b2172fd9421edf8279

Fixed Possible Resolver Infinite Loop

There was a possibility in the case where the ApplicationSuggestions
are being used and the Resolver isn't replaced that an infinite loop
of the resolver starting itself up and finishing its current instance
would happen.  This will fix this case by no returning the Resolver
in the query if we aren't currently using a Custom Resolver.

This means that any custom resolver used needs to handle the case where
it gets returned a reference to itself when there are no other activities
to handle the intent otherwise.

Change-Id: I559a188f5011445e4ba91738b30d7ed367398406

Fix FileManager Interaction

After much thought about this last night, I decided that we can't
handle making sure the situation in
http://developer.android.com/training/basics/intents/sending.html#StartActivity
can actually be handled without possibly making a bad experience in
other situations (such as FileManager doing its own resolving).

This will now only pop it up when we query a function which could
possibly return the resolver like how it was before  the previous change.

Change-Id: I2e458a80d3e3f7c358949c210b5372933910ac7a
Issue-Id: CYNGNOS-1152
parent 7f492ee8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3899,7 +3899,8 @@ public final class ActivityManagerService extends ActivityManagerNative
            if (sourceRecord == null) {
                throw new SecurityException("Called with bad activity token: " + resultTo);
            }
            if (!sourceRecord.info.packageName.equals("android")) {
            if (!sourceRecord.info.packageName.equals("android") &&
                    !sourceRecord.info.packageName.equals("org.cyanogenmod.resolver")) {
                throw new SecurityException(
                        "Must be called from an activity that is declared in the android package");
            }
+5 −0
Original line number Diff line number Diff line
@@ -1509,6 +1509,11 @@ public final class ActivityStackSupervisor implements DisplayListener {
        if (err == ActivityManager.START_SUCCESS && intent.getComponent() == null) {
            // We couldn't find a class that can handle the given Intent.
            // That's the end of that!
            final Uri data = intent.getData();
            final String strData = data != null ? data.toSafeString() : null;
            EventLog.writeEvent(EventLogTags.AM_INTENT_NOT_RESOLVED, callingPackage,
                    intent.getAction(), intent.getType(), strData, intent.getFlags());

            err = ActivityManager.START_INTENT_NOT_RESOLVED;
        }

+2 −0
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ option java_package com.android.server.am
30036 am_provider_lost_process (User|1|5),(Package Name|3),(UID|1|5),(Name|3)
# The activity manager gave up on a new process taking too long to start
30037 am_process_start_timeout (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3)
# The activity manager was unable to resolve the intent to an Activity
30038 am_intent_not_resolved (Calling Package Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5)

# Unhandled exception
30039 am_crash (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Exception|3),(Message|3),(File|3),(Line|1|5)
+25 −3
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ import static com.android.internal.util.ArrayUtils.removeInt;
import android.Manifest;
import cyanogenmod.app.suggest.AppSuggestManager;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.AppGlobals;
@@ -1973,9 +1975,11 @@ public class PackageManagerService extends IPackageManager.Stub {
            mRestoredSettings = mSettings.readLPw(this, sUserManager.getUsers(false),
                    mSdkVersion, mOnlyCore);
            String customResolverActivity = Resources.getSystem().getString(
            String customResolverActivity = SystemProperties.get("ro.custom.resolver.activity");
            if (TextUtils.isEmpty(customResolverActivity)) {
                customResolverActivity = Resources.getSystem().getString(
                        R.string.config_customResolverActivity);
            }
            if (TextUtils.isEmpty(customResolverActivity)) {
                customResolverActivity = null;
            } else {
@@ -4370,6 +4374,17 @@ public class PackageManagerService extends IPackageManager.Stub {
                if (ri.activityInfo.metaData == null) ri.activityInfo.metaData = new Bundle();
                ri.activityInfo.metaData.putBoolean(Intent.METADATA_DOCK_HOME, true);
                return ri;
            } else if (shouldIncludeResolveActivity(intent)) {
                if (userId != 0) {
                    ResolveInfo ri = new ResolveInfo(mResolveInfo);
                    ri.activityInfo = new ActivityInfo(ri.activityInfo);
                    ri.activityInfo.applicationInfo = new ApplicationInfo(
                            ri.activityInfo.applicationInfo);
                    ri.activityInfo.applicationInfo.uid = UserHandle.getUid(userId,
                            UserHandle.getAppId(ri.activityInfo.applicationInfo.uid));
                    return ri;
                }
                return mResolveInfo;
            }
        }
        return null;
@@ -4630,6 +4645,13 @@ public class PackageManagerService extends IPackageManager.Stub {
        return null;
    }
    private boolean shouldIncludeResolveActivity(Intent intent) {
        synchronized(mPackages) {
            AppSuggestManager suggest = AppSuggestManager.getInstance(mContext);
            return mResolverReplaced && (suggest != null) ? suggest.handles(intent) : false;
        }
    }
    @Override
    public List<ResolveInfo> queryIntentActivities(Intent intent,
            String resolvedType, int flags, int userId) {