8

I've installed the androidtv-sample-inputs so I can fake some Tv inputs and have some channels and I wanted to get information about that channels, however, when I query to get that information I get an empty cursors.

What i've tried so far is:

TvInputManager tv = (TvInputManager)getApplicationContext().getSystemService(Context.TV_INPUT_SERVICE);

    List<TvInputInfo> list = tv.getTvInputList();

    String[] projection =  {
            TvContract.Channels._ID,
            TvContract.Channels.COLUMN_DISPLAY_NUMBER
    };

    ContentResolver cr = getContentResolver();

    Iterator<TvInputInfo> it = list.iterator();
    while(it.hasNext()) {
        TvInputInfo aux = it.next();
        Uri uri = TvContract.buildChannelsUriForInput(aux.getId());

        Log.d("TAG", uri.toString());
        Log.d("TAG", aux.toString());

        Cursor cur = cr.query(uri, projection, null, null ,null);
        Log.d("TAG", cur.toString());

        if(cur.moveToFirst()) {
            Log.d("TAG", "not empty cursors");
        }

    }

I have already added the uses-permission and I've checked that the tv input are not pass-through.

<uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" />
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" />
<uses-permission android:name="com.android.providers.tv.permission.ACCESS_ALL_EPG_DATA"/>
Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
user1139368
  • 89
  • 1
  • 6

2 Answers2

3

What kind of permission are you using ?

If your application isn't signatureOrSystem, you can only access your own channels and programs from queries to the TV provider. All the queries you're doing are filtered on your package name.

I guess that the information you can retrieve from a channel are restricted to what is accessible from TvInputInfo.

sdex
  • 3,169
  • 15
  • 28
ph0b
  • 14,353
  • 4
  • 43
  • 41
  • I have tried adding this in my manifest: – user1139368 Feb 25 '15 at 16:12
  • I've misspelled it, it's signatureOrSystem and not systemOrSignature. It's the ACCESS_ALL_EPG_DATA that has such protection level. That means it can only be used by applications that are in the Android system image or that are signed with the same certificate as the application that declared the permission. – ph0b Feb 25 '15 at 16:23
  • First of all, what's the difference between "READ_EPG_DATA" and "ACCES_ALL_EPG_DATA". Then how can i read the channels provided by the different Tv inputs? if i can't make my application to be Android system and i can't sign my application with the same certificate as the application that declared the permission i just cannot get that information? I cannot know what channel the user is watching in any moment? – user1139368 Feb 25 '15 at 16:46
  • READ_EPG_DATA and WRITE_EPG_DATA allows you to access the data from the channels and programs, but limited to what you own. ACCESS_ALL_EPG_DATA allows you to access everything. Yes, the TvProvider currently prevents you to get all the channels: https://android.googlesource.com/platform/packages/providers/TvProvider/+/master/src/com/android/providers/tv/TvProvider.java -> `params.setWhere(BaseTvColumns.COLUMN_PACKAGE_NAME + "=?", getCallingPackage_());` is always called. – ph0b Feb 26 '15 at 10:53
  • 1
    That's a shame that TvProdier prevents one to get all the channels. I've seen that sony android TVs don't use Tv app to show live tv from Tv inputs. Do you have any idea if they will provide acces to channel list or current channel list? Thank you very much for your help! – user1139368 Feb 27 '15 at 20:17
  • I don't know much about Sony's implementation but it should be consistent with what's in AOSP, so unless they provide an additional SDK or another unrestricted TvProvider, there isn't much chance that getting access to all the channels would be allowed specifically on their platform. – ph0b Feb 28 '15 at 00:15
0

Additionally to "com.android.providers.tv.xxx" EPG permissions needed in the manifest file, you must sign your .apk ! Otherwise you will see all the TvInput available on your device but none of the channels composing these tvInput (and this, without any error returned ;-)). Android Studio provides this features ('BUILD' menu entry then 'Generate Signed APK') see How to sign an android apk file

Community
  • 1
  • 1
g910
  • 96
  • 3