© nds ltd 2010. all rights reserved. refactoring the mmi contribution extending the look and feel

67
© NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Post on 21-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

© NDS Ltd 2010. All rights reserved.

Refactoring the MMI contribution

Extending the look and feel

Page 2: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Reasoning The original contribution from EchoStar works well and

meets MMI requirements

But– Couldn’t easily be re-skinned– Behaviour could not be tailored– Wanted to use elements elsewhere in the Stack

• Very useful basic HTML renderer

2

Page 3: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The Standard MMI displayThe standard display when a single MMI message has been received.

3

Page 4: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The Standard MMI display, thriceHow the display looks after three MMI open messages have been received.

4

Page 5: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The Alternate MMI DisplayA quick re-skin later, and the display looks like this.

5

Page 6: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Redeployment – basicWhen an error is detected in the CableCARD communications, we can display this OSD.

6

Page 7: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Redeployment - advancedThe HTML renderer is now under control of a diagnostics application.

7

Page 8: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

What was changed

Original HTML rendering in

HTMLComponent.java

Data always fetched from CableCARD

Dialog was part of MMIDialog

Flat class structure

Rework HTML rendering now in

MiniBrowser.java with useful interface

Data fetched from abstract UrlGetter

Dialog now separate entity

Added mmi and ui classes to allow inheritance

8

Page 9: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Basic Class Diagram

9

DisplayManager

DisplayManagerImpl DialogMiniBrowser

UrlGetter

CableCardUrlGetter

UrlGetterListener

Page 10: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

How can I add my own? Controlling the display

– Extend DisplayManager and implement these methods

• displayDialog()• dismissDialog()

– Implement [if required] MiniBrowserListener to receive updates in the HTML

• contentUpdated()– Have your own paint()

• Otherwise, it won’t look at all like you thought– Create the extended DisplayManager

• You’ll have to override & extend SystemModuleMgr to instantiate an extended SystemModuleRegistrarImpl that creates your new DisplayManager class

10

Page 11: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

...and... Extend ResidentMmiHandler if you want different

behavior.– We did this to enforce a single dialog

Utilize the methods in MiniBrowser to display help prompts:

– hasLinks()• true if the HTML page has a link that can be

selected– isScrollable()

• true if the HTML page is bigger than the window– hasHistory()

• true if the user has selected any link and therefore can go ‘back’ in the browse history.

– Cleared when navigate() is called– Use navigateBackwards() when back key is

pressed11

Page 12: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Extended Class Diagram

12

SystemManager

+getDisplayManager()

SystemModuleMgr SystemModuleRegistrarImpl

DisplayManager

DisplayManagerImpl

DisplayManagerExImpl SystemModuleExMgr SystemModuleRegistrarExImpl

Page 13: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Word of warning The MMI display behaves like a ‘Well Behaved

Application’– i.e. It informs of focus stolen– But! It doesn’t listen for focus lost

This means that if you decide to remove the ability to clear the MMI display, you may find yourself in a whole new world of hurt as you try to restore focus to the application...

13

Page 14: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Using the MiniBrowser elsewhere Simply create one and give it the data! OK, an example:

UrlGetter urlGetter = CableCardUrlGetter.getSession();MiniBrowser browser = new MiniBrowser(urlGetter);browser.registerMiniBrowserListener(this); // we implement MiniBrowserListener// Now fetch the Applications from the POD... And thenPODApplication application = <PODManager>.getApplications().[<index>]// Set the browser size and color, setBounds(), setBackground() etc.// Add the browser to your own Container / Componentthis.container.add(browser);// And navigate to the app URLbrowser.navigate(application.getURL());

Don’t forget to add key passingpublic void chUpKeyAction() { browser.scrollVertically(MiniBrowser.SCROLL_UP_1_PAGE);}public void selectKeyAction() { // Doesn’t matter if one is not selected, will call contentUpdated() browser.followCurrentLink();}

14

Page 15: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Questions

15

Page 16: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Thanks EchoStar for the original contribution @ NDS

– Tom Gwozdz– Laurentiu Dragan– Madhusmitha Gottipati– Bigi Porinju

@ Cablelabs– Steve Maynard

@ Comcast– Khurram Qureshi

16

Page 17: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

© NDS Ltd 2010. All rights reserved.

TDK

Test Development Environment.

Page 18: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

18

TDK (Test Development Kit) The TDK was created so that Comcast could do

integration testing on the RI set tops. The TDK runs on a computer/set top environment. The TDK is built using Maven. There are two parts to the TDK; the TDK server(Run on

PC) and the TDK app which is run on the set top. The TDK uses TestNG for its reporting and maven for

its execution. The TDK server tells the TDK app what tests to run and

where to get the test classes over a UDP socket connection.

The TDK works on top the Comcast CATS framework .(Comcast proprietary software)

Page 19: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

19

NDS Contribution to the TDK NDS has implemented over 500 test cases Tests around

– Tuning– Recording– User key presses– Time Shift Buffers– Trick Play– DSMCC downloading– Section filtering– Channel maps– Performance– Graphics– …….

Page 20: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

20

After the TDK is built.

mvn clean install : build the entire TDK and run all the tests.

mvn clean install –DskipTests=true : Just build the TDK

Build The TDK.

You can execute individual test cases with the following command

mvn test –Dgroups=TC0003,TC0006,…. Or execute the entire suite mvn test

Page 21: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

21

TDK Execution. TDK tests start to execute. TDK server opens socket to set top running TGShell

app. TDK tells TGShell app what test class to run and where

it can find that class file. TGShell executes the class file and reports the results. Once the TDK run finishes

the TestNG results can be foundin test/target/surefire-report

A detailed report with the testpasses/failures exists there.

Page 22: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

22

What is TGShell. TGShell is the app that is run on the set top. All TGShell does is when launched opens a socket and

waits to be told what to do. TGShell receives instructions from that open socket and

creates class files to be executed from those instructions.

TGShell then sends back the results of the execution over the socket connection.

Page 23: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

23

CI with Hudson. With Hudson the RI can be built on a fixed schedule or

even monitor the SVN/CVS/GIT…. Repoisitory for updates which will then trigger a new build to be preformed on the new src code.

If the RI build is successful another project can then be triggered lets say the TDK to then test the new build.

All automated with build artifact/Test results archiving that can be retrieved at any time.

Page 24: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

24

The End….. Demo Q & A time

Page 25: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

© NDS Ltd 2010. All rights reserved.

Version control with Git and GerritA different way of working with the RI

Page 26: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Question

Who has used Git at work or home before?

26

Page 27: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

What is Git Git is a distributed version control system (DVCS)

– It’s non-centralized nature makes it ideal for loosely coupled, widely distributed projects

Git was originally developed by Linus Torvalds for versioning the Linux kernel

– Now used by a growing number of projects in both open and closed source communities

Git is itself an open source project– Available as source code under GPL– Pre-built packages for all common platforms– Free as in freedom, and free as in beer!

27

Page 28: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

What is Gerrit Gerrit is a web based code review and repository

management tool for Git

Gerrit is developed by Google and is used for the Android project

Gerrit is an open source project and is available as a deployable .war file

For an example have a look at the Android Gerrit– https://review.source.android.com

28

Page 29: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

What is wrong with Subversion? Nothing, it’s just not the best tool for this job

SVN works in a very centralised, server dependent way

SVN cannot import from other SVN repositories– Except by using patches, but svn diff is very limited

SVN has poor support for branching and merging

And every now and again SVN gets confused and refuses to let us commit – normally when we are trying to release

29

Page 30: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

What are the advantages of Git The biggest strength of Git is it’s distributed nature

– Not dependant on a central server– Once the initial clone is complete network access is

only required for updates and delivery– Great for offline working– Bringing in changes from other repo’s is normal work

flow

Branching and merging are easy

Understands SVN

Reliable – doesn’t break it’s own repo– Well, it hasn’t yet…

30

Page 31: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Our set up

31

Although Git does not require or enforce a central server it is good to have a definitive repository for releases and work tracking

– The work is not done until it’s in the definitive repository!

We use Gerrit for code reviews and to manage our repositories

Page 32: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

32

Main Feature

Gerrit

NDS SVN

SVN Mirror

Cablelabs SVN

To be retired

External

Git repositories

Developers

Page 33: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Benefits Easy merging of Cablelabs commits into our code base

Much better support for feature development– Separate branch per feature– Update the branch from the main line regularly– Easy merge back of the feature once complete

Enforced code reviews– And a guarantee that what is reviewed is what is

committed

33

Page 34: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

34

The Future

Page 35: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Cablelabs support of Git Cablelabs are currently looking at adding support for

Git

Initially along side SVN

Then maybe longer term moving across to Git completely

The benefits for third parties of this would be– Easier merging of releases– Better visibility and tracking of fixes

It will also allow us to simplify our set up

35

Page 36: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

36

Main Feature

Gerrit

Cablelabs SVN

External

Git repositories

Developers

CablelabsGit

Page 37: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Improving the contribution process? Suggestion

– If Cablelabs were to have a public Gerrit in the same way the Android project has, then third parties could contribute fixes and features directly as a code review. Cablelabs and other interested parties could review and comment on the submission prior to it’s acceptance.

37

Page 38: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

38

Any Questions?

Page 39: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

© NDS Ltd 2010. All rights reserved.

SNMP

Implementing ECN-1114 *

Page 40: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

© NDS Ltd 2010. All rights reserved.

* and a few other things

Page 41: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The reasoning ECN-1114 simply states that Applications should be

able to query MIBs where data is supplied from the Stack.

Or the Platform Or another Application Or, come to think of it, the ECM But that’s not 1114 that’s 1138 isn’t it? And there’s probably an SNMP server in the Platform

Aargh. So that’s easy then.

41

Page 42: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The setup We put an SNMP Master Agent in the Platform We open up Agent X on the Master We put an Agent X client in the Stack

– All the applications register with the Stack, we register via Agent X with the Master

– All the Stack handlers register in the same way– The Platform supports queries with its own Agent X

client

We use snmp4j to do this

Cup of tea and a biscuit, job done

42

Page 43: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The sting Whadja mean “snmp4j doesn’t work in the RI”?

Oh, I see, it wants a full J2SE 1.4.2 JVM because it makes extensive use of nio

So let’s go find an open source SNMP client we can use...

That we can use.– And would run on PBP 1.1 – Not J2SE 1.5

We can use.– And didn’t upset our lawyers quite so much

Eventually, Hello to the University of Coimbra And Drexel University

43

Page 44: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The fun Drexel’s SNMP implementation was OK.

– We needed to wrap it up a little in case the lawyers decided we couldn’t use it, and therefore we wouldn’t impact the rest of the stack.

– But, all in all, it handled ASN.1 BER data pretty well.

UoC j.AgentX– Bit of a student project, shall we say– Lots of examples of Java coding– At times, it would almost work– Got a serious refactoring

44

Page 45: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Serious Refactoring

45

Page 46: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

And then Having gotten the SNMP framework in place in the

Stack, along with a simple SNMP Master in the Simulator Platform, we had to add the ability to register MIBs with that framework.

There is a function in MIBRouter that can add OIDs to the router, but they don’t quite support query, table indexing etc.

So, in a slightly more serious vein, here’s how to add your own data sources.

But first a slight detour...

46

Page 47: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Block Diagram

47

SNMP-Proxy SNMP-Query

AgentX Subagent SNMP

AgentX Master SNMP Server

Net-SNMP

Agentx-Subagent

Register API

Agentx-Register

Agentx-Register

Query API

SNMP Get/Set

SNMP Get/Set

Agentx-Get/Set

Get/Set API

Stack MIBs

MPE MIBs

App

Java Stack

MPE

Platform Agentx-Get/Set

JNI interface

Platform MIBs

DOCSIS

JAVA

C

Page 48: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The Objects you can use

48

Page 49: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

A Leaf Handler A Leaf Handler is one that supplies a single value for a

single OID– Each OID is treated independently– You can’t provide the base-OID of the group and

have the framework pass all requests to you The ABC LeafMIBModuleHandler provides the base

functionality; your class must provide– SNMPResponse processGetRequest(SNMPRequest r)– String[] getOIDs()

You should also implement MIBModuleHandler as that is used in dynamic registration

– registerMIBObjects() Currently, Leaf Handlers are Read Only handlers as

there are no MIBs that can be set within the Stack.

49

Page 50: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

processGetRequest(SNMPRequest r) This simply passes the SNMP Get request to your

handler. You find the OID requested from

– r.getMIBObject().getOID() You return the value as an SNMPResponse

50

Page 51: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

getOIDs() Simply return an array of all the OIDs your handler

satisfies. When a request comes in to the framework, this tests

to see if the OID is handled and if not, will be rejected. Therefore you know that the OID provided is one you

support. The array can have gaps where OIDs have been

deprecated.– But remeber, the ‘gap’ OID will never reach your processGetRequest() as it is tested in the framework

51

Page 52: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

registerMIBObjects() We’ll come back to this, but this called by the SNMP

Manager framework when the settop starts.

52

Page 53: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

A Table Handler Another abstract class within the framework is TableMIBModuleHandler which extends LeafMIBModuleHandler

Unlike LeafMIBModuleHandler it has a constructor like this:

TableMIBModuleHandler(String rootOID, String[] colOIDs)

The rootOID specifies the base OID and the colOIDs specify all the columns within that table

– This is to allow gap OIDs to be handled by the framework

– But! The OID must be a complete OID, not just that from the Root OID

– I messed with the signature to make it fit...

53

Page 54: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Again you must implement processGetRequest() as it

is possible to query a table for a definite value. The is no need to implement getOIDs() as the base

class now implements this. You will need to implement the interface MIBModuleHandler for registration purposes.

The new abstract method in this class is processGetNextRequest(MIBObject o)

54

Page 55: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

processGetNextRequest(MIBObject o) Again an SNMPResponse is returned however:

– The OID in the response is the full OID of the element

– If the end of table has been reached you must return END_OF_MIB_VIEW

• We have an easy way of doing this– You can use the base class method getNextOIDDetails(String ) to get the column and row of the request; even if the request was for the base table OID

– The framework will reject GET requests that do not have an entry, row and column

55

Page 56: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Helpful Classes Throughout the Stack we use a base class SNMPValue

– A simple wrapper of the Drexel SNMPObject class– Derived classes include

• SNMPValueInteger• SNMPValueOctetString• SNMPValueGuage32• SNMPValueIPAddress• SNMPValueError

SNMPValueError is a very useful class that allows you access to standard values for [e.g.]

– ‘End of Mib View’ [a table is complete]– ‘No such Instance’ [a bad index]– ‘No such Object’ [a bad OID]

56

Page 57: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

The standard return value is SNMPResponse, but there is

also an extended class SNMPResponseExt This is very handy as we can construct an SNMPResponse via an SNMPResponseExt and a class derived from SNMPValue

return new SNMPResponseExt(new SNMPValueInteger(52)); return new SNMPResponseExt(SNMPValueError.END_OF_MIB_VIEW);

57

Page 58: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Startup When the SNMP system starts up it looks for, and

registers, MIB handlers. Here’s how. The property files [base, hn, dvr etc] are scanned for a

property that looks like:

OCAP.MIBHandlers.eas= org.cablelabs.impl.manager.snmp.EASMIBModuleHandler

Where eas is just a unique identifier. It could easily be a number, but that makes extensions difficult.

It then tries to create the class specified, cast it to MIBModuleHandler and then call the registerMIBObjects() method on that instance.

The instance should call MIBManager.registerOID() to register the leaves and tables it supports.

58

Page 59: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Just when you thought it was safe... Cast your minds way back to Slide 6... We said that the Drexel SNMP library happily supported

ASN.1 BER encoding. In fact, because we have used SNMPValues throughout

the code, you can easily get the BER of a value. Sadly, the OCAP spec for MIBObject was a little open to

interpretation and in some cases the methods– MIBManager.queryMibs()– MIBManager.setMIBObject()

are assumed to take only the V of the TLV in ASN.1 BER. This means we are returning data that some

applications can’t understand. Or that when they attempt to return or set values, the value cannot be encoded and Exceptions are thrown.

This needs fixing for legacy applications and dual deployment.

59

Page 60: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

... you can go back in the water soon Solutions:

– Inter-application MIBs can be encoded as Opaque– Stack [or Platform] sourced data can be transcoded– SNMP Master Writes and Reads can be transcoded– Application Writes to Stack/Platform will need

adaptation Three Phases:

– Phase 1• Inter-application - Based on registrant type• Application read from Stack - Based on source

– Phase 2• Application write to Stack – Based on GET/SET

– Phase 3• Heuristic approach for apps that support TLV

60

Page 61: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Questions

?61

Page 62: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Thanks to @ NDS

– Alan Glynne Jones– David Brockhurst– Kevin Hendry– Krushna Reddy– Laurentiu Dragan– Madhusmitha Gottipati– Mark Orchard– Mike Ertl– Nitha Ponnanna

@ Cablelabs– Steve Maynard– Marcin Korzen

62

Page 63: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

© NDS Ltd 2010. All rights reserved.

Real World Issues

CableLabs and NDS working together

Page 64: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

An Example Recently a defect was raised detailing that the Stack

should wait for an event from the Platform. This was raised as OCAP_RI-505

– http://java.net/jira/browse/OCAP_RI-505– The problem was TSB conversion could start before

the Platform had filled the buffer, leading to occasional failure after a reboot or power cycle.

Before implementing the change we had to ensure that all Vendors produced the event when recording data.

Although it seemed obvious that this should happen, it’s always best to check.

64

Page 65: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Another example At times Vendors will find defects, or propose

enhancements, that come with a ready made patch. For example Home Networking issues, OCAP_RI-487:

– http://java.net/jira/browse/OCAP_RI-487– Couldn’t retune to encrypted channel when

recording When this happens, NDS will

– Test the fix against the reported defect– Apply the patch to the current CableLabs 1.1.4 code– Submit the patch to CableLabs and wait for release

Sometimes the patch is too late, or not applicable to the CableLabs code.

– Here NDS will incorporate the patch into their own distribution

65

Page 66: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

Finally NDS tries to keep Vendors aware of up-coming changes

to the MPEOS interfaces.

This is so they can be ready to implement changes when the code is released.

66

Page 67: © NDS Ltd 2010. All rights reserved. Refactoring the MMI contribution Extending the look and feel

67