Search in sources :

Example 1 with ACCESS_FINE_LOCATION

use of android.Manifest.permission.ACCESS_FINE_LOCATION in project android_packages_apps_GmsCore by microg.

the class SelfCheckFragment method prepareSelfCheckList.

@Override
protected void prepareSelfCheckList(List<SelfCheckGroup> checks) {
    checks.add(new RomSpoofSignatureChecks());
    checks.add(new InstalledPackagesChecks());
    if (SDK_INT >= 23) {
        List<String> permissions = new ArrayList<>();
        permissions.add(ACCESS_COARSE_LOCATION);
        permissions.add(ACCESS_FINE_LOCATION);
        if (SDK_INT >= 29) {
            permissions.add(ACCESS_BACKGROUND_LOCATION);
        }
        permissions.add(READ_EXTERNAL_STORAGE);
        permissions.add(WRITE_EXTERNAL_STORAGE);
        permissions.add(GET_ACCOUNTS);
        permissions.add(READ_PHONE_STATE);
        permissions.add(RECEIVE_SMS);
        checks.add(new PermissionCheckGroup(permissions.toArray(new String[0])) {

            @Override
            public void doChecks(Context context, ResultCollector collector) {
                super.doChecks(context, collector);
                PackageManager pm = context.getPackageManager();
                try {
                    PermissionInfo info = pm.getPermissionInfo("android.permission.SYSTEM_ALERT_WINDOW", 0);
                    CharSequence permLabel = info.loadLabel(pm);
                    collector.addResult(context.getString(org.microg.tools.ui.R.string.self_check_name_permission, permLabel), Settings.canDrawOverlays(context) ? Result.Positive : Result.Negative, context.getString(org.microg.tools.ui.R.string.self_check_resolution_permission), fragment -> {
                        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
                        startActivityForResult(intent, 42);
                    });
                } catch (Exception e) {
                    Log.w("SelfCheckPerms", e);
                }
            }
        });
    }
    if (SDK_INT >= Build.VERSION_CODES.M) {
        checks.add(new SystemChecks());
    }
// checks.add(new NlpOsCompatChecks());
// checks.add(new NlpStatusChecks());
}
Also used : Context(android.content.Context) Context(android.content.Context) PermissionInfo(android.content.pm.PermissionInfo) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) ACCESS_FINE_LOCATION(android.Manifest.permission.ACCESS_FINE_LOCATION) Uri(android.net.Uri) PermissionCheckGroup(org.microg.tools.selfcheck.PermissionCheckGroup) ACCESS_COARSE_LOCATION(android.Manifest.permission.ACCESS_COARSE_LOCATION) Intent(android.content.Intent) SDK_INT(android.os.Build.VERSION.SDK_INT) ArrayList(java.util.ArrayList) LOLLIPOP_MR1(android.os.Build.VERSION_CODES.LOLLIPOP_MR1) READ_EXTERNAL_STORAGE(android.Manifest.permission.READ_EXTERNAL_STORAGE) InstalledPackagesChecks(org.microg.tools.selfcheck.InstalledPackagesChecks) Fragment(androidx.fragment.app.Fragment) Settings(android.provider.Settings) Build(android.os.Build) Log(android.util.Log) AbstractSettingsActivity(org.microg.tools.ui.AbstractSettingsActivity) READ_SMS(android.Manifest.permission.READ_SMS) PermissionGroupInfo(android.content.pm.PermissionGroupInfo) AbstractSelfCheckFragment(org.microg.tools.ui.AbstractSelfCheckFragment) GET_ACCOUNTS(android.Manifest.permission.GET_ACCOUNTS) LayoutInflater(android.view.LayoutInflater) SelfCheckGroup(org.microg.tools.selfcheck.SelfCheckGroup) WRITE_EXTERNAL_STORAGE(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) RECEIVE_SMS(android.Manifest.permission.RECEIVE_SMS) List(java.util.List) READ_PHONE_STATE(android.Manifest.permission.READ_PHONE_STATE) RomSpoofSignatureChecks(org.microg.tools.selfcheck.RomSpoofSignatureChecks) ACCESS_BACKGROUND_LOCATION(android.Manifest.permission.ACCESS_BACKGROUND_LOCATION) SystemChecks(org.microg.tools.selfcheck.SystemChecks) ArrayList(java.util.ArrayList) RomSpoofSignatureChecks(org.microg.tools.selfcheck.RomSpoofSignatureChecks) Intent(android.content.Intent) PackageManager(android.content.pm.PackageManager) PermissionInfo(android.content.pm.PermissionInfo) SystemChecks(org.microg.tools.selfcheck.SystemChecks) PermissionCheckGroup(org.microg.tools.selfcheck.PermissionCheckGroup) InstalledPackagesChecks(org.microg.tools.selfcheck.InstalledPackagesChecks)

Example 2 with ACCESS_FINE_LOCATION

use of android.Manifest.permission.ACCESS_FINE_LOCATION in project Osmand by osmandapp.

the class RequestPermissionScreen method onGetTemplate.

@NonNull
@Override
public Template onGetTemplate() {
    List<String> permissions = new ArrayList<>();
    permissions.add(ACCESS_FINE_LOCATION);
    String message = getCarContext().getString(R.string.location_access_request_title);
    OnClickListener listener = ParkedOnlyOnClickListener.create(() -> getCarContext().requestPermissions(permissions, (approved, rejected) -> {
        if (!approved.isEmpty()) {
            LocationPermissionCheckCallback locationPermissionCheckCallback = mLocationPermissionCheckCallback;
            if (locationPermissionCheckCallback != null) {
                locationPermissionCheckCallback.onPermissionGranted();
            }
        }
        finish();
    }));
    Action action = new Action.Builder().setTitle(getCarContext().getString(R.string.location_access_request_action)).setBackgroundColor(CarColor.GREEN).setOnClickListener(listener).build();
    return new MessageTemplate.Builder(message).addAction(action).setHeaderAction(Action.APP_ICON).build();
}
Also used : MessageTemplate(androidx.car.app.model.MessageTemplate) ACCESS_FINE_LOCATION(android.Manifest.permission.ACCESS_FINE_LOCATION) NonNull(androidx.annotation.NonNull) OnClickListener(androidx.car.app.model.OnClickListener) R(net.osmand.plus.R) CarColor(androidx.car.app.model.CarColor) Template(androidx.car.app.model.Template) ArrayList(java.util.ArrayList) List(java.util.List) Nullable(androidx.annotation.Nullable) ParkedOnlyOnClickListener(androidx.car.app.model.ParkedOnlyOnClickListener) CarContext(androidx.car.app.CarContext) Action(androidx.car.app.model.Action) Screen(androidx.car.app.Screen) MessageTemplate(androidx.car.app.model.MessageTemplate) Action(androidx.car.app.model.Action) ArrayList(java.util.ArrayList) OnClickListener(androidx.car.app.model.OnClickListener) ParkedOnlyOnClickListener(androidx.car.app.model.ParkedOnlyOnClickListener) NonNull(androidx.annotation.NonNull)

Example 3 with ACCESS_FINE_LOCATION

use of android.Manifest.permission.ACCESS_FINE_LOCATION in project GmsCore by microg.

the class SelfCheckFragment method prepareSelfCheckList.

@Override
protected void prepareSelfCheckList(List<SelfCheckGroup> checks) {
    checks.add(new RomSpoofSignatureChecks());
    checks.add(new InstalledPackagesChecks());
    if (SDK_INT >= 23) {
        List<String> permissions = new ArrayList<>();
        permissions.add(ACCESS_COARSE_LOCATION);
        permissions.add(ACCESS_FINE_LOCATION);
        if (SDK_INT >= 29) {
            permissions.add(ACCESS_BACKGROUND_LOCATION);
        }
        permissions.add(READ_EXTERNAL_STORAGE);
        permissions.add(WRITE_EXTERNAL_STORAGE);
        permissions.add(GET_ACCOUNTS);
        permissions.add(READ_PHONE_STATE);
        permissions.add(RECEIVE_SMS);
        checks.add(new PermissionCheckGroup(permissions.toArray(new String[0])) {

            @Override
            public void doChecks(Context context, ResultCollector collector) {
                super.doChecks(context, collector);
                PackageManager pm = context.getPackageManager();
                try {
                    PermissionInfo info = pm.getPermissionInfo("android.permission.SYSTEM_ALERT_WINDOW", 0);
                    CharSequence permLabel = info.loadLabel(pm);
                    collector.addResult(context.getString(org.microg.tools.ui.R.string.self_check_name_permission, permLabel), Settings.canDrawOverlays(context) ? Result.Positive : Result.Negative, context.getString(org.microg.tools.ui.R.string.self_check_resolution_permission), fragment -> {
                        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
                        startActivityForResult(intent, 42);
                    });
                } catch (Exception e) {
                    Log.w("SelfCheckPerms", e);
                }
            }
        });
    }
    if (SDK_INT >= Build.VERSION_CODES.M) {
        checks.add(new SystemChecks());
    }
// checks.add(new NlpOsCompatChecks());
// checks.add(new NlpStatusChecks());
}
Also used : Context(android.content.Context) Context(android.content.Context) PermissionInfo(android.content.pm.PermissionInfo) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) ACCESS_FINE_LOCATION(android.Manifest.permission.ACCESS_FINE_LOCATION) Uri(android.net.Uri) PermissionCheckGroup(org.microg.tools.selfcheck.PermissionCheckGroup) ACCESS_COARSE_LOCATION(android.Manifest.permission.ACCESS_COARSE_LOCATION) Intent(android.content.Intent) SDK_INT(android.os.Build.VERSION.SDK_INT) ArrayList(java.util.ArrayList) LOLLIPOP_MR1(android.os.Build.VERSION_CODES.LOLLIPOP_MR1) READ_EXTERNAL_STORAGE(android.Manifest.permission.READ_EXTERNAL_STORAGE) InstalledPackagesChecks(org.microg.tools.selfcheck.InstalledPackagesChecks) Fragment(androidx.fragment.app.Fragment) Settings(android.provider.Settings) Build(android.os.Build) Log(android.util.Log) AbstractSettingsActivity(org.microg.tools.ui.AbstractSettingsActivity) READ_SMS(android.Manifest.permission.READ_SMS) PermissionGroupInfo(android.content.pm.PermissionGroupInfo) AbstractSelfCheckFragment(org.microg.tools.ui.AbstractSelfCheckFragment) GET_ACCOUNTS(android.Manifest.permission.GET_ACCOUNTS) LayoutInflater(android.view.LayoutInflater) SelfCheckGroup(org.microg.tools.selfcheck.SelfCheckGroup) WRITE_EXTERNAL_STORAGE(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) RECEIVE_SMS(android.Manifest.permission.RECEIVE_SMS) List(java.util.List) READ_PHONE_STATE(android.Manifest.permission.READ_PHONE_STATE) RomSpoofSignatureChecks(org.microg.tools.selfcheck.RomSpoofSignatureChecks) ACCESS_BACKGROUND_LOCATION(android.Manifest.permission.ACCESS_BACKGROUND_LOCATION) SystemChecks(org.microg.tools.selfcheck.SystemChecks) ArrayList(java.util.ArrayList) RomSpoofSignatureChecks(org.microg.tools.selfcheck.RomSpoofSignatureChecks) Intent(android.content.Intent) PackageManager(android.content.pm.PackageManager) PermissionInfo(android.content.pm.PermissionInfo) SystemChecks(org.microg.tools.selfcheck.SystemChecks) PermissionCheckGroup(org.microg.tools.selfcheck.PermissionCheckGroup) InstalledPackagesChecks(org.microg.tools.selfcheck.InstalledPackagesChecks)

Example 4 with ACCESS_FINE_LOCATION

use of android.Manifest.permission.ACCESS_FINE_LOCATION in project OsmAnd by osmandapp.

the class RequestPermissionScreen method onGetTemplate.

@NonNull
@Override
public Template onGetTemplate() {
    List<String> permissions = new ArrayList<>();
    permissions.add(ACCESS_FINE_LOCATION);
    String message = getCarContext().getString(R.string.location_access_request_title);
    OnClickListener listener = ParkedOnlyOnClickListener.create(() -> getCarContext().requestPermissions(permissions, (approved, rejected) -> {
        if (!approved.isEmpty()) {
            LocationPermissionCheckCallback locationPermissionCheckCallback = mLocationPermissionCheckCallback;
            if (locationPermissionCheckCallback != null) {
                locationPermissionCheckCallback.onPermissionGranted();
            }
        }
        finish();
    }));
    Action action = new Action.Builder().setTitle(getCarContext().getString(R.string.location_access_request_action)).setBackgroundColor(CarColor.GREEN).setOnClickListener(listener).build();
    return new MessageTemplate.Builder(message).addAction(action).setHeaderAction(Action.APP_ICON).build();
}
Also used : MessageTemplate(androidx.car.app.model.MessageTemplate) ACCESS_FINE_LOCATION(android.Manifest.permission.ACCESS_FINE_LOCATION) NonNull(androidx.annotation.NonNull) OnClickListener(androidx.car.app.model.OnClickListener) R(net.osmand.plus.R) CarColor(androidx.car.app.model.CarColor) Template(androidx.car.app.model.Template) ArrayList(java.util.ArrayList) List(java.util.List) Nullable(androidx.annotation.Nullable) ParkedOnlyOnClickListener(androidx.car.app.model.ParkedOnlyOnClickListener) CarContext(androidx.car.app.CarContext) Action(androidx.car.app.model.Action) Screen(androidx.car.app.Screen) MessageTemplate(androidx.car.app.model.MessageTemplate) Action(androidx.car.app.model.Action) ArrayList(java.util.ArrayList) OnClickListener(androidx.car.app.model.OnClickListener) ParkedOnlyOnClickListener(androidx.car.app.model.ParkedOnlyOnClickListener) NonNull(androidx.annotation.NonNull)

Example 5 with ACCESS_FINE_LOCATION

use of android.Manifest.permission.ACCESS_FINE_LOCATION in project forgerock-android-sdk by ForgeRock.

the class DeviceProfileCallbackFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_device_profile_callback, container, false);
    message = view.findViewById(R.id.message);
    progressBar = view.findViewById(R.id.collectingDeviceProfileProgress);
    if (node.getCallbacks().size() == 1) {
        // auto submit if there is one node
        progressBar.setVisibility(View.VISIBLE);
        message.setText(callback.getMessage());
    } else {
        progressBar.setVisibility(GONE);
        message.setVisibility(GONE);
    }
    if (callback.isLocation()) {
        if (ContextCompat.checkSelfPermission(getContext(), ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // We don't have permission.
            if (shouldShowRequestPermissionRationale(ACCESS_FINE_LOCATION)) {
                AlertDialog alertDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialogTheme).setMessage(R.string.request_location_rationale).setPositiveButton("Proceed", (dialog, which) -> requestLocationPermission()).setNegativeButton("Deny", (dialog, which) -> proceed()).create();
                alertDialog.show();
            } else {
                requestLocationPermission();
            }
        } else {
            // Location permission is granted, proceed.
            proceed();
        }
    } else {
        proceed();
    }
    return view;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) DeviceProfileCallback(org.forgerock.android.auth.callback.DeviceProfileCallback) PackageManager(android.content.pm.PackageManager) ProgressBar(android.widget.ProgressBar) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) ACCESS_FINE_LOCATION(android.Manifest.permission.ACCESS_FINE_LOCATION) FRListener(org.forgerock.android.auth.FRListener) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) R(org.forgerock.android.auth.ui.R) GONE(android.view.View.GONE) Fragment(androidx.fragment.app.Fragment) View(android.view.View) ContextCompat(androidx.core.content.ContextCompat) TextView(android.widget.TextView) View(android.view.View)

Aggregations

ACCESS_FINE_LOCATION (android.Manifest.permission.ACCESS_FINE_LOCATION)7 NonNull (androidx.annotation.NonNull)5 List (java.util.List)5 ACCESS_COARSE_LOCATION (android.Manifest.permission.ACCESS_COARSE_LOCATION)4 PackageManager (android.content.pm.PackageManager)4 Context (android.content.Context)3 Intent (android.content.Intent)3 LayoutInflater (android.view.LayoutInflater)3 Nullable (androidx.annotation.Nullable)3 ArrayList (java.util.ArrayList)3 FRListener (org.forgerock.android.auth.FRListener)3 ACCESS_BACKGROUND_LOCATION (android.Manifest.permission.ACCESS_BACKGROUND_LOCATION)2 GET_ACCOUNTS (android.Manifest.permission.GET_ACCOUNTS)2 READ_EXTERNAL_STORAGE (android.Manifest.permission.READ_EXTERNAL_STORAGE)2 READ_PHONE_STATE (android.Manifest.permission.READ_PHONE_STATE)2 READ_SMS (android.Manifest.permission.READ_SMS)2 RECEIVE_SMS (android.Manifest.permission.RECEIVE_SMS)2 WRITE_EXTERNAL_STORAGE (android.Manifest.permission.WRITE_EXTERNAL_STORAGE)2 PermissionGroupInfo (android.content.pm.PermissionGroupInfo)2 PermissionInfo (android.content.pm.PermissionInfo)2