text:
class Camera
{

protected:

	bool isWrappingPointer;
	bool mouseTriggered;
	bool isActive;
	bool isOrtho;

	glm::mat4 matProjection, matView;
	glm::mat4 matInvProjection, matInvView;
	glm::vec3 position, direction, up;
	float aspectRatio, fov, zNear, zFar;
	glm::vec2 resolution;

	int mouseX, mouseY, mouseLastX, mouseLastY;
	float mouseDeltaX, mouseDeltaY;
	float maxSpeed, acceleration, smoothness;
	float mouseSensitivity;

	virtual void updateProjectionMatrix();
	virtual void updateViewMatrix();

public:

	Camera();
	~Camera();

	// === Functions ===

	virtual void update(float dt);
	virtual void mouse(int button, int state);
	virtual void mouseMotion(int x, int y);
	virtual void mouseMotionPassive(int x, int y);
	virtual void mouseWheel(int dir);
	virtual void keyboard(int key);
	virtual void keyboardUp(int key);
	virtual void keyboardSpecial(int key);
	virtual void keyboardSpecialUp(int key);

	// === Accessors ===

	void setPosition(glm::vec3 position);
	void setResolution(int width, int height);
	void setMaxSpeed(float maxspeed);
	void setAcceleration(float acceleration);
	void setSmoothness(float smoothness);
	void setMouseSensitivity(float sensitivity);
	void setActive(bool isActive);
	void setFov(float angle);
	void setOrtho(bool isOrtho);

	glm::mat4 getMatViewProjection() const;
	glm::mat4 getMatView() const;
	glm::mat4 getMatInvView() const;
	glm::mat4 getMatProjection() const;
	glm::mat4 getMatInvProjection() const;
	glm::vec2 getResolution() const;
	glm::vec3 getPosition() const;
	glm::vec3 getDirection() const;
	float getMaxSpeed() const;
	float getAcceleration() const;
	float getSmoothness() const;
	float getMouseSensitivity() const;
	bool getActive() const;
	float getNearPlane() const;
	float getFarPlane() const;

};


text:
type: post
title: Oracle Delta Server
categories: SBP
parent: data-access-patterns.html
weight: 1300
---

|Author|XAP Version|Last Updated | Reference | Download |
|------|-----------|-------------|-----------|----------|
| Chris Roffler| 9.6 | Nov 2013|  |     |

# Overview

Almost every large enterprise system includes legacy applications or backend systems that are communicating with the enterprise main database system for reporting, batch processing, data mining, OLAP and other processing activity. These applications might not need to access the data grid to improve their performance or scalability. They will be using the database directly. Once these systems perform data updates , removing data or add new records to the database, these updates might need to be reflected within the data grid. This synchronization activity ensures the data grid is consistent and up to date with the enterprise main database server.

The Delta Server described with this pattern responsible for getting notifications from the database for any user activity (excluding data grid updates) and delegate these to the data grid. You may specify the exact data set updates to be delegated to the data grid by specifying a SQL Query that will indicate which records updates / removal / addition should be reflected within the data grid.

# Scenario

We have an In Memory Data Grid (IMDG) that is used for querying information. The initial load of the IMDG was performed from an Oracle Database. The IMDG is not used as a system of record in this case meaning that any changes to the objects in the IMDG are not propagated back into the Database. Non-Aware Data-Grid Clients are updating the Database. These updates (insert,update and delete) need to be reflected in the IMDG.

{{%align center%}}
[](/attachment_files/sbp/oracle-dserver.png)
{{%/align%}}

We will show you how you can implement this scenario with XAP. A fully functional example is available on [GitHub](https://github.com/Gigaspaces/oracle-delta-server).

# Database Change Notification

Oracle's Database Change Notification enables client applications to register queries with the database and receive notifications in response to DML or DDL changes on the objects associated with the queries. The notifications are published by the database when the DML or DDL transaction commits. During registration, the application specifies a notification handler and associates a set of interesting queries with the notification handler. A notification handler can be either a server side PL/SQL procedure or a client side callback.

When the database issues change notification, it can contain some or all of the following information:

* Names of the modified objects. For example, the notification can specify that the hr.employees table was changed.
* The type of change. For example, the message specifies whether the change was caused by an INSERT, UPDATE, DELETE, ALTER TABLE, or DROP TABLE.
* The ROWIDs of the changed rows and the type of DML that changed them.

For further information please consult the Oracle [documentation](http://docs.oracle.com/cd/B19306_01/appdev.102/b14251/adfns_dcn.htm).
In our example we will only demonstrate the notifications for INSERT, UPDATE and Delete.

## Registering a listener
Lets assume we have an Employee table in the database that we want to be notified when a record is inserted, updated or deleted so we can update the IMDG with the changes. Here is an example of an ChangeNotificationListener.

```java
private void registerListener() {

  Properties props = new Properties();
  props.put(OracleConnection.DCN_NOTIFY_ROWIDS, "true");
  props.put(OracleConnection.NTF_QOS_RELIABLE, "false");
  props.setProperty(OracleConnection.DCN_BEST_EFFORT, "true");

  DatabaseChangeRegistration dcr = dbConnection.registerDatabaseChangeNotification(props);

  Statement stmt = dbConnection.createStatement();

  // Associate the statement with the registration.
  ((OracleStatement) stmt).setDatabaseChangeRegistration(dcr);
  // Register the actual query
  ResultSet rs = stmt.executeQuery("select * from employee");

  while (rs.next()) {
  // Do Nothing
  }

  // Add the Application listener
  dcr.addListener(this);
 }
```

{{%note%}}The select statement for the listener could be any valid sql statement{{%/note%}}

## Implementing the Listener
The listener will receive the change notifications whenever a row was inserted, updated or deleted in the employee table. Here is the code for the listener implementation:

```java
@Override
public void onDatabaseChangeNotification(DatabaseChangeEvent databaseChangeEvent) {

  TableChangeDescription[] tableChanges = databaseChangeEvent.getTableChangeDescription();

  for (TableChangeDescription tableChange : tableChanges) {
    RowChangeDescription[] rcds = tableChange.getRowChangeDescription();

     for (RowChangeDescription rcd : rcds) {
       RowOperation ro = rcd.getRowOperation();
       String rowId = rcd.getRowid().stringValue();

       if (ro.equals(RowOperation.INSERT)) {
         service.insertSpace(rowId);
       } else if (ro.equals(RowOperation.UPDATE)) {
         service.updateSpace(rowId);
       } else if (ro.equals(RowOperation.DELETE)) {
         service.removeSpace(rowId);
       } else {
         logger.info("Event Not Replicated - Only INSERT/DELETE/UPDATE are handled.");
       }
    }
  }
}
```

The notification information only contains the actual operation performed in the database and the corresponding ROWID. After receiving the ROWID we have to retrieve the actual data from the employee table with a query that uses this ROWID in the where clause and then we instantiate the object and write it into the IMDG.

Here is an example of this query:

```java
"select rowid, id, processed, firstName, lastname, age, departmentid from employee where rowId = ? "
```

## Employee POJO
Here is the corresponding Employee POJO that we will use to write to the space:

```java
@SpaceClass
@Entity
public class Employee implements IDomainEntity<Long> {
  private static final long serialVersionUID = 1L;
  private String rowid;
  @Id
  private Long id;
  private Boolean processed;
  private String firstName;
  private String lastName;
  private Integer age;
  private Integer departmentid;

  public Employee() {
  }

  @SpaceId
  public Long getId() {
    return id;
  }

  @SpaceRouting
  public Integer getDepartmentid() {
    return departmentid;
  }
..........
}
```

Since we are using Hibernate for the queries, we are declaring the Class as an `@Entity`. However we do not define a table for the Entity otherwise Hibernate would try to map the ROWID attribute to a column in the oracle table.

# Deployment

In our example we deploy two Processing Units (PU's):
- The first PU (loaderPU) creates an embedded space and registers notify listeners that will tell us when objects are written, updated or deleted from the space. This PU also performs the initial load.
- The second PU (feederPU) creates the Oracle Change Listener and writes, updates or deletes the object from the space.

# Initial load
On system startup we perform an initial load from the database. The first PU that creates the space will load all rows from the database into the IMDG. Here is an example how we can accomplish this:

```java
@PostConstruct
private void initialize() {

   logger.debug("Starting to load data ");

   Collection<Employee> employees = null;

   if (clusterInfo.getNumberOfInstances() > 1) {
     employees = dao.findAllEmloyeesByPartition(clusterInfo.getNumberOfInstances(),
        .getInstanceId() - 1);
   } else {
     employees = dao.findAllEmloyees();
   }

   for (Employee emp : employees) {
      space.write(emp);
   }
}

```
If the space is not partitioned we simply read all employees from the table and write them to the space. If the space is partitioned, we will query the database with the following query assuming that the `departmentid` attribute is the routing attribute:

```sql
"select rowid, id, processed, firstName, lastname, age, departmentid from employee where mod(departmentid,?) = ? "
```

# Running the example

1. Download the example from {{%git "https://github.com/Gigaspaces/oracle-delta-server"%}}.
2. Change the Database properties according to your environment:

```java
# Oracle Database Config
db.type=oracle
db.driver=oracle.jdbc.driver.OracleDriver
db.dialect=org.hibernate.dialect.Oracle9iDialect
db.url=jdbc:oracle:thin:@yourhost:1521:orcl
db.username=username
db.password=password

```

These configuration files are located :

* /oracle-delta-server/loader/src/main/resources/service.properties
* /oracle-delta-server/feeder/src/main/resources/service.properties
* /oracle-delta-server/src/test/resources/service.properties

3. Build the processing units with the top pom file.
4. Deploy the loaderPU.jar file onto the XAP Data Grid (this will perform the initial load from the database)
5. Deploy the feederPU.jar file onto the XAP Data Grid (this will register the change listener with oracle)
6. Run a client that inserts, updates and deletes employees in the database /oracle-delta-server/src/test/java/xap/oracle/test/DBTest.java
This application will insert every 10 seconds an employee into the Database, then updates them and finally removes them from the Database.

You can see in the feeder.log file that the feederPU generates, that the events are processed from the change listener:

```java
2013-11-07T14:15:50.256 DEBUG - xap.oracle.processor.OracleChangeListener -Event handler received event
2013-11-07T14:15:50.256 DEBUG - xap.oracle.processor.OracleChangeListener -Affected row : AAASNyAAEAAAAIzABk
ROW: operation=DELETE, ROWID=AAASNyAAEAAAAIzABk
```

And in the loader.log file that is generated by the loaderPU, you will see that the space receives the operations:

```java
2013-11-07T14:16:02.118 DEBUG - xap.oracle.loader.listener.RemoveEmployeeListener -An Employee was removed from space
```

redpajama_set_name: RedPajamaGithub


text:
//
//  FissureScene.m
//  Fissure
//
//  Created by Jason Fieldman on 4/20/14.
//  Copyright (c) 2014 fieldman.org. All rights reserved.
//

#import "FissureScene.h"

#define SCALE_RADIUS_WIDTH 20

@implementation FissureScene

-(id)initWithSize:(CGSize)size {
	if (self = [super initWithSize:size]) {
		self.backgroundColor = [SKColor colorWithRed:0.92 green:0.92 blue:0.92 alpha:1.0];

		/* Initialize the physics of the scene */
		self.physicsWorld.gravity = CGVectorMake(0, 0);
		self.physicsWorld.contactDelegate = self;

		/* Create spawn zone array */
		_spawnPoints = [NSMutableArray array];

		/* Create controls */
		_controls = [NSMutableArray array];

		/* Create targets */
		_targets = [NSMutableArray array];

		/* Create fissures */
		_fissures = [NSMutableArray array];

		/* Create static images */
		_staticImages = [NSMutableArray array];

		/* Initialize timing */
		_lastFrameTime = 0;

		/* Create boundary */
		self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:CGRectInset(self.frame, -150, -100)];
		self.physicsBody.categoryBitMask = PHYS_CAT_EDGE;

    }
    return self;
}

- (void) loadFromLevelDictionary:(NSDictionary*)level {

	CGSize screenSize = self.size;

	for (NSDictionary *staticDic in level[@"static"]) {
		NSString *image = staticDic[@"image"];
		SKSpriteNode *node = [SKSpriteNode spriteNodeWithImageNamed:image];
		node.alpha = 0;
		[self addChild:node];
		node.position = CGPointMake(self.size.width/2, self.size.height/2);
		[node animateToAlpha:0.65 delay:1.5 duration:1.5];
		[_staticImages addObject:node];
	}

	/* Create the projectile particle layer */
	_projectileParticleLayerNode = [SKNode node];
	_projectileParticleLayerNode.position = CGPointMake(50, 200);
	[self addChild:_projectileParticleLayerNode];

	_projectileLayerNode = [SKNode node];
	_projectileLayerNode.zPosition = 0.5;
	[self addChild:_projectileLayerNode];

	/* Show proj layers */
	_projectileParticleLayerNode.alpha = 1;
	_projectileLayerNode.alpha         = 1;

	/* Allow spawns after delay */
	dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
		_shouldSpawnProjectiles = YES;
	});

	NSArray *spawnDics = level[@"spawns"];
	int spawnIndex = 0;
	for (NSDictionary *dic in spawnDics) {
		SpawnPoint *spawn = [[SpawnPoint alloc] initWithDictionary:dic forSceneSize:screenSize];
		[_spawnPoints addObject:spawn];
		EXLog(MODEL, DBG, @"Loaded spawn point at (%.2f, %.2f)", spawn.position.x, spawn.position.y);

		[self addChild:spawn.node];

		/* Scale in */
		float delay = 0.1 + (spawnIndex * 0.25); spawnIndex++;
		spawn.node.alpha = 0;
		[spawn.node bounceInAfterDelay:delay duration:0.9 bounces:5];
		[spawn.node animateToAlpha:0.1 delay:delay duration:0.4];
	}

	NSArray *controlDics = level[@"controls"];
	NSMutableArray *warps = [NSMutableArray array];
	int controlIndex = 0;
	for (NSDictionary *dic in controlDics) {
		if ([dic[@"ignore"] boolValue]) continue;
		SceneControl *control = [[SceneControl alloc] initWithDictionary:dic forSceneSize:screenSize];
		control.scene = self;
		[_controls addObject:control];
		EXLog(MODEL, DBG, @"Loaded control of type %d at (%.2f, %.2f)", control.controlType, control.position.x, control.position.y);

		if (control.node)  [self addChild:control.node];
		if (control.icon)  [self addChild:control.icon];
		if (control.shape) [self addChild:control.shape];

		if (control.controlType == CONTROL_TYPE_WARP) [warps addObject:control];

		/* Scale in */
		float delay = 0.1 + (controlIndex * 0.1); controlIndex++;
		control.node.alpha = 0;
		control.icon.alpha = 0;
		control.shape.alpha = 0;
		[control.node  bounceInAfterDelay:delay duration:0.9 bounces:5];
		if (control.controlType != CONTROL_TYPE_SHAPE) [control.node  animateToAlpha:0.1 delay:delay duration:0.4];
		[control.icon  bounceInAfterDelay:delay duration:0.9 bounces:5];
		[control.icon  animateToAlpha:1   delay:delay duration:0.4];
		[control.shape bounceInAfterDelay:delay duration:0.9 bounces:5];
		[control.shape animateToAlpha:1   delay:delay duration:0.4];
	}

	NSArray *fissureDics = level[@"fissures"];
	int fissureIndex = 1;
	for (NSDictionary *dic in fissureDics) {
		Fissure *fissure = [[Fissure alloc] initWithDictionary:dic forSceneSize:screenSize];
		fissure.fissureIndex = fissureIndex;
		[_fissures addObject:fissure];
		EXLog(MODEL, DBG, @"Loaded fissure at (%.2f, %.2f)", fissure.position.x, fissure.position.y);

		[self addChild:fissure];
		fissureIndex++;

		float delay = 0.25 + (fissureIndex * 0.25);
		fissure.alpha = 0;
		[fissure animateToAlpha:1 delay:delay duration:1.5];
	}

	NSArray *targetDics = level[@"targets"];
	int targetIndex = 0;
	for (NSDictionary *dic in targetDics) {
		Target *target = [[Target alloc] initWithDictionary:dic forSceneSize:screenSize];
		if (target.matchedFissure) {
			target.color = ((Fissure*)_fissures[target.matchedFissure-1]).color;
		}

		[_targets addObject:target];
		EXLog(MODEL, DBG, @"Loaded target at (%.2f, %.2f)", target.position.x, target.position.y);

		[self addChild:target.node];

		/* Scale in */
		float delay = 0.1 + (targetIndex * 0.15); targetIndex++;
		target.node.alpha = 0;
		[target.node bounceInAfterDelay:delay duration:0.9 bounces:5];
		[target.node animateToAlpha:1 delay:delay duration:0.4];
	}

	/* This part connects the warp zones */
	if ([warps count] == 0) {
		EXLog(MODEL, DBG, @"No warp zones");
	} else if ([warps count] % 2 == 0) {
		for (int i = 0; i < [warps count]; i+=2) {
			SceneControl *w1 = warps[i];
			SceneControl *w2 = warps[i+1];
			w1.connectedWarp = w2;
			w2.connectedWarp = w1;
		}
	} else {
		EXLog(MODEL, DBG, @"Invalid warp count: %d", (int)[warps count]);
	}

	/* Allow full trigger! */
	_canTriggerFull = YES;
}

-(void)update:(CFTimeInterval)currentTime {
	/* If we missed more than a certain lapse, pretend it was just a complete skip */
	CFTimeInterval elapsedTime = currentTime - _lastFrameTime;
	_lastFrameTime = currentTime;
	if (elapsedTime > 1) {
		return;
	}

	/* Spawn if neeeded */
	[self spawnProjectiles];

	/* Update projectiles */
	for (SceneControl *control in _controls) {
		[control updateAffectedProjectilesForDuration:elapsedTime];
	}

	/* Update targets */
	BOOL allFull = YES;
	for (Target *target in _targets) {
		[target updateForDuration:elapsedTime];
		if (target.timeFull < (target.hysteresis + 0.25)) allFull = NO;
	}

	if (allFull) {
		[self allTargetsFull];
	}

	/* Check for stopped nodes */
	for (SKNode *node in _projectileLayerNode.children) {
		float dx = node.physicsBody.velocity.dx;
		float dy = node.physicsBody.velocity.dy;
		if (dx < 10 && dy < 10 && dx > -10 && dy > -10) {
			BOOL found = NO;
			for (SceneControl *control in _controls) {
				//if (control.controlType != CONTROL_TYPE_PUSH) continue;
				if ([control.affectedProjectiles indexOfObjectIdenticalTo:node] != NSNotFound) {
					found = YES;
					break;
				}
			}
			if (!found) [node removeFromParent];
		}
	}
}

- (void) allTargetsFull {
	if (!_canTriggerFull) return;
	_canTriggerFull = NO;

	[self.sceneDelegate sceneAllTargetsLit];
	[self levelOverStageOne];
}

- (void) forceWin {
	[self allTargetsFull];
}

/* animate all objects out */
- (void) levelOverStageOne {

	/* Alpha-out statics */
	for (SKNode *node in _staticImages) {
		[node animateToAlpha:0 delay:0 duration:0.5];
	}

	/* Alpha-out controls */
	int controlIndex = 0;
	for (SceneControl *control in _controls) {
		float delay = 0.5 + controlIndex * 0.15;

		[control.node  bounceOutAfterDelay:delay-0.25 duration:0.9 bounces:2];
		[control.icon  bounceOutAfterDelay:delay-0.25 duration:0.9 bounces:2];
		[control.shape bounceOutAfterDelay:delay-0.25 duration:0.9 bounces:2];

		[control.node  animateToAlpha:0 delay:delay duration:0.5];
		[control.icon  animateToAlpha:0 delay:delay duration:0.5];
		[control.shape animateToAlpha:0 delay:delay duration:0.5];

		//[control.node  animateToScale:0.5 delay:delay duration:0.5];
		//[control.icon  animateToScale:0.5 delay:delay duration:0.5];
		//[control.shape animateToScale:0.5 delay:delay duration:0.5];

		controlIndex++;
	}

	/* Alpha-out projectiles */
	[_projectileLayerNode         animateToAlpha:0 delay:0 duration:0.75];
	[_projectileParticleLayerNode animateToAlpha:0 delay:0 duration:0.75];

	dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
		_shouldSpawnProjectiles = NO;
	});

	/* Alpha-out targets */
	int targetIndex = 0;
	for (Target *target in _targets) {
		float delay = 1 + targetIndex * 0.15;
		[target.node animateToAlpha:0   delay:delay duration:0.5];
		[target.node animateToScale:0.5 delay:delay duration:0.5];
		targetIndex++;
	}

	/* Alpha-out fissures */
	int fissureIndex = 0;
	for (Fissure *fissure in _fissures) {
		float delay = 1 + fissureIndex * 0.15;
		[fissure animateToAlpha:0   delay:delay duration:0.5];
		[fissure animateToScale:0.5 delay:delay duration:0.5];
		fissureIndex++;
	}

	/* Alpha-out spawn points */
	int spawnIndex = 0;
	for (SpawnPoint *spawn in _spawnPoints) {
		float delay = 1 + spawnIndex * 0.15;
		[spawn.node animateToAlpha:0   delay:delay duration:0.5];
		[spawn.node animateToScale:0.5 delay:delay duration:0.5];
		spawnIndex++;
	}

	/* Trigger stage 2 */
	[self performSelector:@selector(levelOverStageTwo) withObject:nil afterDelay:2];
}

/* Kill all objects and remove from tree */
- (void) levelOverStageTwo {
	for (SKNode *node in _staticImages) {
		[node removeFromParent];
	}
	[_staticImages removeAllObjects];

	for (SceneControl *c in _controls) {
		[c.node removeFromParent];
		[c.icon removeFromParent];
		[c.shape removeFromParent];
	}
	[_controls removeAllObjects];

	for (Fissure *f in _fissures) {
		[f removeFromParent];
	}
	[_fissures removeAllObjects];

	for (SpawnPoint *s in _spawnPoints) {
		[s.node removeFromParent];
	}
	[_spawnPoints removeAllObjects];

	for (Target *t in _targets) {
		[t.node removeFromParent];
	}
	[_targets removeAllObjects];

	/* Particles */
	[_projectileLayerNode removeFromParent];
	[_projectileParticleLayerNode removeFromParent];

	_projectileLayerNode = nil;
	_projectileParticleLayerNode = nil;

	dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
		[self levelOverStageThree];
	});
}

- (void) levelOverStageThree {
	[self.sceneDelegate sceneReadyToTransition];
}

- (void) spawnProjectiles {
	if (!_shouldSpawnProjectiles) return;

	for (SpawnPoint *point in _spawnPoints) {
		if (![point shouldSpawnThisFrame]) continue;

		/* Create the projectile */
		SKSpriteNode *node = [[SKSpriteNode alloc] initWithImageNamed:@"line5x1"];
		//node.position = CGPointMake( point.position.x + (rand() % (int)point.positionJitter.width)  - point.positionJitter.width/2,
		//							 point.position.y + (rand() % (int)point.positionJitter.height) - point.positionJitter.height/2);
		node.position = CGPointMake( point.position.x + floatBetween(-point.positionJitter.width, point.positionJitter.width),
									 point.position.y + floatBetween(-point.positionJitter.height, point.positionJitter.height) );

		node.color = [UIColor grayColor];
		node.colorBlendFactor = 1;

		node.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:PROJECTILE_PHYS_RADIUS];
		node.physicsBody.friction = point.friction;
		node.physicsBody.velocity = point.initialVelocity;
		node.physicsBody.affectedByGravity = NO;
		node.physicsBody.allowsRotation = YES;
		node.physicsBody.linearDamping = point.friction;
		node.physicsBody.restitution = 1;
		node.zRotation = atan2(node.physicsBody.velocity.dy, node.physicsBody.velocity.dx);

		node.physicsBody.categoryBitMask = PHYS_CAT_PROJ;
		node.physicsBody.collisionBitMask = PHYS_CAT_CONTROL_COLL;
		node.physicsBody.contactTestBitMask = PHYS_CAT_EDGE | PHYS_CAT_CONTROL_TRANS | PHYS_CAT_TARGET | PHYS_CAT_FISSURE | PHYS_CAT_CONTROL_COLL;

		[_projectileLayerNode addChild:node];

		/* Create the particle effect behind it */
		SKEmitterNode *emitter = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle] pathForResource:@"projectile_trail" ofType:@"sks"]];
		emitter.targetNode = _projectileParticleLayerNode;
		[node addChild:emitter];

		/* Attach it to the userData */
		node.userData = [NSMutableDictionary dictionaryWithDictionary:@{@"emitter":emitter}];
	}
}

- (void) removeNodeFromAllControlsNotInRange:(SKNode*)node {
	for (SceneControl *control in _controls) {

		if (control.controlType == CONTROL_TYPE_WARP) continue;

		float dx = node.position.x - control.position.x;
		float dy = node.position.y - control.position.y;
		float dist = sqrt(dx * dx + dy * dy);

		if (dist > control.radius) {
			[control.affectedProjectiles removeObjectIdenticalTo:node];
		}
	}
}

- (void) resetControlsToInitialPositions {
	for (SceneControl *control in _controls) {
		[control.node  bounceToPosition:control.initialPosition scale:1 delay:0 duration:1.1 bounces:5];
		[control.icon  bounceToPosition:control.initialPosition scale:1 delay:0 duration:1.1 bounces:5];
		[control.shape bounceToPosition:control.initialPosition scale:1 delay:0 duration:1.1 bounces:5];

		dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
			control.position = control.initialPosition;
			control.radius   = control.initialRadius;
		});
	}
}

#pragma mark Contact Checks

- (void) didBeginContact:(SKPhysicsContact *)contact {
	SKPhysicsBody *firstBody, *secondBody;

	/* Order the nodes by category for easier processing */
	if (contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask) {
		firstBody = contact.bodyA;
		secondBody = contact.bodyB;
	} else {
		firstBody = contact.bodyB;
		secondBody = contact.bodyA;
	}

	/* If a projectile hits an edge, remove it */
	if ((firstBody.categoryBitMask & PHYS_CAT_EDGE) && (secondBody.categoryBitMask & PHYS_CAT_PROJ)) {
		[_projectileLayerNode removeChildrenInArray:@[secondBody.node]];
		return;
	}

	/* Check if a projectile hits a passable control */
	if (firstBody.categoryBitMask & PHYS_CAT_PROJ) {
		if (secondBody.categoryBitMask & PHYS_CAT_CONTROL_TRANS) {
			SceneControl *control = secondBody.node.userData[@"control"];
			[control.affectedProjectiles addObject:firstBody.node];
			return;
		}

		/* Check if a projectile hits a target */
		if (secondBody.categoryBitMask & PHYS_CAT_TARGET) {
			Target *target = secondBody.node.userData[@"target"];
			SKSpriteNode *proj = (SKSpriteNode*)firstBody.node;

			if ([proj.userData[@"fissureIndex"] intValue] == target.matchedFissure) {
				[target hitByProjectile];
			}
			return;
		}

		/* Change projectile rotation */
		if (secondBody.categoryBitMask & PHYS_CAT_CONTROL_COLL) {
			SKSpriteNode *proj = (SKSpriteNode*)firstBody.node;

			dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
				proj.zRotation = atan2(proj.physicsBody.velocity.dy, proj.physicsBody.velocity.dx);
			});
			//proj.zRotation = atan2(proj.physicsBody.velocity.dy, proj.physicsBody.velocity.dx);
			return;
			//NSLog(@"vel: %f %f %f", proj.physicsBody.velocity.dx, proj.physicsBody.velocity.dy, proj.zRotation);
		}

	}
}

- (void) didEndContact:(SKPhysicsContact *)contact {
	SKPhysicsBody *firstBody, *secondBody;

	/* Order the nodes by category for easier processing */
	if (contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask) {
		firstBody = contact.bodyA;
		secondBody = contact.bodyB;
	} else {
		firstBody = contact.bodyB;
		secondBody = contact.bodyA;
	}

	if (firstBody.categoryBitMask & PHYS_CAT_PROJ) {

		/* Projectile leaves a control */
		if (secondBody.categoryBitMask & PHYS_CAT_CONTROL_TRANS) {
			SceneControl *control = secondBody.node.userData[@"control"];
			[control.affectedProjectiles removeObjectIdenticalTo:firstBody.node];
			if (control.controlType == CONTROL_TYPE_WARP) [firstBody.node.userData removeObjectForKey:@"warped"];
			return;
		}

		/* Check if a projectile hits a fissure */
		if (secondBody.categoryBitMask & PHYS_CAT_FISSURE) {
			/* Update fissure */
			Fissure *fissure = (Fissure*)secondBody.node;
			SKSpriteNode *proj = (SKSpriteNode*)firstBody.node;
			proj.color = fissure.color;
			proj.colorBlendFactor = 0.95;
			proj.userData[@"fissureIndex"] = @(fissure.fissureIndex);

			/* Update emitter color */
			SKEmitterNode *emitter = (SKEmitterNode*)proj.userData[@"emitter"];
			CGFloat r,g,b,a;
			[fissure.color getRed:&r green:&g blue:&b alpha:&a];
			emitter.particleColorSequence = [[SKKeyframeSequence alloc] initWithKeyframeValues:@[[UIColor colorWithRed:r green:g blue:b alpha:0.15],
																								 [UIColor colorWithRed:r green:g blue:b alpha:0]] times:@[@(0), @(1)]];;
			return;
		}

	}
}

#pragma mark Touch Controls

-(void)touchesBegan:(NSSet*) touches withEvent:(UIEvent*) event {
	if ([touches count] == 1) {

		CGPoint touchPoint = [[touches anyObject] locationInNode:self];
		NSArray *touchedNodes = [self nodesAtPoint:touchPoint];

		/* Debug touch output */
		#ifdef EXDEBUGENABLED
		EXLog(ANY, DBG, @"%f %f", (touchPoint.x - (([UIScreen mainScreen].bounds.size.height < 481)?0:44))/480.0, touchPoint.y / 320.0);
		#endif

		NSMutableArray *touchedControls = [NSMutableArray array];
		for (SKNode *node in touchedNodes) {
			if (![node.userData[@"isControl"] boolValue]) continue;
			SceneControl *control = node.userData[@"control"];
			if (!control.canMove && !control.canScale) continue;
			[touchedControls addObject:control];
			/*
			for (SceneControl *control in _controls) {
				if (control.node == node) {
					[touchedControls addObject:control];
					break;
				}
			}
			 */
		}

		/* No controls touched?  break */
		if (![touchedControls count]) return;

		/* Default to drag behavior */
		_draggedControl = nil;
		float minDist = 1000000;
		for (SceneControl *control in touchedControls) {
			float dx = control.position.x - touchPoint.x;
			float dy = control.position.y - touchPoint.y;
			float dist = sqrt(dx * dx + dy * dy);
			if (dist < minDist) {
				minDist = dist;
				_draggedControl = control;
				_dragOffset = CGPointMake(dx, dy);
			}
		}

		/* See if it's scaling instead */
		if (!_draggedControl.canScale) return;
		if (minDist > (_draggedControl.radius - SCALE_RADIUS_WIDTH)) {
			_scalingControl = _draggedControl; _draggedControl = nil;
			_scalingOffset  = _scalingControl.radius - minDist;
		} else if (!_draggedControl.canMove) {
			_draggedControl = nil;
		}
	}

}

-(void)touchesMoved:(NSSet*) touches withEvent:(UIEvent*) event {
	if ([touches count] > 1) return;

	CGPoint touchPoint = [[touches anyObject] locationInNode:self];

	if (_draggedControl) {

		/* Update position of control (this should update the node position as well */
		_draggedControl.position = CGPointMake(touchPoint.x + _dragOffset.x, touchPoint.y + _dragOffset.y);

		[self resetTargetTimers];

	} else if (_scalingControl) {

		/* Update radius of control */
		float dx = touchPoint.x - _scalingControl.position.x;
		float dy = touchPoint.y - _scalingControl.position.y;
		float dist = sqrt(dx * dx + dy * dy);
		float radius = dist + _scalingOffset;

		_scalingControl.radius = radius;

		[self resetTargetTimers];
	}
}

- (void) resetTargetTimers {
	for (Target *t in _targets) {
		[t controlMoved];
	}
}

-(void)touchesEnded:(NSSet*) touches withEvent:(UIEvent*) event {
	_draggedControl = nil;
	_scalingControl = nil;
}

@end


text:
package com.bupt.core.security.model;

public class Privilege {

	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.privilege_id
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private Integer privilegeId;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.parent_id
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private Integer parentId;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.description
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private String description;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.name
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private String name;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.display_name
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private String displayName;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.level
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private Byte level;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.is_leaf
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private Boolean isLeaf;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.url
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private String url;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.target
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private String target;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.order_num
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private Integer orderNum;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.display
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private Boolean display;
	/**
	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_security_privilege.type
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	private String type;

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.privilege_id
	 * @return  the value of t_security_privilege.privilege_id
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public Integer getPrivilegeId() {
		return privilegeId;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.privilege_id
	 * @param privilegeId  the value for t_security_privilege.privilege_id
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setPrivilegeId(Integer privilegeId) {
		this.privilegeId = privilegeId;
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.parent_id
	 * @return  the value of t_security_privilege.parent_id
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public Integer getParentId() {
		return parentId;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.parent_id
	 * @param parentId  the value for t_security_privilege.parent_id
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.description
	 * @return  the value of t_security_privilege.description
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.description
	 * @param description  the value for t_security_privilege.description
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setDescription(String description) {
		this.description = description == null ? null : description.trim();
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.name
	 * @return  the value of t_security_privilege.name
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public String getName() {
		return name;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.name
	 * @param name  the value for t_security_privilege.name
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setName(String name) {
		this.name = name == null ? null : name.trim();
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.display_name
	 * @return  the value of t_security_privilege.display_name
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public String getDisplayName() {
		return displayName;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.display_name
	 * @param displayName  the value for t_security_privilege.display_name
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setDisplayName(String displayName) {
		this.displayName = displayName == null ? null : displayName.trim();
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.level
	 * @return  the value of t_security_privilege.level
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public Byte getLevel() {
		return level;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.level
	 * @param level  the value for t_security_privilege.level
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setLevel(Byte level) {
		this.level = level;
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.is_leaf
	 * @return  the value of t_security_privilege.is_leaf
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public Boolean getIsLeaf() {
		return isLeaf;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.is_leaf
	 * @param isLeaf  the value for t_security_privilege.is_leaf
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setIsLeaf(Boolean isLeaf) {
		this.isLeaf = isLeaf;
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.url
	 * @return  the value of t_security_privilege.url
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.url
	 * @param url  the value for t_security_privilege.url
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setUrl(String url) {
		this.url = url == null ? null : url.trim();
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.target
	 * @return  the value of t_security_privilege.target
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public String getTarget() {
		return target;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.target
	 * @param target  the value for t_security_privilege.target
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setTarget(String target) {
		this.target = target == null ? null : target.trim();
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.order_num
	 * @return  the value of t_security_privilege.order_num
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public Integer getOrderNum() {
		return orderNum;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.order_num
	 * @param orderNum  the value for t_security_privilege.order_num
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.display
	 * @return  the value of t_security_privilege.display
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public Boolean getDisplay() {
		return display;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.display
	 * @param display  the value for t_security_privilege.display
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setDisplay(Boolean display) {
		this.display = display;
	}

	/**
	 * This method was generated by MyBatis Generator. This method returns the value of the database column t_security_privilege.type
	 * @return  the value of t_security_privilege.type
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public String getType() {
		return type;
	}

	/**
	 * This method was generated by MyBatis Generator. This method sets the value of the database column t_security_privilege.type
	 * @param type  the value for t_security_privilege.type
	 * @mbggenerated  Sun Jul 21 16:19:05 CST 2013
	 */
	public void setType(String type) {
		this.type = type == null ? null : type.trim();
	}
}


text:
// @COPYRIGHT@
// Licensed under MIT license (LICENSE.txt)

// clxx/context_properties.t.h

/** // doc: clxx/context_properties.t.h {{{
 * \file clxx/context_properties.t.h
 * \todo Write documentation
 */ // }}}
#ifndef CLXX_CONTEXT_PROPERTIES_T_H_INCLUDED
#define CLXX_CONTEXT_PROPERTIES_T_H_INCLUDED

#include <cxxtest/TestSuite.h>
#include <clxx/cl/context_properties.hpp>
#include <clxx/common/exceptions.hpp>

namespace clxx { class context_properties_test_suite; }

/** // doc: class clxx::context_properties_test_suite {{{
 * \todo Write documentation
 */ // }}}
class clxx::context_properties_test_suite : public CxxTest::TestSuite
{
public:
  /** // doc: test_context_properties_array_size() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_array_size()
  {
    TS_ASSERT_EQUALS(context_properties_array_size(context_properties()),1);
    TS_ASSERT_EQUALS(context_properties_array_size(context_properties({context_platform(nullptr)})),3);
    TS_ASSERT_EQUALS(context_properties_array_size(context_properties({context_platform(nullptr), context_interop_user_sync(true)})),5);
  }
  /** // doc: test_context_properties_fill_array_1() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_fill_array_1()
  {
    context_properties props;
    cl_context_properties array[1];
    TS_ASSERT_EQUALS(context_properties_fill_array(props,array,1ul),1ul);
    TS_ASSERT_EQUALS(array[0],(cl_context_properties)0ul);
  }
  /** // doc: test_context_properties_fill_array_2() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_fill_array_2()
  {
    context_properties props = { context_platform((cl_platform_id)0x1234ul) };
    cl_context_properties array[5];
    TS_ASSERT_EQUALS(context_properties_fill_array(props,array,5ul),3ul);
    TS_ASSERT_EQUALS(array[0],(cl_context_properties)CL_CONTEXT_PLATFORM);
    TS_ASSERT_EQUALS(array[1],(cl_context_properties)0x1234ul);
    TS_ASSERT_EQUALS(array[2],(cl_context_properties)0ul);
  }
  /** // doc: test_context_properties_fill_array_3() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_fill_array_3()
  {
    context_properties props = { context_platform((cl_platform_id)0x1234ul),
                                 context_interop_user_sync(true) };
    cl_context_properties array[5];
    TS_ASSERT_EQUALS(context_properties_fill_array(props,array,5ul),5ul);
    TS_ASSERT_EQUALS(array[0],(cl_context_properties)CL_CONTEXT_PLATFORM);
    TS_ASSERT_EQUALS(array[1],(cl_context_properties)0x1234ul);
    TS_ASSERT_EQUALS(array[2],(cl_context_properties)CL_CONTEXT_INTEROP_USER_SYNC);
    TS_ASSERT_EQUALS(array[3],(cl_context_properties)CL_TRUE);
    TS_ASSERT_EQUALS(array[4],(cl_context_properties)0ul);
  }
  /** // doc: test_context_properties_fill_array_4() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_fill_array_4()
  {
    context_properties props;
    TS_ASSERT_THROWS(context_properties_fill_array(props,nullptr,8), invalid_argument_error);
  }
  /** // doc: test_context_properties_fill_array_5() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_fill_array_5()
  {
    context_properties props = { context_platform((cl_platform_id)0x1234ul),
                                 context_interop_user_sync(true) };
    cl_context_properties array[1];
    TS_ASSERT_THROWS(context_properties_fill_array(props,array,1), not_enough_space_error);
  }
  /** // doc: test_context_properties_fill_array_6() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_fill_array_6()
  {
    context_properties props;
    cl_context_properties array[1];
    TS_ASSERT_THROWS(context_properties_fill_array(props,array,0), not_enough_space_error);
  }
  /** // doc: test_context_properties_parse_array_6() {{{
   * \todo Write documentation
   */ // }}}
  void test_context_properties_parse_array_6()
  {
    cl_context_properties array[] = {
      CL_CONTEXT_PLATFORM, (cl_context_properties)0x12345,
      CL_CONTEXT_INTEROP_USER_SYNC, (cl_context_properties)CL_TRUE,
      (cl_context_properties)0ul
    };
    context_properties cp;
    TS_ASSERT_EQUALS(context_properties_parse_array(cp, array), 4);
    TS_ASSERT_EQUALS(cp[0].name(), context_properties_t::platform);
    TS_ASSERT_EQUALS(cp[0].value(), (cl_context_properties)0x12345);
    TS_ASSERT_EQUALS(cp[1].name(), context_properties_t::interop_user_sync);
    TS_ASSERT_EQUALS(cp[1].value(), (cl_context_properties)CL_TRUE);
  }
  /** // doc: test_op_and_1() {{{
   * \todo Write documentation
   */ // }}}
  void test_op_and_1()
  {
    context_properties cp(context_platform((cl_platform_id)0x1234) & context_interop_user_sync(true));
    TS_ASSERT_EQUALS(cp.size(), 2);
    TS_ASSERT_EQUALS(cp[0].name(), context_properties_t::platform);
    TS_ASSERT_EQUALS(cp[0].value(), (cl_context_properties)0x1234);
    TS_ASSERT_EQUALS(cp[1].name(), context_properties_t::interop_user_sync);
    TS_ASSERT_EQUALS(cp[1].value(), (cl_context_properties)CL_TRUE);
  }
  /** // doc: test_op_and_2() {{{
   * \todo Write documentation
   */ // }}}
  void test_op_and_2()
  {
    context_properties cp1;
    cp1.push_back(context_platform((cl_platform_id)0x1234));
    context_properties cp(cp1 & context_interop_user_sync(true));
    TS_ASSERT_EQUALS(cp.size(), 2);
    TS_ASSERT_EQUALS(cp[0].name(), context_properties_t::platform);
    TS_ASSERT_EQUALS(cp[0].value(), (cl_context_properties)0x1234);
    TS_ASSERT_EQUALS(cp[1].name(), context_properties_t::interop_user_sync);
    TS_ASSERT_EQUALS(cp[1].value(), (cl_context_properties)CL_TRUE);
  }
  /** // doc: test_op_and_3() {{{
   * \todo Write documentation
   */ // }}}
  void test_op_and_3()
  {
    context_properties cp2;
    cp2.push_back(context_interop_user_sync(true));
    context_properties cp(context_platform((cl_platform_id)0x1234) & cp2);
    TS_ASSERT_EQUALS(cp.size(), 2);
    TS_ASSERT_EQUALS(cp[0].name(), context_properties_t::platform);
    TS_ASSERT_EQUALS(cp[0].value(), (cl_context_properties)0x1234);
    TS_ASSERT_EQUALS(cp[1].name(), context_properties_t::interop_user_sync);
    TS_ASSERT_EQUALS(cp[1].value(), (cl_context_properties)CL_TRUE);
  }
  /** // doc: test_op_and_4() {{{
   * \todo Write documentation
   */ // }}}
  void test_op_and_4()
  {
    context_properties cp(context_platform((cl_platform_id)0x1234) & context_interop_user_sync(true) & context_gl_context_khr((void*)0x5678));
    TS_ASSERT_EQUALS(cp.size(), 3);
    TS_ASSERT_EQUALS(cp[0].name(), context_properties_t::platform);
    TS_ASSERT_EQUALS(cp[0].value(), (cl_context_properties)0x1234);
    TS_ASSERT_EQUALS(cp[1].name(), context_properties_t::interop_user_sync);
    TS_ASSERT_EQUALS(cp[1].value(), (cl_context_properties)CL_TRUE);
    TS_ASSERT_EQUALS(cp[2].name(), context_properties_t::gl_context_khr);
    TS_ASSERT_EQUALS(cp[2].value(), (cl_context_properties)0x5678);
  }
  /** // doc: test_make_context_properties() {{{
   * \todo Write documentation
   */ // }}}
  void test_make_context_properties()
  {
    platform p1((cl_platform_id)0x1234);
    platform p2((cl_platform_id)0x5678);
    TS_ASSERT_THROWS_NOTHING(make_context_properties());
    TS_ASSERT_THROWS_NOTHING(make_context_properties(context_platform(p1)));
    TS_ASSERT_THROWS_NOTHING(make_context_properties(p1));
    TS_ASSERT_THROWS_NOTHING(make_context_properties(p1,context_interop_user_sync(true)));
    TS_ASSERT_THROWS_NOTHING(make_context_properties(p1,context_interop_user_sync(true)));
    TS_ASSERT_THROWS_NOTHING(make_context_properties(p1,p2,context_interop_user_sync(true)));
    TS_ASSERT_THROWS_NOTHING(make_context_properties(make_context_properties(p1,p2),context_interop_user_sync(true)));
    TS_ASSERT_THROWS_NOTHING(make_context_properties(p1,make_context_properties(p2,context_interop_user_sync(true))));

    TS_ASSERT_EQUALS(make_context_properties().size(), 0);
    TS_ASSERT_EQUALS(make_context_properties(p1).size(), 1);
    TS_ASSERT_EQUALS(make_context_properties(p1,p2).size(), 2);
    TS_ASSERT_EQUALS(make_context_properties(p1,p2,context_interop_user_sync(true)).size(),3);
  }
};

#endif /* CLXX_CONTEXT_PROPERTIES_T_H_INCLUDED */
// vim: set expandtab tabstop=2 shiftwidth=2:
// vim: set foldmethod=marker foldcolumn=4:


text:
package org.lnu.is.converter.degree.type;

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.List;

import org.junit.Test;
import org.lnu.is.domain.degree.type.DegreeType;
import org.lnu.is.resource.degree.type.DegreeTypeResource;

public class DegreeTypeResourceConverterTest {

	private DegreeTypeResourceConverter unit = new DegreeTypeResourceConverter();

	@Test
	public void testConvert() throws Exception {
		// Given
		String name = "DegreeN";
		String abbrName = "AN";

		DegreeType expected = new DegreeType();
		expected.setName(name);
		expected.setAbbrName(abbrName);

		DegreeTypeResource source = new DegreeTypeResource();
		source.setName(name);
		source.setAbbrName(abbrName);

		// When
		DegreeType actual = unit.convert(source);

		// Then
		assertEquals(expected, actual);
	}

	@Test
	public void testConvertAll() throws Exception {
		// Given
		Long id = 1l;
		String abbrName = "abbr Name";
		String name = "n a m e";

		DegreeTypeResource source = new DegreeTypeResource();
		source.setId(id);
		source.setAbbrName(abbrName);
		source.setName(name);

		List<DegreeTypeResource> sources = Arrays.asList(source);

		DegreeType expected = new DegreeType();
		expected.setId(id);
		expected.setAbbrName(abbrName);
		expected.setName(name);

		List<DegreeType> expecteds = Arrays.asList(expected);

		// Where
		List<DegreeType> actuals = unit.convertAll(sources);

		//Then
		assertEquals(expecteds, actuals);
	}
}


text:
import webpack from 'webpack';
import Config from 'webpack-config';

const env = process.env.NODE_ENV;
const inProduction = env === 'production';

export default new Config().merge({
  plugins: inProduction ? [
    new webpack.DefinePlugin(env),
    new webpack.optimize.UglifyJsPlugin({
      mangle: true,
      compress: {
        screw_ie8: true,
        warnings: false,
        comparisons: false,
      },
      output: {
        comments: false,
        ascii_only: true,
      },
    }),
  ] : [],
});


text:
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="recovery_installing" msgid="7864047928003865598">"Installerer systemoppdateringen ..."</string>
    <string name="recovery_erasing" msgid="4612809744968710197">"Sletter ..."</string>
    <string name="recovery_no_command" msgid="1915703879031023455">"Ingen kommando."</string>
    <string name="recovery_error" msgid="4550265746256727080">"Feil!"</string>
</resources>


text:
package org.cagrid.introduce.security.tests.service;

import gov.nih.nci.cagrid.common.Utils;

import java.rmi.RemoteException;

/**
 * TODO:I am the service side implementation class.  IMPLEMENT AND DOCUMENT ME
 *
 * @created by Introduce Toolkit version 1.3
 *
 */
public class SecurityTestsImpl extends SecurityTestsImplBase {

	public SecurityTestsImpl() throws RemoteException {
		super();
	}

  public java.lang.String anonPrefered() throws RemoteException {
    return org.cagrid.introduce.security.tests.service.globus.SecurityTestsAuthorization.getCallerIdentity();
  }

  public java.lang.String anonNotPrefered() throws RemoteException {
      return org.cagrid.introduce.security.tests.service.globus.SecurityTestsAuthorization.getCallerIdentity();
  }

}


text:
require 'rubygems'
require 'spork'
require 'sunspot_test/rspec'

Spork.prefork do
  # This file is copied to spec/ when you run 'rails generate rspec:install'
  ENV["RAILS_ENV"] ||= 'test'
  require "rails/application"
  require 'simplecov'
  SimpleCov.start 'rails'

  # Use of https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujutsu
  Spork.trap_method(Rails::Application, :reload_routes!)
  Spork.trap_method(Rails::Application::RoutesReloader, :reload!)

  # Prevent main application to eager_load in the prefork block (do not load files in autoload_paths)
  Spork.trap_method(Rails::Application, :eager_load!)

  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'
  require 'draper/rspec_integration'
  require 'email_spec'

  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|
    config.mock_with :rspec

    # Enable Specs to be targeted using :focus => true tag
    config.treat_symbols_as_metadata_keys_with_true_values = true
    config.filter_run :focus => true
    config.run_all_when_everything_filtered = true

    config.use_transactional_fixtures = true
    config.include Devise::TestHelpers, :type => :controller
    include CustomMatchers
    include EmailSpec::Helpers
    include EmailSpec::Matchers

    config.infer_base_class_for_anonymous_controllers = false
  end

  # Load all railties files
  Rails.application.railties.all { |r| r.eager_load! }

end

Spork.each_run do
  FactoryGirl.reload
end


text:
namespace base {
class Value;
}  // namespace base

namespace domain_reliability {

// The per-request data that is uploaded to the Domain Reliability collector.
struct DOMAIN_RELIABILITY_EXPORT DomainReliabilityBeacon {
 public:
  DomainReliabilityBeacon();
  ~DomainReliabilityBeacon();

  // Converts the Beacon to JSON format for uploading. Calculates the age
  // relative to an upload time of |upload_time|.
  base::Value* ToValue(base::TimeTicks upload_time,
                       base::TimeTicks last_network_change_time) const;

  // The URL that the beacon is reporting on, if included.
  std::string url;
  // The domain that the beacon is reporting on, if included.
  std::string domain;
  // The resource name that the beacon is reporting on, if included.
  std::string resource;
  // Status string (e.g. "ok", "dns.nxdomain", "http.403").
  std::string status;
  // Net error code.  Encoded as a string in the final JSON.
  int chrome_error;
  // IP address of the server the request went to.
  std::string server_ip;
  // Protocol used to make the request.
  std::string protocol;
  // HTTP response code returned by the server, or -1 if none was received.
  int http_response_code;
  // Elapsed time between starting and completing the request.
  base::TimeDelta elapsed;
  // Start time of the request.  Encoded as the request age in the final JSON.
  base::TimeTicks start_time;

  // Okay to copy and assign.
};

}  // namespace domain_reliability

#endif  // COMPONENTS_DOMAIN_RELIABILITY_BEACON_H_


text:
.class public Lcom/android/systemui/volume/MediaSessions;
.super Ljava/lang/Object;
.source "MediaSessions.java"

# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/android/systemui/volume/MediaSessions$1;,
        Lcom/android/systemui/volume/MediaSessions$2;,
        Lcom/android/systemui/volume/MediaSessions$Callbacks;,
        Lcom/android/systemui/volume/MediaSessions$H;,
        Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;
    }
.end annotation

# static fields
.field private static final TAG:Ljava/lang/String;

# instance fields
.field private final mCallbacks:Lcom/android/systemui/volume/MediaSessions$Callbacks;

.field private final mContext:Landroid/content/Context;

.field private final mHandler:Lcom/android/systemui/volume/MediaSessions$H;

.field private mInit:Z

.field private final mMgr:Landroid/media/session/MediaSessionManager;

.field private final mRecords:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Landroid/media/session/MediaSession$Token;",
            "Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;",
            ">;"
        }
    .end annotation
.end field

.field private final mRvc:Landroid/media/IRemoteVolumeController;

.field private final mSessionsListener:Landroid/media/session/MediaSessionManager$OnActiveSessionsChangedListener;

# direct methods
.method static synthetic -get0()Ljava/lang/String;
    .locals 1

    sget-object v0, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic -get1(Lcom/android/systemui/volume/MediaSessions;)Lcom/android/systemui/volume/MediaSessions$Callbacks;
    .locals 1

    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mCallbacks:Lcom/android/systemui/volume/MediaSessions$Callbacks;

    return-object v0
.end method

.method static synthetic -get2(Lcom/android/systemui/volume/MediaSessions;)Lcom/android/systemui/volume/MediaSessions$H;
    .locals 1

    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mHandler:Lcom/android/systemui/volume/MediaSessions$H;

    return-object v0
.end method

.method static synthetic -get3(Lcom/android/systemui/volume/MediaSessions;)Landroid/media/session/MediaSessionManager;
    .locals 1

    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mMgr:Landroid/media/session/MediaSessionManager;

    return-object v0
.end method

.method static synthetic -wrap0(Landroid/media/session/MediaController$PlaybackInfo;)Z
    .locals 1

    invoke-static {p0}, Lcom/android/systemui/volume/MediaSessions;->isRemote(Landroid/media/session/MediaController$PlaybackInfo;)Z

    move-result v0

    return v0
.end method

.method static synthetic -wrap1(Lcom/android/systemui/volume/MediaSessions;Landroid/media/session/ISessionController;I)V
    .locals 0

    invoke-direct {p0, p1, p2}, Lcom/android/systemui/volume/MediaSessions;->onRemoteVolumeChangedH(Landroid/media/session/ISessionController;I)V

    return-void
.end method

.method static synthetic -wrap2(Lcom/android/systemui/volume/MediaSessions;Landroid/media/session/ISessionController;)V
    .locals 0

    invoke-direct {p0, p1}, Lcom/android/systemui/volume/MediaSessions;->onUpdateRemoteControllerH(Landroid/media/session/ISessionController;)V

    return-void
.end method

.method static synthetic -wrap3(Lcom/android/systemui/volume/MediaSessions;Landroid/media/session/MediaSession$Token;Ljava/lang/String;Landroid/media/session/MediaController$PlaybackInfo;)V
    .locals 0

    invoke-direct {p0, p1, p2, p3}, Lcom/android/systemui/volume/MediaSessions;->updateRemoteH(Landroid/media/session/MediaSession$Token;Ljava/lang/String;Landroid/media/session/MediaController$PlaybackInfo;)V

    return-void
.end method

.method static constructor <clinit>()V
    .locals 1

    const-class v0, Lcom/android/systemui/volume/MediaSessions;

    invoke-static {v0}, Lcom/android/systemui/volume/Util;->logTag(Ljava/lang/Class;)Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/os/Looper;Lcom/android/systemui/volume/MediaSessions$Callbacks;)V
    .locals 2

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    new-instance v0, Lcom/android/systemui/volume/MediaSessions$1;

    invoke-direct {v0, p0}, Lcom/android/systemui/volume/MediaSessions$1;-><init>(Lcom/android/systemui/volume/MediaSessions;)V

    iput-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mSessionsListener:Landroid/media/session/MediaSessionManager$OnActiveSessionsChangedListener;

    new-instance v0, Lcom/android/systemui/volume/MediaSessions$2;

    invoke-direct {v0, p0}, Lcom/android/systemui/volume/MediaSessions$2;-><init>(Lcom/android/systemui/volume/MediaSessions;)V

    iput-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mRvc:Landroid/media/IRemoteVolumeController;

    iput-object p1, p0, Lcom/android/systemui/volume/MediaSessions;->mContext:Landroid/content/Context;

    new-instance v0, Lcom/android/systemui/volume/MediaSessions$H;

    const/4 v1, 0x0

    invoke-direct {v0, p0, p2, v1}, Lcom/android/systemui/volume/MediaSessions$H;-><init>(Lcom/android/systemui/volume/MediaSessions;Landroid/os/Looper;Lcom/android/systemui/volume/MediaSessions$H;)V

    iput-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mHandler:Lcom/android/systemui/volume/MediaSessions$H;

    const-string/jumbo v0, "media_session"

    invoke-virtual {p1, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/media/session/MediaSessionManager;

    iput-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mMgr:Landroid/media/session/MediaSessionManager;

    iput-object p3, p0, Lcom/android/systemui/volume/MediaSessions;->mCallbacks:Lcom/android/systemui/volume/MediaSessions$Callbacks;

    return-void
.end method

.method private static dump(ILjava/io/PrintWriter;Landroid/media/session/MediaController;)V
    .locals 18

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "  Controller "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    move-object/from16 v0, v16

    move/from16 v1, p0

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v16

    const-string/jumbo v17, ": "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getPackageName()Ljava/lang/String;

    move-result-object v17

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getExtras()Landroid/os/Bundle;

    move-result-object v2

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getFlags()J

    move-result-wide v4

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getMetadata()Landroid/media/MediaMetadata;

    move-result-object v7

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getPlaybackInfo()Landroid/media/session/MediaController$PlaybackInfo;

    move-result-object v8

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getPlaybackState()Landroid/media/session/PlaybackState;

    move-result-object v9

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getQueue()Ljava/util/List;

    move-result-object v12

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getQueueTitle()Ljava/lang/CharSequence;

    move-result-object v13

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getRatingType()I

    move-result v14

    invoke-virtual/range {p2 .. p2}, Landroid/media/session/MediaController;->getSessionActivity()Landroid/app/PendingIntent;

    move-result-object v15

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "    PlaybackState: "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-static {v9}, Lcom/android/systemui/volume/Util;->playbackStateToString(Landroid/media/session/PlaybackState;)Ljava/lang/String;

    move-result-object v17

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "    PlaybackInfo: "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-static {v8}, Lcom/android/systemui/volume/Util;->playbackInfoToString(Landroid/media/session/MediaController$PlaybackInfo;)Ljava/lang/String;

    move-result-object v17

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    if-eqz v7, :cond_0

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "  MediaMetadata.desc="

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual {v7}, Landroid/media/MediaMetadata;->getDescription()Landroid/media/MediaDescription;

    move-result-object v17

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    :cond_0
    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "    RatingType: "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    move-object/from16 v0, v16

    invoke-virtual {v0, v14}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "    Flags: "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    move-object/from16 v0, v16

    invoke-virtual {v0, v4, v5}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    if-eqz v2, :cond_1

    const-string/jumbo v16, "    Extras:"

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    invoke-virtual {v2}, Landroid/os/Bundle;->keySet()Ljava/util/Set;

    move-result-object v16

    invoke-interface/range {v16 .. v16}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v6

    :goto_0
    invoke-interface {v6}, Ljava/util/Iterator;->hasNext()Z

    move-result v16

    if-eqz v16, :cond_1

    invoke-interface {v6}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "      "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    move-object/from16 v0, v16

    invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    const-string/jumbo v17, "="

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual {v2, v3}, Landroid/os/Bundle;->get(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v17

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    goto :goto_0

    :cond_1
    if-eqz v13, :cond_2

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "    QueueTitle: "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    move-object/from16 v0, v16

    invoke-virtual {v0, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/CharSequence;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    :cond_2
    if-eqz v12, :cond_3

    invoke-interface {v12}, Ljava/util/List;->isEmpty()Z

    move-result v16

    xor-int/lit8 v16, v16, 0x1

    if-eqz v16, :cond_3

    const-string/jumbo v16, "    Queue:"

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    invoke-interface {v12}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v11

    :goto_1
    invoke-interface {v11}, Ljava/util/Iterator;->hasNext()Z

    move-result v16

    if-eqz v16, :cond_3

    invoke-interface {v11}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v10

    check-cast v10, Landroid/media/session/MediaSession$QueueItem;

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "      "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    move-object/from16 v0, v16

    invoke-virtual {v0, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    goto :goto_1

    :cond_3
    if-eqz v8, :cond_4

    new-instance v16, Ljava/lang/StringBuilder;

    invoke-direct/range {v16 .. v16}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v17, "    sessionActivity: "

    invoke-virtual/range {v16 .. v17}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v16

    move-object/from16 v0, v16

    invoke-virtual {v0, v15}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v16

    invoke-virtual/range {v16 .. v16}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v16

    move-object/from16 v0, p1

    move-object/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    :cond_4
    return-void
.end method

.method private static isRemote(Landroid/media/session/MediaController$PlaybackInfo;)Z
    .locals 3

    const/4 v0, 0x0

    if-eqz p0, :cond_0

    invoke-virtual {p0}, Landroid/media/session/MediaController$PlaybackInfo;->getPlaybackType()I

    move-result v1

    const/4 v2, 0x2

    if-ne v1, v2, :cond_0

    const/4 v0, 0x1

    :cond_0
    return v0
.end method

.method private onRemoteVolumeChangedH(Landroid/media/session/ISessionController;I)V
    .locals 5

    new-instance v0, Landroid/media/session/MediaController;

    iget-object v2, p0, Lcom/android/systemui/volume/MediaSessions;->mContext:Landroid/content/Context;

    invoke-direct {v0, v2, p1}, Landroid/media/session/MediaController;-><init>(Landroid/content/Context;Landroid/media/session/ISessionController;)V

    sget-boolean v2, Lcom/android/systemui/volume/D;->BUG:Z

    if-eqz v2, :cond_0

    sget-object v2, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v4, "remoteVolumeChangedH "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v0}, Landroid/media/session/MediaController;->getPackageName()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string/jumbo v4, " "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-static {p2}, Lcom/android/systemui/volume/Util;->audioManagerFlagsToString(I)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    :cond_0
    invoke-virtual {v0}, Landroid/media/session/MediaController;->getSessionToken()Landroid/media/session/MediaSession$Token;

    move-result-object v1

    iget-object v2, p0, Lcom/android/systemui/volume/MediaSessions;->mCallbacks:Lcom/android/systemui/volume/MediaSessions$Callbacks;

    invoke-interface {v2, v1, p2}, Lcom/android/systemui/volume/MediaSessions$Callbacks;->onRemoteVolumeChanged(Landroid/media/session/MediaSession$Token;I)V

    return-void
.end method

.method private onUpdateRemoteControllerH(Landroid/media/session/ISessionController;)V
    .locals 5

    if-eqz p1, :cond_1

    new-instance v0, Landroid/media/session/MediaController;

    iget-object v2, p0, Lcom/android/systemui/volume/MediaSessions;->mContext:Landroid/content/Context;

    invoke-direct {v0, v2, p1}, Landroid/media/session/MediaController;-><init>(Landroid/content/Context;Landroid/media/session/ISessionController;)V

    :goto_0
    if-eqz v0, :cond_2

    invoke-virtual {v0}, Landroid/media/session/MediaController;->getPackageName()Ljava/lang/String;

    move-result-object v1

    :goto_1
    sget-boolean v2, Lcom/android/systemui/volume/D;->BUG:Z

    if-eqz v2, :cond_0

    sget-object v2, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v4, "updateRemoteControllerH "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    :cond_0
    invoke-virtual {p0}, Lcom/android/systemui/volume/MediaSessions;->postUpdateSessions()V

    return-void

    :cond_1
    const/4 v0, 0x0

    goto :goto_0

    :cond_2
    const/4 v1, 0x0

    goto :goto_1
.end method

.method private updateRemoteH(Landroid/media/session/MediaSession$Token;Ljava/lang/String;Landroid/media/session/MediaController$PlaybackInfo;)V
    .locals 1

    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mCallbacks:Lcom/android/systemui/volume/MediaSessions$Callbacks;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mCallbacks:Lcom/android/systemui/volume/MediaSessions$Callbacks;

    invoke-interface {v0, p1, p2, p3}, Lcom/android/systemui/volume/MediaSessions$Callbacks;->onRemoteUpdate(Landroid/media/session/MediaSession$Token;Ljava/lang/String;Landroid/media/session/MediaController$PlaybackInfo;)V

    :cond_0
    return-void
.end method

# virtual methods
.method public dump(Ljava/io/PrintWriter;)V
    .locals 6

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {p0}, Lcom/android/systemui/volume/MediaSessions;->getClass()Ljava/lang/Class;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string/jumbo v5, " state:"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {p1, v4}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    const-string/jumbo v4, "  mInit: "

    invoke-virtual {p1, v4}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget-boolean v4, p0, Lcom/android/systemui/volume/MediaSessions;->mInit:Z

    invoke-virtual {p1, v4}, Ljava/io/PrintWriter;->println(Z)V

    const-string/jumbo v4, "  mRecords.size: "

    invoke-virtual {p1, v4}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget-object v4, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v4}, Ljava/util/HashMap;->size()I

    move-result v4

    invoke-virtual {p1, v4}, Ljava/io/PrintWriter;->println(I)V

    const/4 v1, 0x0

    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iget-object v4, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v4}, Ljava/util/HashMap;->clone()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->values()Ljava/util/Collection;

    move-result-object v4

    invoke-interface {v4}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v3

    :goto_0
    invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-eqz v4, :cond_0

    invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;

    add-int/lit8 v1, v1, 0x1

    invoke-static {v2}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-get0(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)Landroid/media/session/MediaController;

    move-result-object v4

    invoke-static {v1, p1, v4}, Lcom/android/systemui/volume/MediaSessions;->dump(ILjava/io/PrintWriter;Landroid/media/session/MediaController;)V

    goto :goto_0

    :cond_0
    return-void
.end method

.method protected getControllerName(Landroid/media/session/MediaController;)Ljava/lang/String;
    .locals 7

    iget-object v5, p0, Lcom/android/systemui/volume/MediaSessions;->mContext:Landroid/content/Context;

    invoke-virtual {v5}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v4

    invoke-virtual {p1}, Landroid/media/session/MediaController;->getPackageName()Ljava/lang/String;

    move-result-object v3

    const/4 v5, 0x0

    :try_start_0
    invoke-virtual {v4, v3, v5}, Landroid/content/pm/PackageManager;->getApplicationInfo(Ljava/lang/String;I)Landroid/content/pm/ApplicationInfo;

    move-result-object v0

    invoke-virtual {v0, v4}, Landroid/content/pm/ApplicationInfo;->loadLabel(Landroid/content/pm/PackageManager;)Ljava/lang/CharSequence;

    move-result-object v5

    const-string/jumbo v6, ""

    invoke-static {v5, v6}, Ljava/util/Objects;->toString(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/String;->length()I
    :try_end_0
    .catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v5

    if-lez v5, :cond_0

    return-object v1

    :catch_0
    move-exception v2

    :cond_0
    return-object v3
.end method

.method public init()V
    .locals 4

    sget-boolean v0, Lcom/android/systemui/volume/D;->BUG:Z

    if-eqz v0, :cond_0

    sget-object v0, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    const-string/jumbo v1, "init"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    :cond_0
    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mMgr:Landroid/media/session/MediaSessionManager;

    iget-object v1, p0, Lcom/android/systemui/volume/MediaSessions;->mSessionsListener:Landroid/media/session/MediaSessionManager$OnActiveSessionsChangedListener;

    iget-object v2, p0, Lcom/android/systemui/volume/MediaSessions;->mHandler:Lcom/android/systemui/volume/MediaSessions$H;

    const/4 v3, 0x0

    invoke-virtual {v0, v1, v3, v2}, Landroid/media/session/MediaSessionManager;->addOnActiveSessionsChangedListener(Landroid/media/session/MediaSessionManager$OnActiveSessionsChangedListener;Landroid/content/ComponentName;Landroid/os/Handler;)V

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/android/systemui/volume/MediaSessions;->mInit:Z

    invoke-virtual {p0}, Lcom/android/systemui/volume/MediaSessions;->postUpdateSessions()V

    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mMgr:Landroid/media/session/MediaSessionManager;

    iget-object v1, p0, Lcom/android/systemui/volume/MediaSessions;->mRvc:Landroid/media/IRemoteVolumeController;

    invoke-virtual {v0, v1}, Landroid/media/session/MediaSessionManager;->setRemoteVolumeController(Landroid/media/IRemoteVolumeController;)V

    return-void
.end method

.method protected onActiveSessionsUpdatedH(Ljava/util/List;)V
    .locals 12
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List",
            "<",
            "Landroid/media/session/MediaController;",
            ">;)V"
        }
    .end annotation

    sget-boolean v9, Lcom/android/systemui/volume/D;->BUG:Z

    if-eqz v9, :cond_0

    sget-object v9, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    new-instance v10, Ljava/lang/StringBuilder;

    invoke-direct {v10}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v11, "onActiveSessionsUpdatedH n="

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-interface {p1}, Ljava/util/List;->size()I

    move-result v11

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    :cond_0
    new-instance v7, Ljava/util/HashSet;

    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v9}, Ljava/util/HashMap;->keySet()Ljava/util/Set;

    move-result-object v9

    invoke-direct {v7, v9}, Ljava/util/HashSet;-><init>(Ljava/util/Collection;)V

    invoke-interface {p1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :cond_1
    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v9

    if-eqz v9, :cond_3

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/media/session/MediaController;

    invoke-virtual {v0}, Landroid/media/session/MediaController;->getSessionToken()Landroid/media/session/MediaSession$Token;

    move-result-object v8

    invoke-virtual {v0}, Landroid/media/session/MediaController;->getPlaybackInfo()Landroid/media/session/MediaController$PlaybackInfo;

    move-result-object v2

    invoke-interface {v7, v8}, Ljava/util/Set;->remove(Ljava/lang/Object;)Z

    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v9, v8}, Ljava/util/HashMap;->containsKey(Ljava/lang/Object;)Z

    move-result v9

    if-nez v9, :cond_2

    new-instance v3, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;

    const/4 v9, 0x0

    invoke-direct {v3, p0, v0, v9}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;-><init>(Lcom/android/systemui/volume/MediaSessions;Landroid/media/session/MediaController;Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)V

    invoke-virtual {p0, v0}, Lcom/android/systemui/volume/MediaSessions;->getControllerName(Landroid/media/session/MediaController;)Ljava/lang/String;

    move-result-object v9

    invoke-static {v3, v9}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-set0(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;Ljava/lang/String;)Ljava/lang/String;

    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v9, v8, v3}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mHandler:Lcom/android/systemui/volume/MediaSessions$H;

    invoke-virtual {v0, v3, v9}, Landroid/media/session/MediaController;->registerCallback(Landroid/media/session/MediaController$Callback;Landroid/os/Handler;)V

    :cond_2
    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v9, v8}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;

    invoke-static {v2}, Lcom/android/systemui/volume/MediaSessions;->isRemote(Landroid/media/session/MediaController$PlaybackInfo;)Z

    move-result v4

    if-eqz v4, :cond_1

    invoke-static {v3}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-get1(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)Ljava/lang/String;

    move-result-object v9

    invoke-direct {p0, v8, v9, v2}, Lcom/android/systemui/volume/MediaSessions;->updateRemoteH(Landroid/media/session/MediaSession$Token;Ljava/lang/String;Landroid/media/session/MediaController$PlaybackInfo;)V

    const/4 v9, 0x1

    invoke-static {v3, v9}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-set1(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;Z)Z

    goto :goto_0

    :cond_3
    invoke-interface {v7}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v6

    :cond_4
    :goto_1
    invoke-interface {v6}, Ljava/util/Iterator;->hasNext()Z

    move-result v9

    if-eqz v9, :cond_6

    invoke-interface {v6}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Landroid/media/session/MediaSession$Token;

    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v9, v5}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;

    invoke-static {v3}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-get0(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)Landroid/media/session/MediaController;

    move-result-object v9

    invoke-virtual {v9, v3}, Landroid/media/session/MediaController;->unregisterCallback(Landroid/media/session/MediaController$Callback;)V

    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v9, v5}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    sget-boolean v9, Lcom/android/systemui/volume/D;->BUG:Z

    if-eqz v9, :cond_5

    sget-object v9, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    new-instance v10, Ljava/lang/StringBuilder;

    invoke-direct {v10}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v11, "Removing "

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-static {v3}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-get1(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)Ljava/lang/String;

    move-result-object v11

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    const-string/jumbo v11, " sentRemote="

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-static {v3}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-get2(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)Z

    move-result v11

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    :cond_5
    invoke-static {v3}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-get2(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)Z

    move-result v9

    if-eqz v9, :cond_4

    iget-object v9, p0, Lcom/android/systemui/volume/MediaSessions;->mCallbacks:Lcom/android/systemui/volume/MediaSessions$Callbacks;

    invoke-interface {v9, v5}, Lcom/android/systemui/volume/MediaSessions$Callbacks;->onRemoteRemoved(Landroid/media/session/MediaSession$Token;)V

    const/4 v9, 0x0

    invoke-static {v3, v9}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-set1(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;Z)Z

    goto :goto_1

    :cond_6
    return-void
.end method

.method protected postUpdateSessions()V
    .locals 2

    iget-boolean v0, p0, Lcom/android/systemui/volume/MediaSessions;->mInit:Z

    if-nez v0, :cond_0

    return-void

    :cond_0
    iget-object v0, p0, Lcom/android/systemui/volume/MediaSessions;->mHandler:Lcom/android/systemui/volume/MediaSessions$H;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Lcom/android/systemui/volume/MediaSessions$H;->sendEmptyMessage(I)Z

    return-void
.end method

.method public setVolume(Landroid/media/session/MediaSession$Token;I)V
    .locals 4

    iget-object v1, p0, Lcom/android/systemui/volume/MediaSessions;->mRecords:Ljava/util/HashMap;

    invoke-virtual {v1, p1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;

    if-nez v0, :cond_0

    sget-object v1, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v3, "setVolume: No record found for token "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    return-void

    :cond_0
    sget-boolean v1, Lcom/android/systemui/volume/D;->BUG:Z

    if-eqz v1, :cond_1

    sget-object v1, Lcom/android/systemui/volume/MediaSessions;->TAG:Ljava/lang/String;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v3, "Setting level to "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    :cond_1
    invoke-static {v0}, Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;->-get0(Lcom/android/systemui/volume/MediaSessions$MediaControllerRecord;)Landroid/media/session/MediaController;

    move-result-object v1

    const/4 v2, 0x0

    invoke-virtual {v1, p2, v2}, Landroid/media/session/MediaController;->setVolumeTo(II)V

    return-void
.end method


text:
class ExampleCustomTableCellsScreen < PMListScreen
  stylesheet ExampleCustomTableCellsScreenStylesheet
  title "Example Custom Table Cells"

  def load_view
    mp "ExampleTableScreen load_view"
    Potion::ListView.new(self.activity)
  end

  def table_data
    [{
      # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # Illustrating a basic Cell - Nothing Fancy
      # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      title: "Custom Cell Table/ListView",
      cells: [{
        title: "I'm a Regular Cell"
      },{
      # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # Illustrating a XML Cell - Update via Screen
      # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        title: "XML Custom Image Cell 1",
        cell_xml: R::Layout::Image_cell,
        update: :update_xml_cell,
        action: :make_magic,
        arguments: { saying: "SUCH WOW" }
      },{
        title: "XML Custom Imge Cell 2",
        cell_xml: R::Layout::Image_cell,
        update: :update_xml_cell,
        action: :make_magic,
        arguments: { other_saying: "MUCH AMAZE" }
      }
      #,{
      ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ## Illustrating Cell Class - Update via Class
      ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        #cell_class: ImageCell,
        #action: :make_magic,
        #arguments: { simple: "!!!!!"},
        #properties: {
          #custom_name: "Random Color Cell Class",
          #color: rmq.color.random,
          #i_dont_exist: true
        #}
      #}
      ]
    }]
  end

  # Cell logic in the screen for XML
  def make_magic(args, position)
    mp args
  end

  def update_xml_cell(cell, cell_data)
    # Let's set the cell info - specific to Image_cell
    rmq_cell = find(cell)
    rmq_cell.find(Potion::Label).data = cell_data[:title]
    rmq_cell.find(Potion::ImageView).get.imageResource = rmq.image.resource("ic_launcher")
  end
end