java – How to check if a given package is disabled or not and then show toast message accordingly?

I’m making an app where it uses intent to send data to another app. In case, the other app, which is supposed to receive data from my app, is not installed on users’s device then it redirects user to play store with toast message asking user to install it. I used “if else” to achieve this. It worked all good until I found that if the other app is disabled by user (OEM installed app which can’t be uninstalled) , then my app crashes. In such a condition, I want to let user know that the app is disabled by them and ask them to enable it (through toast message). How can I achieve this?

Here is my complete code :

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);



    // Creates button view which is connected to a view in the XML layout, which gets triggered on touching the view.
    TextView textView = (TextView) findViewById(R.id.location);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            // Use package name which we want to check
            boolean isAppInstalled = appInstalledOrNot("com.google.android.apps.maps");


            if(isAppInstalled){

                Uri gmmIntentUri = Uri.parse("geo:00,0000,00,0000");
                Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
                mapIntent.setPackage("com.google.android.apps.maps");
                startActivity(mapIntent);

            } else {
                Uri uri2 = Uri.parse("market://details?id=com.google.android.apps.maps");
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri2);
                Toast.makeText(MainActivity.this, "Google Maps not Installed", Toast.LENGTH_SHORT).show();
                startActivity(goToMarket);
            }
        }


    });
    
}

private boolean appInstalledOrNot(String uri) {
    PackageManager pm = getPackageManager();
    try {
        pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
    }

    return false;
}

}

openssl – How do you manually decrypt RSA oaep-mgf1p XML message?

I have a problem similar to the previous post and used the steps from here, and I got this error at the last step.

*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
bad decrypt

What I am missing?

The XML message I am working on is attached below:

<ocf:encryption xmlns:ocf="urn:oasis:names:tc:opendocument:xmlns:container">
  <EncryptedKey Id="key-4b1dae5e-3d45-4c72-b527-c9503b894187" xmlns="http://www.w3.org/2001/04/xmlenc#">
    <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" />
    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
      <KeyName>CN=engine.simple.com</KeyName>
    </KeyInfo>
    <CipherData>
      <CipherValue>W2+3...jfXIKNdjv5z==</CipherValue>
    </CipherData>
  </EncryptedKey>
  <EncryptedData ocf:full-path="/Images/cover.png" xmlns="http://www.w3.org/2001/04/xmlenc#">
    <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
      <RetrievalMethod URI="#key-4b1dae5e-3d45-4c72-b527-c9503b894187" Type="http://www.w3.org/2001/04/xmlenc#EncryptedKey" />
    </KeyInfo>
    <CipherData>
      <CipherReference URI="/Images/cover.png" />
    </CipherData>
    <EncryptionProperties>
      <EncryptionProperty>
        <Compression Method="0" OriginalLength="42681" xmlns="http://www.idpf.org/2016/encryption#compression" />
      </EncryptionProperty>
    </EncryptionProperties>
  </EncryptedData>

malware – How to determine if a PC is safe after receiving a suspicious email message

I was checking my gmail account spam folder and I noticed an email sent by a known sender.

I thought it was flagged as spam by mistake so I opened it. Then I realized the content is the same as another email I sent the same person about a month ago. Even the subject is the same.

The sender’s name is correct, but I checked the headers and the actual address is not the sender’s. I checked it on various blacklist search engines but apparently it came clean, WHOIS has redacted data for privacy reasons but it seems to be just a case of spoofing.

The message also has an encrypted .zip file attached that was not present in the original mail. In the message there’s a password to open the .zip file but there’s no way I’m going to open the thing on my PC.

The mail content is pretty spooky, though. I mean, it’s an email I sent and supposedly only the receiver and me knew about it. I want to make sure there’s nothing wrong with my account/devices. I’m wondering if the mail was “stolen” through malware on one of my devices, or on the other person’s. We both used gmail accounts.

I safely store my passwords using an appropriate encryption software (KeePass) and have 2FA enabled, I’m pretty cautious when browsing and checking my mail (stuff like checking link urls before opening them). The other person, on the other hand, stores his passwords on a plain text file (I literally saw him open it), so I suppose his security could be pretty lacking.

What should I do in this situation? How could I inspect the content of the .zip file without exposing my machine and/or my personal data? I was thinking of installing some linux distro on a virtual machine to check it out. Should I download the file on my PC and transfer it on the machine? Or should I open gmail from inside the machine itself and download the attachment? I’m worrying that the former method could expose my PC, while the latter could allow the collection of personal data.

javascript – Error message when launching android emulator

I tried launch my app in React Native with npx react-native run-android on terminal and this error happen

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.    
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warning 
Picked up _JAVA_OPTIONS: -Xmx512M        

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.        
-----------
* Where:
Build file 'C:UsersmikaeDesktopAppDentistaandroidappbuild.gradle' line: 87

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not read script 'C:UsersmikaeDesktopAppDentistanode_modulesexpo-updatesscriptscreate-manifest-android.gradle' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 45s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details. 
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Picked up _JAVA_OPTIONS: -Xmx512M

I wanna start and install my application on Android emulator, but this error always happen when I try. This says something is missing, but I don’t know what. I didn’t find the same problem as mine elsewhere on the internet

c++ – Rendering a texture with SDL2 causes “Invalid texture” error message

When SDL_RenderCopy() gets called, it fails and SDL_GetError()returns the error “Invalid texture”.

Here’s my code:

main.cpp

#include "Game.cpp"
#include <iostream>

using namespace std;

int main(int argc, char* args()) {
    
    try {

        Game game("Test", 1280, 720, 60);
        GameObject object("Immagine.bmp");
        game.addObject(object);
        game.run();
    }
    catch(const char* message) {

        cerr<<message;
    }

    return 0;
}

Game.cpp

#include "GameGraphics.cpp"

class Game {

    private:
        bool running;
        GameGraphics* graphics;
        vector<GameObject> objects;

    public:
        Game(const char* title, int width, int height, int targetFps) {

            running = false;

            if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {

                throw SDL_GetError(); 
            }

            try {

                graphics = new GameGraphics(title, width, height, targetFps);
            }
            catch(const char* message) {

                SDL_Quit();
                throw;
            }
        }

        void addObject(GameObject& object) {

            objects.push_back(object);
            graphics->loadTexture(object);
        }

        void run() {

            running = true;

            while(running) {

                SDL_Event e;

                if(SDL_PollEvent(&e)) {

                    if(e.type == SDL_QUIT) {

                        running = false;
                    }
                }

                graphics->render(objects);
            }
        }
};

GameGraphics.cpp

#include <SDL2/SDL.h>
#include <vector>
#include "GameObject.cpp"
#include <iostream>

using namespace std;
class GameGraphics {

    private:
        int targetFps, ticksPerFrame;
        SDL_Renderer* renderer;
        SDL_Window* window;

    public:
        GameGraphics(const char* title, int width, int height, int targetFps) {

            if(SDL_WasInit(SDL_INIT_EVERYTHING) < 0) {

                throw "Can't construct GameGraphics object without initializing SDL first";
            }

            window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);

            if(window == NULL) {

                throw SDL_GetError();
            }

            renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

            if(renderer == NULL) {

                SDL_DestroyWindow(window);
                throw SDL_GetError();
            }
        }

        void render(vector<GameObject>& objects) {

            if(SDL_RenderClear(renderer)) {

                throw SDL_GetError();
            }

            for(auto it = objects.begin(); it != objects.end(); ++it) {

                GameObject object = *it;
                
                if(SDL_RenderCopy(renderer, object.getTexture(), NULL, NULL) == -1) {

                    throw SDL_GetError();
                }
            }

            SDL_RenderPresent(renderer);
        }

        void loadTexture(GameObject& object) {

            SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, object.getSurface());
            
            if(texture == NULL) {

                throw SDL_GetError();
            }

            object.setTexture(texture);
        }
};

GameObject.cpp

#include <SDL2/SDL.h>
#include <string.h>

class GameObject {

    private:
        SDL_Surface* surface;
        SDL_Texture* texture;

    public:
        GameObject(const char* bmpFile) {

            char* basePath = strcat(SDL_GetBasePath(), "resources/images/");
            surface = SDL_LoadBMP(strcat(basePath, bmpFile));

            if(surface == NULL) {

                throw SDL_GetError();
            }

            texture = NULL;
        }

        void setSurface(SDL_Surface* surface) {

            this->surface = surface;
        }

        void setTexture(SDL_Texture* texture) {

            this->texture = texture;
        }

        SDL_Surface* getSurface() {

            return surface;
        }

        SDL_Texture* getTexture() {

            return texture;
        }
};

I’m really new to C++ (coming from C, Java, Python, Javascript/Typescript) and I think I might be getting something wrong about the mechanism of passing an object by reference. What I suspect that’s happening is that in GameGraphics::loadTexture() the formal parameter object is being treated as if its value is just a copy of the actual parameter (basically, as if I was passing it by value). So when the texture member of object is modified, I’m just modifying the copy, not a reference to an external object. So when SDL_RenderCopy() gets invoked (inside GameGraphics::render()), it gets a NULL instead of a pointer to the texture to render, therefore the error gets printed.
But according to countless sources I’ve read through the last few hours, this is the correct way to pass an object by reference. What am I getting wrong then?

Magento 2.3.2 Product Export Message: “Message is added to queue, wait to get your file soon”

Try to fix Following way..

Open below file

vendor/magento/module-import-export/Controller/Adminhtml/Export/Export.php

and replace below function

public function execute()
{
    if ($this->getRequest()->getPost(ExportModel::FILTER_ELEMENT_GROUP)) {
        try {
            $params = $this->getRequest()->getParams();
            $model = $this->_objectManager->create(MagentoImportExportModelExport::class);
            $model->setData($this->getRequest()->getParams());
            $this->sessionManager->writeClose();

            return $this->fileFactory->create(
                $model->getFileName(),
                $model->export(),
                MagentoFrameworkAppFilesystemDirectoryList::VAR_DIR,
                $model->getContentType()
            );

            /** @var ExportInfoFactory $dataObject */
            $dataObject = $this->exportInfoFactory->create(
                $params('file_format'),
                $params('entity'),
                $params('export_filter')
            );

            $this->messagePublisher->publish('import_export.export', $dataObject);
            $this->messageManager->addSuccessMessage(
                __('Message is added to queue, wait to get your file soon')
            );
        } catch (Exception $e) {
            $this->_objectManager->get(PsrLogLoggerInterface::class)->critical($e);
            $this->messageManager->addError(__('Please correct the data sent value.'));
        }
    } else {
        $this->messageManager->addError(__('Please correct the data sent value.'));
    }
    /** @var MagentoBackendModelViewResultRedirect $resultRedirect */
    $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
    $resultRedirect->setPath('adminhtml/*/index');
    return $resultRedirect;
}

Please don’t forget to clear cache after change in files

validation – showing yup validator custom error message

I’m trying to change yup error message

age must be a number type, but the final value was: NaN (cast from
the value "").

to something like this

please check this field

currently I’m using yup setLocale as the error message provider

export const yupLocale = {
mixed: {
    default: 'Não é válido',
    required: 'harus diisi'
},
number: {
    min: 'minimal ${min} karakter'
},
string: {
    email: 'email',
    min: ({ min }) => ({ key: 'minLength', options: { count: min } }),
    max: ({ max }) => ({ key: 'maxLength', options: { count: max } }),
}

};

where and what property should I add to my yuplocale object ?