Android Open Source - permission-explorer Action Registry






From Project

Back to project page permission-explorer.

License

The source code is released under:

Copyright (C) 2012 Rui Gon?alves and Daniel Cibr?o Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),...

If you think the Android project permission-explorer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package pt.up.fe.ssin.pexplorer.app;
//from   w w  w .j a  va2 s.c o m
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import pt.up.fe.ssin.pexplorer.actions.AccessFineLocationAction;
import pt.up.fe.ssin.pexplorer.actions.AccessNetworkStateAction;
import pt.up.fe.ssin.pexplorer.actions.ChangeWifiStateAction;
import pt.up.fe.ssin.pexplorer.actions.GetAccountsAction;
import pt.up.fe.ssin.pexplorer.actions.InternetAccessAction;
import pt.up.fe.ssin.pexplorer.actions.PhoneCallAction;
import pt.up.fe.ssin.pexplorer.actions.ReadCalendarAction;
import pt.up.fe.ssin.pexplorer.actions.ReadContactsAction;
import pt.up.fe.ssin.pexplorer.actions.ReadPhoneStateAction;
import pt.up.fe.ssin.pexplorer.actions.RebootAction;
import pt.up.fe.ssin.pexplorer.actions.RetrieveRunningTasksAction;
import pt.up.fe.ssin.pexplorer.actions.SendTestSmsAction;
import pt.up.fe.ssin.pexplorer.actions.ShellCommandAction;
import pt.up.fe.ssin.pexplorer.actions.TakePictureAction;
import pt.up.fe.ssin.pexplorer.actions.VibrateAction;
import pt.up.fe.ssin.pexplorer.actions.WriteCalendarAction;
import pt.up.fe.ssin.pexplorer.actions.WriteExternalStorageAction;
import pt.up.fe.ssin.pexplorer.actions.WriteSettingsAction;

public class ActionRegistry {

    private static ActionRegistry instance;

    public static ActionRegistry getInstance() {
        if (instance == null)
            instance = new ActionRegistry();
        return instance;
    }

    private Map<String, List<PermissionAction>> actions = new HashMap<String, List<PermissionAction>>();

    // register all actions implemented for each permission
    static {
        getInstance().addAction("android.permission.SEND_SMS",
                new SendTestSmsAction());
        getInstance().addAction("android.permission.CALL_PHONE",
                new PhoneCallAction());
        getInstance().addAction("android.permission.READ_CONTACTS",
                new ReadContactsAction());
        getInstance().addAction("android.permission.READ_PHONE_STATE",
                new ReadPhoneStateAction());
        getInstance().addAction("android.permission.ACCESS_FINE_LOCATION",
                new AccessFineLocationAction());
        getInstance().addAction("android.permission.INTERNET",
                new InternetAccessAction());
        getInstance().addAction("android.permission.ACCESS_NETWORK_STATE",
                new AccessNetworkStateAction());
        getInstance().addAction("android.permission.CHANGE_WIFI_STATE",
                new ChangeWifiStateAction());
        getInstance().addAction("android.permission.WRITE_SETTINGS",
                new WriteSettingsAction());
        getInstance().addAction("android.permission.WRITE_EXTERNAL_STORAGE",
                new WriteExternalStorageAction());
        getInstance().addAction("android.permission.VIBRATE",
                new VibrateAction());
        getInstance().addAction("android.permission.CAMERA",
                new TakePictureAction());
        getInstance().addAction("android.permission.READ_CALENDAR",
                new ReadCalendarAction());
        getInstance().addAction("android.permission.WRITE_CALENDAR",
                new WriteCalendarAction());
        getInstance().addAction("android.permission.GET_TASKS",
                new RetrieveRunningTasksAction());
        getInstance().addAction("android.permission.GET_ACCOUNTS",
                new GetAccountsAction());
        getInstance().addAction("com.noshufou.android.su.provider.READ",
                new RebootAction(), new ShellCommandAction());
        getInstance().addAction("com.noshufou.android.su.provider.WRITE",
                new RebootAction(), new ShellCommandAction());
    }

    private ActionRegistry() {
    }

    public List<PermissionAction> getPermissionActions(String permName) {
        if (actions.containsKey(permName))
            return actions.get(permName);

        List<PermissionAction> permActions = new ArrayList<PermissionAction>();
        actions.put(permName, permActions);
        return permActions;
    }

    public void addAction(String permName, PermissionAction... actions) {
        for (PermissionAction action : actions)
            addAction(permName, action, -1);
    }

    public void addAction(String permName, PermissionAction action, int position) {
        List<PermissionAction> permActions;
        if (!actions.containsKey(permName)) {
            permActions = new ArrayList<PermissionAction>();
            actions.put(permName, permActions);
        } else
            permActions = actions.get(permName);

        if (position >= 0)
            permActions.add(position, action);
        else
            permActions.add(action);
    }
}




Java Source Code List

pt.up.fe.ssin.pexplorer.actions.AccessFineLocationAction.java
pt.up.fe.ssin.pexplorer.actions.AccessNetworkStateAction.java
pt.up.fe.ssin.pexplorer.actions.ChangeWifiStateAction.java
pt.up.fe.ssin.pexplorer.actions.GetAccountsAction.java
pt.up.fe.ssin.pexplorer.actions.InternetAccessAction.java
pt.up.fe.ssin.pexplorer.actions.PhoneCallAction.java
pt.up.fe.ssin.pexplorer.actions.ReadCalendarAction.java
pt.up.fe.ssin.pexplorer.actions.ReadContactsAction.java
pt.up.fe.ssin.pexplorer.actions.ReadPhoneStateAction.java
pt.up.fe.ssin.pexplorer.actions.RebootAction.java
pt.up.fe.ssin.pexplorer.actions.RetrieveRunningTasksAction.java
pt.up.fe.ssin.pexplorer.actions.SendTestSmsAction.java
pt.up.fe.ssin.pexplorer.actions.ShellCommandAction.java
pt.up.fe.ssin.pexplorer.actions.TakePictureAction.java
pt.up.fe.ssin.pexplorer.actions.TakePictureActivity.java
pt.up.fe.ssin.pexplorer.actions.VibrateAction.java
pt.up.fe.ssin.pexplorer.actions.WriteCalendarAction.java
pt.up.fe.ssin.pexplorer.actions.WriteExternalStorageAction.java
pt.up.fe.ssin.pexplorer.actions.WriteSettingsAction.java
pt.up.fe.ssin.pexplorer.app.ActionRegistry.java
pt.up.fe.ssin.pexplorer.app.ApplicationListAdapter.java
pt.up.fe.ssin.pexplorer.app.FilterConfigActivity.java
pt.up.fe.ssin.pexplorer.app.Keys.java
pt.up.fe.ssin.pexplorer.app.PermissionAction.java
pt.up.fe.ssin.pexplorer.app.PermissionExplorerActivity.java
pt.up.fe.ssin.pexplorer.app.PermissionInfoActivity.java
pt.up.fe.ssin.pexplorer.app.PermissionListAdapter.java
pt.up.fe.ssin.pexplorer.data.GlobalSchema.java
pt.up.fe.ssin.pexplorer.data.PermissionCatalog.java
pt.up.fe.ssin.pexplorer.data.PermissionDBOperations.java
pt.up.fe.ssin.pexplorer.data.PermissionExplorerContentProvider.java
pt.up.fe.ssin.pexplorer.entities.Contact.java
pt.up.fe.ssin.pexplorer.utils.ApplicationDetailsHelper.java
pt.up.fe.ssin.pexplorer.utils.Pair.java
pt.up.fe.ssin.pexplorer.utils.PermissionUtils.java
pt.up.fe.ssin.pexplorer.utils.ui.AlertDialogHelper.java
pt.up.fe.ssin.pexplorer.utils.ui.CheckedLinearLayout.java
pt.up.fe.ssin.pexplorer.utils.ui.CheckedRelativeLayout.java
pt.up.fe.ssin.pexplorer.utils.ui.FilterTextWatcher.java
pt.up.fe.ssin.pexplorer.utils.ui.InputDialogBuilder.java
pt.up.fe.ssin.pexplorer.utils.ui.SimpleObjectAdapter.java
pt.up.fe.ssin.pexplorer.utils.ui.views.NonEventBlockingScrollView.java