Forums - Snpe phone support

2 posts / 0 new
Last post
Snpe phone support
Danziv
Join Date: 6 Aug 18
Posts: 2
Posted: Sun, 2018-09-16 06:57

Hi i've tried to run the snpe tutorial on my xiomi mi 8, and im getting the errors in the images i uploaded below.

my questions are as followes:

1. Is this problem known and what is the solution?

2. what phones are compatible with the snpe tutorial?

3.  Are there options/software we need to enable/install (on the phone) to make the tutorial work?

 

 

 

 

https://ibb.co/f0BYEz

https://ibb.co/i20PnK

https://ibb.co/mhYrHK

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Fri, 2019-08-09 05:18

Hi Danziv,

1. Android 8.0 (API level 26) and above now require a valid ContentProvider that is defined for the authority in all URIs. Defining a valid ContentProvider with relevant permissions will help defend your app against content changes from malicious apps, and prevent you from leaking potentially private data to malicious apps.

Please make following changes in Image-Classifiers application to resolve the Security Exception

a. Create a Java file CustomContentProvider.java in the src folder. Add the following code:

public class CustomContentProvider extends ContentProvider  {
    public static final String CONTENT_PROVIDER_AUTHORITY = "com.qualcomm.qti.snpe.imageclassifiers.CustomContentProvider";
    @Override
    public boolean onCreate() {
        return true;
    }
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        return null;
    }
    @Override
    public String getType(Uri uri) {
        return null;
    }
    @Override
    public Uri insert(Uri uri, ContentValues values) {
        return null;
    }
    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        return 0;
    }
    @Override
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        return 0;
    }
    public static Uri getUri() {
        Uri outputUri = Model.MODELS_URI;
        Uri.Builder builder = new Uri.Builder()
                .authority(CONTENT_PROVIDER_AUTHORITY)
                .scheme("file")
                .path(outputUri.getPath())
                .query(outputUri.getQuery())
                .fragment(outputUri.getFragment());
        return builder.build();
    }
}

b.Add the provider in manifest.java inside application tag.

<provider
    android:name=".CustomContentProvider"
    android:authorities="com.qualcomm.qti.snpe.imageclassifiers.CustomContentProvider"
    android:enabled="true"
    android:grantUriPermissions="true"
    android:exported="false">
</provider>

c. Invoke CustomContentProvider.getUri() method in ModelCatalogueFragmentController.java class and replace Model.MODELS_URI with Uri got from  CustomContentProvider class.

@Override
protected void onViewAttached(final ModelCatalogueFragment view) {
    view.setExtractingModelMessageVisible(true);
    final ContentResolver contentResolver = mContext.getContentResolver();
    Uri outputUri = CustomContentProvider.getUri();
    contentResolver.registerContentObserver(Uri.withAppendedPath(
            outputUri, Model.INVALID_ID), false, mModelExtractionFailedObserver);
    contentResolver.registerContentObserver(outputUri, true, mModelExtractionObserver);
    startModelsExtraction();
    loadModels();
}

These changes to the code will help you to resolve Security Exception of Content Provider.

2. Please go through the following link to find the list of Supported Snapdragon devices https://developer.qualcomm.com/docs/snpe/overview.html

3. No softwares/options are required to make the tutorial work.

I hope this helps!

Thank You.

*/

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.