mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
PackageManager: implement resolveActivity
This commit is contained in:
parent
955113f110
commit
f03f3106e7
1 changed files with 43 additions and 4 deletions
|
@ -19,6 +19,7 @@ package android.content.pm;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -1834,6 +1835,14 @@ public class PackageManager {
|
||||||
case "android.permission.READ_EXTERNAL_STORAGE":
|
case "android.permission.READ_EXTERNAL_STORAGE":
|
||||||
case "com.google.android.c2dm.permission.SEND":
|
case "com.google.android.c2dm.permission.SEND":
|
||||||
return PERMISSION_GRANTED;
|
return PERMISSION_GRANTED;
|
||||||
|
// only tell the app that it can access location if it *actually* can
|
||||||
|
// (until we find apps that refuse to launch without being lied to anyway)
|
||||||
|
case "android.permission.ACCESS_FINE_LOCATION":
|
||||||
|
case "android.permission.ACCESS_COARSE_LOCATION":
|
||||||
|
if(System.getenv("ATL_UGLY_ENABLE_LOCATION") != null)
|
||||||
|
return PERMISSION_GRANTED;
|
||||||
|
else
|
||||||
|
return PERMISSION_DENIED;
|
||||||
default:
|
default:
|
||||||
System.out.println("PackageManager.checkPermission: >" + permName + "< not handled\n");
|
System.out.println("PackageManager.checkPermission: >" + permName + "< not handled\n");
|
||||||
return PERMISSION_DENIED;
|
return PERMISSION_DENIED;
|
||||||
|
@ -2142,7 +2151,34 @@ public class PackageManager {
|
||||||
* @see #GET_RESOLVED_FILTER
|
* @see #GET_RESOLVED_FILTER
|
||||||
*/
|
*/
|
||||||
public ResolveInfo resolveActivity(Intent intent, int flags) {
|
public ResolveInfo resolveActivity(Intent intent, int flags) {
|
||||||
return new ResolveInfo();
|
ResolveInfo info = null;
|
||||||
|
ActivityInfo activity_info = null;
|
||||||
|
|
||||||
|
if (intent.getComponent() != null) {
|
||||||
|
for (PackageParser.Activity activity: Context.pkg.activities) {
|
||||||
|
if (intent.getComponent().getClassName() == activity.className)
|
||||||
|
activity_info = activity.info;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (PackageParser.Activity activity: Context.pkg.activities) {
|
||||||
|
for (PackageParser.IntentInfo intentInfo: activity.intents) {
|
||||||
|
if (intentInfo.matchAction(intent.getAction())) {
|
||||||
|
activity_info = activity.info;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activity_info == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
info = new ResolveInfo();
|
||||||
|
info.activityInfo.exported = true;
|
||||||
|
info.activityInfo = activity_info;
|
||||||
|
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2200,9 +2236,12 @@ public class PackageManager {
|
||||||
*/
|
*/
|
||||||
public List<ResolveInfo> queryIntentActivities(Intent intent,
|
public List<ResolveInfo> queryIntentActivities(Intent intent,
|
||||||
int flags) {
|
int flags) {
|
||||||
ResolveInfo info = new ResolveInfo();
|
/* FIXME - we may need to return more than one */
|
||||||
info.activityInfo.exported = true;
|
ResolveInfo info = resolveActivity(intent, flags);
|
||||||
return Arrays.asList(info);
|
if (info != null)
|
||||||
|
return Arrays.asList(info);
|
||||||
|
else
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue