summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/AppPicker.java
diff options
context:
space:
mode:
authorSvet Ganov <svetoslavganov@google.com>2015-05-13 10:39:35 -0700
committerSvetoslav <svetoslavganov@google.com>2015-05-13 15:45:03 -0700
commit02e65a181ae3b8b757b520f599b2678d06ce0c2f (patch)
tree30b0354d16a68b666eaf6fbf3fbb7833b83ed617 /src/com/android/settings/AppPicker.java
parent0c3d8f1c0f869f5faa4b828e118f8717c8f77d40 (diff)
downloadpackages_apps_Settings-02e65a181ae3b8b757b520f599b2678d06ce0c2f.zip
packages_apps_Settings-02e65a181ae3b8b757b520f599b2678d06ce0c2f.tar.gz
packages_apps_Settings-02e65a181ae3b8b757b520f599b2678d06ce0c2f.tar.bz2
Access mock location is no longer a runtime permission - settings
The access mock location is no longer a runtime permission. It is a signature protected one that apps cannot get but the fact they request it means they want to inject location into the system. Now the user gets to choose the current mock location app in developer options from the apps that request the mock location permission. The access to mock location is no longer guarded by the permisson but from a new app op which is off by default and the settiings UI sets it to enabled only for the currently selected mock location app. bug:21078873 Change-Id: I6555179ecf0cc37d9bb857e9dfb3b04c091ea612
Diffstat (limited to 'src/com/android/settings/AppPicker.java')
-rw-r--r--src/com/android/settings/AppPicker.java52
1 files changed, 46 insertions, 6 deletions
diff --git a/src/com/android/settings/AppPicker.java b/src/com/android/settings/AppPicker.java
index d525427..2447bcb 100644
--- a/src/com/android/settings/AppPicker.java
+++ b/src/com/android/settings/AppPicker.java
@@ -22,6 +22,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
import com.android.settings.applications.AppViewHolder;
import android.app.ListActivity;
@@ -40,10 +42,20 @@ import android.widget.ListView;
public class AppPicker extends ListActivity {
private AppListAdapter mAdapter;
+ public static final String EXTRA_REQUESTIING_PERMISSION
+ = "com.android.settings.extra.REQUESTIING_PERMISSION";
+ public static final String EXTRA_DEBUGGABLE = "com.android.settings.extra.DEBUGGABLE";
+
+ private String mPermissionName;
+ private boolean mDebuggableOnly;
+
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ mPermissionName = getIntent().getStringExtra(EXTRA_REQUESTIING_PERMISSION);
+ mDebuggableOnly = getIntent().getBooleanExtra(EXTRA_DEBUGGABLE, false);
+
mAdapter = new AppListAdapter(this);
if (mAdapter.getCount() <= 0) {
finish();
@@ -89,13 +101,41 @@ public class AppPicker extends ListActivity {
if (ai.uid == Process.SYSTEM_UID) {
continue;
}
- // On a user build, we only allow debugging of apps that
- // are marked as debuggable. Otherwise (for platform development)
- // we allow all apps.
- if ((ai.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0
- && "user".equals(Build.TYPE)) {
- continue;
+
+ // Filter out apps that are not debuggable if required.
+ if (mDebuggableOnly) {
+ // On a user build, we only allow debugging of apps that
+ // are marked as debuggable. Otherwise (for platform development)
+ // we allow all apps.
+ if ((ai.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0
+ && "user".equals(Build.TYPE)) {
+ continue;
+ }
+ }
+
+ // Filter out apps that do not request the permission if required.
+ if (mPermissionName != null) {
+ boolean requestsPermission = false;
+ try {
+ PackageInfo pi = getPackageManager().getPackageInfo(ai.packageName,
+ PackageManager.GET_PERMISSIONS);
+ if (pi.requestedPermissions == null) {
+ continue;
+ }
+ for (String requestedPermission : pi.requestedPermissions) {
+ if (requestedPermission.equals(mPermissionName)) {
+ requestsPermission = true;
+ break;
+ }
+ }
+ if (!requestsPermission) {
+ continue;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ continue;
+ }
}
+
MyApplicationInfo info = new MyApplicationInfo();
info.info = ai;
info.label = info.info.loadLabel(getPackageManager()).toString();