From your activity, you can retrieve an instance of {@link com.actionbarsherlock.app.ActionBar} by calling {@link
+ *
From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link
* android.app.Activity#getActionBar getActionBar()}.
*
In some cases, the action bar may be overlayed by another bar that enables contextual actions,
* using an {@link android.view.ActionMode}. For example, when the user selects one or more items in
* your activity, you can enable an action mode that offers actions specific to the selected
* items, with a UI that temporarily replaces the action bar. Although the UI may occupy the
* same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for
- * {@link com.actionbarsherlock.app.ActionBar}.
+ * {@link ActionBar}.
*
*
Developer Guides
*
For information about how to use the action bar, including how to add action items, navigation
@@ -496,7 +496,7 @@ public abstract class ActionBar {
public abstract int getDisplayOptions();
/**
- * Create and return a new {@link com.actionbarsherlock.app.ActionBar.Tab}.
+ * Create and return a new {@link Tab}.
* This tab will not be included in the action bar until it is added.
*
*
Very often tabs will be used to switch between {@link Fragment}
@@ -507,7 +507,7 @@ public abstract class ActionBar {
*
* @return A new Tab
*
- * @see #addTab(com.actionbarsherlock.app.ActionBar.Tab)
+ * @see #addTab(Tab)
*/
public abstract Tab newTab();
@@ -807,7 +807,7 @@ public abstract class ActionBar {
public abstract Object getTag();
/**
- * Set the {@link com.actionbarsherlock.app.ActionBar.TabListener} that will handle switching to and from this tab.
+ * Set the {@link TabListener} that will handle switching to and from this tab.
* All tabs must have a TabListener set before being added to the ActionBar.
*
* @param listener Listener to handle tab selection events
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java
index 9e1abc206..2caf5b4a9 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/Animator.java
@@ -36,7 +36,7 @@ public abstract class Animator implements Cloneable {
* Starts this animation. If the animation has a nonzero startDelay, the animation will start
* running after that delay elapses. A non-delayed animation will have its initial
* value(s) set immediately, followed by calls to
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.Animator.AnimatorListener#onAnimationStart(com.actionbarsherlock.internal.nineoldandroids.animation.Animator)} for any listeners of this animator.
+ * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator.
*
*
The animation started by calling this method will be run on the thread that called
* this method. This thread should have a Looper on it (a runtime exception will be thrown if
@@ -51,9 +51,9 @@ public abstract class Animator implements Cloneable {
/**
* Cancels the animation. Unlike {@link #end()}, cancel() causes the animation to
* stop in its tracks, sending an
- * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(com.actionbarsherlock.internal.nineoldandroids.animation.Animator)} to
+ * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
* its listeners, followed by an
- * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(com.actionbarsherlock.internal.nineoldandroids.animation.Animator)} message.
+ * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
*
*
This method must be called on the thread that is running the animation.
*/
@@ -63,7 +63,7 @@ public abstract class Animator implements Cloneable {
/**
* Ends the animation. This causes the animation to assign the end value of the property being
* animated, then calling the
- * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(com.actionbarsherlock.internal.nineoldandroids.animation.Animator)} method on
+ * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on
* its listeners.
*
*
This method must be called on the thread that is running the animation.
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
index cbb06657d..3231080c4 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/AnimatorSet.java
@@ -28,10 +28,10 @@ import android.view.animation.Interpolator;
* can be set up to play together, in sequence, or after a specified delay.
*
*
There are two different approaches to adding animations to a AnimatorSet:
- * either the {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#playTogether(Animator[]) playTogether()} or
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add
- * a set of animations all at once, or the {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} can be
- * used in conjunction with methods in the {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet.Builder Builder}
+ * either the {@link AnimatorSet#playTogether(Animator[]) playTogether()} or
+ * {@link AnimatorSet#playSequentially(Animator[]) playSequentially()} methods can be called to add
+ * a set of animations all at once, or the {@link AnimatorSet#play(Animator)} can be
+ * used in conjunction with methods in the {@link AnimatorSet.Builder Builder}
* class to add animations
* one by one.
*
@@ -959,14 +959,14 @@ public final class AnimatorSet extends Animator {
* The Builder object is a utility class to facilitate adding animations to a
* AnimatorSet along with the relationships between the various animations. The
* intention of the Builder methods, along with the {@link
- * com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator) play()} method of AnimatorSet is to make it possible
+ * AnimatorSet#play(Animator) play()} method of AnimatorSet is to make it possible
* to express the dependency relationships of animations in a natural way. Developers can also
- * use the {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#playTogether(Animator[]) playTogether()} and {@link
- * com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need,
+ * use the {@link AnimatorSet#playTogether(Animator[]) playTogether()} and {@link
+ * AnimatorSet#playSequentially(Animator[]) playSequentially()} methods if these suit the need,
* but it might be easier in some situations to express the AnimatorSet of animations in pairs.
*
*
The Builder object cannot be constructed directly, but is rather constructed
- * internally via a call to {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)}.
+ * internally via a call to {@link AnimatorSet#play(Animator)}.
*
*
For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to
* play when anim2 finishes, and anim4 to play when anim3 finishes:
@@ -977,14 +977,14 @@ public final class AnimatorSet extends Animator {
* s.play(anim4).after(anim3);
*
*
- *
Note in the example that both {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet.Builder#before(Animator)} and {@link
- * com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet.Builder#after(Animator)} are used. These are just different ways of expressing the same
+ *
Note in the example that both {@link Builder#before(Animator)} and {@link
+ * Builder#after(Animator)} are used. These are just different ways of expressing the same
* relationship and are provided to make it easier to say things in a way that is more natural,
* depending on the situation.
*
*
It is possible to make several calls into the same Builder object to express
* multiple relationships. However, note that it is only the animation passed into the initial
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} method that is the dependency in any of the successive
+ * {@link AnimatorSet#play(Animator)} method that is the dependency in any of the successive
* calls to the Builder object. For example, the following code starts both anim2
* and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and
* anim3:
@@ -1033,10 +1033,10 @@ public final class AnimatorSet extends Animator {
/**
* Sets up the given animation to play at the same time as the animation supplied in the
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} call that created this Builder object.
+ * {@link AnimatorSet#play(Animator)} call that created this Builder object.
*
* @param anim The animation that will play when the animation supplied to the
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} method starts.
+ * {@link AnimatorSet#play(Animator)} method starts.
*/
public Builder with(Animator anim) {
Node node = mNodeMap.get(anim);
@@ -1052,11 +1052,11 @@ public final class AnimatorSet extends Animator {
/**
* Sets up the given animation to play when the animation supplied in the
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} call that created this Builder object
+ * {@link AnimatorSet#play(Animator)} call that created this Builder object
* ends.
*
* @param anim The animation that will play when the animation supplied to the
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} method ends.
+ * {@link AnimatorSet#play(Animator)} method ends.
*/
public Builder before(Animator anim) {
Node node = mNodeMap.get(anim);
@@ -1072,11 +1072,11 @@ public final class AnimatorSet extends Animator {
/**
* Sets up the given animation to play when the animation supplied in the
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} call that created this Builder object
+ * {@link AnimatorSet#play(Animator)} call that created this Builder object
* to start when the animation supplied in this method call ends.
*
* @param anim The animation whose end will cause the animation supplied to the
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} method to play.
+ * {@link AnimatorSet#play(Animator)} method to play.
*/
public Builder after(Animator anim) {
Node node = mNodeMap.get(anim);
@@ -1092,7 +1092,7 @@ public final class AnimatorSet extends Animator {
/**
* Sets up the animation supplied in the
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet#play(Animator)} call that created this Builder object
+ * {@link AnimatorSet#play(Animator)} call that created this Builder object
* to play when the given amount of time elapses.
*
* @param delay The number of milliseconds that should elapse before the
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java
index 65b9efc9b..0ea319244 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/TypeEvaluator.java
@@ -17,12 +17,12 @@
package com.actionbarsherlock.internal.nineoldandroids.animation;
/**
- * Interface for use with the {@link ValueAnimator#setEvaluator(com.actionbarsherlock.internal.nineoldandroids.animation.TypeEvaluator)} function. Evaluators
+ * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators
* allow developers to create animations on arbitrary property types, by allowing them to supply
* custom evaulators for types that are not automatically understood and used by the animation
* system.
*
- * @see ValueAnimator#setEvaluator(com.actionbarsherlock.internal.nineoldandroids.animation.TypeEvaluator)
+ * @see ValueAnimator#setEvaluator(TypeEvaluator)
*/
public interface TypeEvaluator {
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
index 401d476be..d8a12c688 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/animation/ValueAnimator.java
@@ -38,7 +38,7 @@ import java.util.HashMap;
*
By default, ValueAnimator uses non-linear time interpolation, via the
* {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates
* out of an animation. This behavior can be changed by calling
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator#setInterpolator(TimeInterpolator)}.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class ValueAnimator extends Animator {
@@ -733,7 +733,7 @@ public class ValueAnimator extends Animator {
* The most recent value calculated by this ValueAnimator when there is just one
* property being animated. This value is only sensible while the animation is running. The main
* purpose for this read-only property is to retrieve the value from the ValueAnimator
- * during a call to {@link com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator)}, which
+ * during a call to {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
* is called during each animation frame, immediately after the value is calculated.
*
* @return animatedValue The value most recently calculated by this ValueAnimator for
@@ -753,7 +753,7 @@ public class ValueAnimator extends Animator {
* The most recent value calculated by this ValueAnimator for propertyName.
* The main purpose for this read-only property is to retrieve the value from the
* ValueAnimator during a call to
- * {@link com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator)}, which
+ * {@link AnimatorUpdateListener#onAnimationUpdate(ValueAnimator)}, which
* is called during each animation frame, immediately after the value is calculated.
*
* @return animatedValue The value most recently calculated for the named property
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java
index 9fa9875e7..c3f35472c 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/MenuPresenter.java
@@ -51,7 +51,7 @@ public interface MenuPresenter {
/**
* Initialize this presenter for the given context and menu.
* This method is called by MenuBuilder when a presenter is
- * added. See {@link MenuBuilder#addMenuPresenter(com.actionbarsherlock.internal.view.menu.MenuPresenter)}
+ * added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)}
*
* @param context Context for this presenter; used for view creation and resource management
* @param menu Menu to host
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java
index 0531cb27e..ce0cb3bca 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsAbsSpinner.java
@@ -261,7 +261,7 @@ public abstract class IcsAbsSpinner extends IcsAdapterView {
void recycleAllViews() {
final int childCount = getChildCount();
- final RecycleBin recycleBin = mRecycler;
+ final IcsAbsSpinner.RecycleBin recycleBin = mRecycler;
final int position = mFirstPosition;
// All views go in recycler
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java
index 433783c7c..1c02d4aca 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/IcsProgressBar.java
@@ -1080,7 +1080,7 @@ public class IcsProgressBar extends View {
int secondaryProgress;
/**
- * Constructor called from {@link com.actionbarsherlock.internal.widget.IcsProgressBar#onSaveInstanceState()}
+ * Constructor called from {@link IcsProgressBar#onSaveInstanceState()}
*/
SavedState(Parcelable superState) {
super(superState);
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/ActionMode.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/ActionMode.java
index 73f187695..7551dbf6c 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/ActionMode.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/ActionMode.java
@@ -112,16 +112,16 @@ public abstract class ActionMode {
/**
* Invalidate the action mode and refresh menu content. The mode's
- * {@link com.actionbarsherlock.view.ActionMode.Callback} will have its
- * {@link com.actionbarsherlock.view.ActionMode.Callback#onPrepareActionMode(com.actionbarsherlock.view.ActionMode, Menu)} method called.
+ * {@link ActionMode.Callback} will have its
+ * {@link Callback#onPrepareActionMode(ActionMode, Menu)} method called.
* If it returns true the menu will be scanned for updated content and any relevant changes
* will be reflected to the user.
*/
public abstract void invalidate();
/**
- * Finish and close this action mode. The action mode's {@link com.actionbarsherlock.view.ActionMode.Callback} will
- * have its {@link com.actionbarsherlock.view.ActionMode.Callback#onDestroyActionMode(com.actionbarsherlock.view.ActionMode)} method called.
+ * Finish and close this action mode. The action mode's {@link ActionMode.Callback} will
+ * have its {@link Callback#onDestroyActionMode(ActionMode)} method called.
*/
public abstract void finish();
@@ -168,18 +168,18 @@ public abstract class ActionMode {
/**
* Callback interface for action modes. Supplied to
- * {@link View#startActionMode(com.actionbarsherlock.view.ActionMode.Callback)}, a Callback
+ * {@link View#startActionMode(Callback)}, a Callback
* configures and handles events raised by a user's interaction with an action mode.
*
*
An action mode's lifecycle is as follows:
*
- *
{@link com.actionbarsherlock.view.ActionMode.Callback#onCreateActionMode(com.actionbarsherlock.view.ActionMode, Menu)} once on initial
+ *
{@link Callback#onCreateActionMode(ActionMode, Menu)} once on initial
* creation
- *
{@link com.actionbarsherlock.view.ActionMode.Callback#onPrepareActionMode(com.actionbarsherlock.view.ActionMode, Menu)} after creation
- * and any time the {@link com.actionbarsherlock.view.ActionMode} is invalidated
- *
{@link com.actionbarsherlock.view.ActionMode.Callback#onActionItemClicked(com.actionbarsherlock.view.ActionMode, MenuItem)} any time a
+ *
{@link Callback#onPrepareActionMode(ActionMode, Menu)} after creation
+ * and any time the {@link ActionMode} is invalidated
+ *
{@link Callback#onActionItemClicked(ActionMode, MenuItem)} any time a
* contextual action button is clicked
- *
{@link com.actionbarsherlock.view.ActionMode.Callback#onDestroyActionMode(com.actionbarsherlock.view.ActionMode)} when the action mode
+ *
{@link Callback#onDestroyActionMode(ActionMode)} when the action mode
* is closed
* Setting the action provider on a {@link MenuItem} directly by calling
- * {@link MenuItem#setActionProvider(com.actionbarsherlock.view.ActionProvider)}.
+ * {@link MenuItem#setActionProvider(ActionProvider)}.
*
*
* Declaring the action provider in the menu XML resource. For example:
@@ -55,7 +55,7 @@ import android.view.View;
*
*
*
- * @see MenuItem#setActionProvider(com.actionbarsherlock.view.ActionProvider)
+ * @see MenuItem#setActionProvider(ActionProvider)
* @see MenuItem#getActionProvider()
*/
public abstract class ActionProvider {
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/Menu.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/Menu.java
index afb8c2990..951f4ccef 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/Menu.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/Menu.java
@@ -26,7 +26,7 @@ import android.view.KeyEvent;
* By default, every Activity supports an options menu of actions or options.
* You can add items to this menu and handle clicks on your additions. The
* easiest way of adding menu items is inflating an XML file into the
- * {@link com.actionbarsherlock.view.Menu} via {@link MenuInflater}. The easiest way of attaching code to
+ * {@link Menu} via {@link MenuInflater}. The easiest way of attaching code to
* clicks is via {@link Activity#onOptionsItemSelected(MenuItem)} and
* {@link Activity#onContextItemSelected(MenuItem)}.
*
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/MenuItem.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/MenuItem.java
index 25179bbe8..7fc3aa430 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/MenuItem.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/view/MenuItem.java
@@ -68,8 +68,8 @@ public interface MenuItem {
* Interface definition for a callback to be invoked when a menu item is
* clicked.
*
- * @see Activity#onContextItemSelected(com.actionbarsherlock.view.MenuItem)
- * @see Activity#onOptionsItemSelected(com.actionbarsherlock.view.MenuItem)
+ * @see Activity#onContextItemSelected(MenuItem)
+ * @see Activity#onOptionsItemSelected(MenuItem)
*/
public interface OnMenuItemClickListener {
/**
@@ -87,16 +87,16 @@ public interface MenuItem {
/**
* Interface definition for a callback to be invoked when a menu item
- * marked with {@link com.actionbarsherlock.view.MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} is
+ * marked with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW} is
* expanded or collapsed.
*
- * @see com.actionbarsherlock.view.MenuItem#expandActionView()
- * @see com.actionbarsherlock.view.MenuItem#collapseActionView()
- * @see com.actionbarsherlock.view.MenuItem#setShowAsActionFlags(int)
+ * @see MenuItem#expandActionView()
+ * @see MenuItem#collapseActionView()
+ * @see MenuItem#setShowAsActionFlags(int)
*/
public interface OnActionExpandListener {
/**
- * Called when a menu item with {@link com.actionbarsherlock.view.MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
+ * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
* is expanded.
* @param item Item that was expanded
* @return true if the item should expand, false if expansion should be suppressed.
@@ -104,7 +104,7 @@ public interface MenuItem {
public boolean onMenuItemActionExpand(MenuItem item);
/**
- * Called when a menu item with {@link com.actionbarsherlock.view.MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
+ * Called when a menu item with {@link MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}
* is collapsed.
* @param item Item that was collapsed
* @return true if the item should collapse, false if collapsing should be suppressed.
@@ -421,15 +421,15 @@ public interface MenuItem {
/**
* Set a custom listener for invocation of this menu item. In most
* situations, it is more efficient and easier to use
- * {@link Activity#onOptionsItemSelected(com.actionbarsherlock.view.MenuItem)} or
- * {@link Activity#onContextItemSelected(com.actionbarsherlock.view.MenuItem)}.
+ * {@link Activity#onOptionsItemSelected(MenuItem)} or
+ * {@link Activity#onContextItemSelected(MenuItem)}.
*
* @param menuItemClickListener The object to receive invokations.
* @return This Item so additional setters can be called.
- * @see Activity#onOptionsItemSelected(com.actionbarsherlock.view.MenuItem)
- * @see Activity#onContextItemSelected(com.actionbarsherlock.view.MenuItem)
+ * @see Activity#onOptionsItemSelected(MenuItem)
+ * @see Activity#onContextItemSelected(MenuItem)
*/
- public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener menuItemClickListener);
+ public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener);
/**
* Gets the extra information linked to this menu item. This extra
@@ -552,8 +552,8 @@ public interface MenuItem {
* Expand the action view associated with this menu item.
* The menu item must have an action view set, as well as
* the showAsAction flag {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
- * If a listener has been set using {@link #setOnActionExpandListener(com.actionbarsherlock.view.MenuItem.OnActionExpandListener)}
- * it will have its {@link com.actionbarsherlock.view.MenuItem.OnActionExpandListener#onMenuItemActionExpand(com.actionbarsherlock.view.MenuItem)}
+ * If a listener has been set using {@link #setOnActionExpandListener(OnActionExpandListener)}
+ * it will have its {@link OnActionExpandListener#onMenuItemActionExpand(MenuItem)}
* method invoked. The listener may return false from this method to prevent expanding
* the action view.
*
@@ -565,8 +565,8 @@ public interface MenuItem {
* Collapse the action view associated with this menu item.
* The menu item must have an action view set, as well as the showAsAction flag
* {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}. If a listener has been set using
- * {@link #setOnActionExpandListener(com.actionbarsherlock.view.MenuItem.OnActionExpandListener)} it will have its
- * {@link com.actionbarsherlock.view.MenuItem.OnActionExpandListener#onMenuItemActionCollapse(com.actionbarsherlock.view.MenuItem)} method invoked.
+ * {@link #setOnActionExpandListener(OnActionExpandListener)} it will have its
+ * {@link OnActionExpandListener#onMenuItemActionCollapse(MenuItem)} method invoked.
* The listener may return false from this method to prevent collapsing the action view.
*
* @return true if the action view was collapsed, false otherwise.
@@ -581,12 +581,12 @@ public interface MenuItem {
* @see #expandActionView()
* @see #collapseActionView()
* @see #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
- * @see com.actionbarsherlock.view.MenuItem.OnActionExpandListener
+ * @see OnActionExpandListener
*/
public boolean isActionViewExpanded();
/**
- * Set an {@link com.actionbarsherlock.view.MenuItem.OnActionExpandListener} on this menu item to be notified when
+ * Set an {@link OnActionExpandListener} on this menu item to be notified when
* the associated action view is expanded or collapsed. The menu item must
* be configured to expand or collapse its action view using the flag
* {@link #SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW}.
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserModel.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserModel.java
index 5b1ed0d4c..d7f110fc6 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserModel.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ActivityChooserModel.java
@@ -95,12 +95,12 @@ import java.util.concurrent.Executors;
class ActivityChooserModel extends DataSetObservable {
/**
- * Client that utilizes an {@link com.actionbarsherlock.widget.ActivityChooserModel}.
+ * Client that utilizes an {@link ActivityChooserModel}.
*/
public interface ActivityChooserModelClient {
/**
- * Sets the {@link com.actionbarsherlock.widget.ActivityChooserModel}.
+ * Sets the {@link ActivityChooserModel}.
*
* @param dataModel The model.
*/
@@ -124,7 +124,7 @@ class ActivityChooserModel extends DataSetObservable {
// This cannot be done by a simple comparator since an Activity weight
// is computed from history. Note that Activity implements Comparable.
public void sort(Intent intent, List activities,
- List historicalRecords);
+ List historicalRecords);
}
/**
@@ -135,7 +135,7 @@ class ActivityChooserModel extends DataSetObservable {
/**
* Called when an activity has been chosen. The client can decide whether
* an activity can be chosen and if so the caller of
- * {@link com.actionbarsherlock.widget.ActivityChooserModel#chooseActivity(int)} will receive and {@link Intent}
+ * {@link ActivityChooserModel#chooseActivity(int)} will receive and {@link Intent}
* for launching it.
*
* Note: Modifying the intent is not permitted and
@@ -146,7 +146,7 @@ class ActivityChooserModel extends DataSetObservable {
* @param intent The intent for launching the chosen activity.
* @return Whether the intent is handled and should not be delivered to clients.
*
- * @see com.actionbarsherlock.widget.ActivityChooserModel#chooseActivity(int)
+ * @see ActivityChooserModel#chooseActivity(int)
*/
public boolean onChooseActivity(ActivityChooserModel host, Intent intent);
}
@@ -407,7 +407,7 @@ class ActivityChooserModel extends DataSetObservable {
*
* @return The activity.
*
- * @see com.actionbarsherlock.widget.ActivityChooserModel.ActivityResolveInfo
+ * @see ActivityResolveInfo
* @see #setIntent(Intent)
*/
public ResolveInfo getActivity(int index) {
@@ -449,8 +449,8 @@ class ActivityChooserModel extends DataSetObservable {
* @return An {@link Intent} for launching the activity or null if the
* policy has consumed the intent.
*
- * @see com.actionbarsherlock.widget.ActivityChooserModel.HistoricalRecord
- * @see com.actionbarsherlock.widget.ActivityChooserModel.OnChooseActivityListener
+ * @see HistoricalRecord
+ * @see OnChooseActivityListener
*/
public Intent chooseActivity(int index) {
ActivityResolveInfo chosenActivity = mActivites.get(index);
@@ -593,7 +593,7 @@ class ActivityChooserModel extends DataSetObservable {
*
* @param activitySorter The sorter.
*
- * @see com.actionbarsherlock.widget.ActivityChooserModel.ActivitySorter
+ * @see ActivitySorter
*/
public void setActivitySorter(ActivitySorter activitySorter) {
synchronized (mInstanceLock) {
@@ -609,7 +609,7 @@ class ActivityChooserModel extends DataSetObservable {
* Sorts the activities based on history and an intent. If
* a sorter is not specified this a default implementation is used.
*
- * @see #setActivitySorter(com.actionbarsherlock.widget.ActivityChooserModel.ActivitySorter)
+ * @see #setActivitySorter(ActivitySorter)
*/
private void sortActivities() {
synchronized (mInstanceLock) {
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ShareActionProvider.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ShareActionProvider.java
index 71143c64c..83e9f0ca9 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ShareActionProvider.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/library/src/com/actionbarsherlock/widget/ShareActionProvider.java
@@ -301,7 +301,7 @@ public class ShareActionProvider extends ActionProvider {
}
/**
- * Policy that delegates to the {@link com.actionbarsherlock.widget.ShareActionProvider.OnShareTargetSelectedListener}, if such.
+ * Policy that delegates to the {@link OnShareTargetSelectedListener}, if such.
*/
private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener {
@Override
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/pom.xml b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/pom.xml
index 1cda497a9..ce4d4fca8 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/pom.xml
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/plugins/ActionBarSherlock/pom.xml
@@ -1,212 +1,191 @@
-
-
-
- 4.0.0
-
-
- org.sonatype.oss
- oss-parent
- 7
-
-
- com.actionbarsherlock
- parent
- pom
- 4.2.0
-
- ActionBarSherlock (Parent)
- Android library for implementing the action bar design pattern using the backported
- sources of Ice Cream Sandwich.
-
- http://actionbarsherlock.com
- 2011
-
-
- library
- samples
-
-
-
- https://github.com/JakeWharton/ActionBarSherlock/
- scm:git:git://github.com/JakeWharton/ActionBarSherlock.git
- scm:git:git@github.com:JakeWharton/ActionBarSherlock.git
-
-
-
-
-
- Jake Wharton
- jakewharton@gmail.com
- jakewharton
- http://jakewharton.com
- -5
-
- developer
-
-
-
-
-
-
- Apache License Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
-
- Jake Wharton
- http://jakewharton.com
-
-
-
- GitHub Issues
- https://github.com/JakeWharton/ActionBarSherlock/issues
-
-
-
- UTF-8
- UTF-8
-
- 1.6
- 4.0.1.2
- 14
- r99
-
- 3.3.2
- 4.10
-
- JakeWharton
- ActionBarSherlock
-
-
-
-
-
- com.google.android
- android
- ${android.version}
-
-
- com.google.android
- support-v4
- ${android-support.version}
+
+ 4.0.0
+
+
+ org.sonatype.oss
+ oss-parent
+ 7
+
+
+ com.actionbarsherlock
+ parent
+ pom
+ 4.2.0
+
+ ActionBarSherlock (Parent)
+ Android library for implementing the action bar design pattern using the backported sources of Ice Cream Sandwich.
+ http://actionbarsherlock.com
+ 2011
+
+
+ library
+ samples
+
+
+
+ https://github.com/JakeWharton/ActionBarSherlock/
+ scm:git:git://github.com/JakeWharton/ActionBarSherlock.git
+ scm:git:git@github.com:JakeWharton/ActionBarSherlock.git
+
+
+
+
+ Jake Wharton
+ jakewharton@gmail.com
+ jakewharton
+ http://jakewharton.com
+ -5
+
+ developer
+
+
+
+
+
+
+ Apache License Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ Jake Wharton
+ http://jakewharton.com
+
+
+
+ GitHub Issues
+ https://github.com/JakeWharton/ActionBarSherlock/issues
+
+
+
+ UTF-8
+ UTF-8
+
+ 1.6
+ 4.0.1.2
+ 14
+ r99
+
+ 3.3.2
+ 4.10
+
+ JakeWharton
+ ActionBarSherlock
+
+
+
+
+
+ com.google.android
+ android
+ ${android.version}
+
+
+ com.google.android
+ support-v4
+ ${android-support.version}system${basedir}/libs/android-support-v4.jar
-
-
- com.nineoldandroids
- library
- 2.4.0
-
-
- com.github.rtyley
- roboguice-sherlock
- 1.4
-
-
- junit
- junit
- ${junit.version}
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.5
-
-
- ${java.version}
-
-
-
-
- com.jayway.maven.plugins.android.generation2
- android-maven-plugin
- 3.3.2
-
-
- ${android.platform}
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.8
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 2.9.1
-
- true
-
-
-
-
- org.apache.maven.plugins
- maven-site-plugin
- 3.0
-
- true
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-release-plugin
- 2.2.2
-
- true
-
-
-
-
- com.github.github
- site-maven-plugin
- 0.5
-
-
- site
-
- site
-
-
-
-
- Creating site for ${project.version}.
- website
-
-
-
-
+
+
+ com.nineoldandroids
+ library
+ 2.4.0
+
+
+ com.github.rtyley
+ roboguice-sherlock
+ 1.4
+
+
+ junit
+ junit
+ ${junit.version}
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.5
+
+
+ ${java.version}
+
+
+
+
+ com.jayway.maven.plugins.android.generation2
+ android-maven-plugin
+ 3.3.2
+
+
+ ${android.platform}
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.8
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 2.9.1
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.0
+
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.2.2
+
+ true
+
+
+
+
+ com.github.github
+ site-maven-plugin
+ 0.5
+
+
+ site
+
+ site
+
+
+
+
+ Creating site for ${project.version}.
+ website
+
+
+
+
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/layout/activity_main.xml b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/layout/activity_main.xml
index 12f3031b9..078b90789 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/layout/activity_main.xml
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/layout/activity_main.xml
@@ -96,6 +96,7 @@
android:layout_centerHorizontal="true"
android:textSize="16sp"
android:textColor="#372c24"
+ android:textAlignment="center"
android:gravity="center"
android:text="Registration failed, check your internet connection and click to retry" />
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/values/strings.xml b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/values/strings.xml
index 33043ed76..746de5173 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/values/strings.xml
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/res/values/strings.xml
@@ -1,5 +1,8 @@
+
+ ${clientKey}
+ ${clientSecret}Please set the %1$s constant and recompile the app.Device is already registered on server.
@@ -52,6 +55,7 @@
COPEInitialization Failed. Please try again.Initialization Failed
+ Re-type the PIN to ConfirmNew PIN Code
@@ -89,9 +93,11 @@
modeinterval
+ username
+
0
- ${clientKey}
- ${clientSecret}
+ ClientID
+ ClientSecret
@@ -156,6 +162,7 @@
OK
+ Cancel/Download/
@@ -171,5 +178,8 @@
Set your server address here to start registration, i.e : www.abc.com
+
+
+ PINs don\'t match, Please re-enter
\ No newline at end of file
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlertActivity.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlertActivity.java
index 2d49e4ec2..bc821bbb1 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlertActivity.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlertActivity.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,25 +27,26 @@ public class AlertActivity extends SherlockActivity {
String message = "";
Button btnOK;
TextView txtMessage;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alert);
-
- btnOK = (Button)findViewById(R.id.btnOK);
- txtMessage = (TextView)findViewById(R.id.txtMessage);
-
+
+ btnOK = (Button) findViewById(R.id.btnOK);
+ txtMessage = (TextView) findViewById(R.id.txtMessage);
+
Bundle extras = getIntent().getExtras();
if (extras != null) {
- if(extras.containsKey( getResources().getString(R.string.intent_extra_message))){
- message = extras.getString( getResources().getString(R.string.intent_extra_message));
+ if (extras.containsKey(getResources().getString(R.string.intent_extra_message))) {
+ message = extras.getString(getResources().getString(R.string.intent_extra_message));
}
}
-
+
txtMessage.setText(message);
-
+
btnOK.setOnClickListener(new OnClickListener() {
-
+
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlreadyRegisteredActivity.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlreadyRegisteredActivity.java
index 7e53e0eaf..6caf5ea76 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlreadyRegisteredActivity.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AlreadyRegisteredActivity.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@ import java.util.Map;
import org.wso2.cdm.agent.R;
import org.wso2.cdm.agent.api.PhoneState;
import org.wso2.cdm.agent.proxy.APIResultCallBack;
+import org.wso2.cdm.agent.services.LocalNotification;
import org.wso2.cdm.agent.services.Operation;
import org.wso2.cdm.agent.services.WSO2DeviceAdminReceiver;
import org.wso2.cdm.agent.utils.CommonDialogUtils;
@@ -52,9 +53,9 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
public class AlreadyRegisteredActivity extends SherlockActivity implements APIResultCallBack {
-
+
private String TAG = AlreadyRegisteredActivity.class.getSimpleName();
-
+
AsyncTask mRegisterTask;
AsyncTask mCheckRegisterTask;
static final int ACTIVATION_REQUEST = 47; // identifies our request id
@@ -84,13 +85,14 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(R.layout.custom_sherlock_bar);
getSupportActionBar().setTitle(R.string.empty_app_title);
- View homeIcon = findViewById(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home
- : R.id.abs__home);
+ View homeIcon = findViewById(
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home
+ : R.id.abs__home);
((View) homeIcon.getParent()).setVisibility(View.GONE);
devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
demoDeviceAdmin = new ComponentName(this,
- WSO2DeviceAdminReceiver.class);
+ WSO2DeviceAdminReceiver.class);
operation = new Operation(AlreadyRegisteredActivity.this);
context = AlreadyRegisteredActivity.this;
Bundle extras = getIntent().getExtras();
@@ -102,11 +104,11 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
}
}
-
-
- String regIden=CommonUtilities.getPref(context, context.getResources().getString(R.string.shared_pref_regId));
- if(!regIden.equals("")){
- regId=regIden;
+
+ String regIden = CommonUtilities
+ .getPref(context, context.getResources().getString(R.string.shared_pref_regId));
+ if (!regIden.equals("")) {
+ regId = regIden;
}
if (freshRegFlag) {
@@ -115,24 +117,26 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
.getSharedPreferences(
getResources().getString(
R.string.shared_pref_package),
- Context.MODE_PRIVATE);
+ Context.MODE_PRIVATE
+ );
Editor editor = mainPref.edit();
- Log.e("freshRegFlag","1");
+ Log.e("freshRegFlag", "1");
editor.putString(
getResources().getString(
- R.string.shared_pref_registered), "1");
+ R.string.shared_pref_registered), "1"
+ );
editor.commit();
-
-
+
if (!devicePolicyManager.isAdminActive(demoDeviceAdmin)) {
Intent intent1 = new Intent(
DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent1.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
- demoDeviceAdmin);
+ demoDeviceAdmin);
intent1.putExtra(
DevicePolicyManager.EXTRA_ADD_EXPLANATION,
getResources().getString(
- R.string.device_admin_enable_alert));
+ R.string.device_admin_enable_alert)
+ );
startActivityForResult(intent1, ACTIVATION_REQUEST);
}
//operation.executePolicy();
@@ -145,26 +149,27 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
btnUnregister = (Button) findViewById(R.id.btnUnreg);
btnUnregister.setTag(TAG_BTN_UNREGISTER);
- btnUnregister.setOnClickListener(onClickListener_BUTTON_CLICKED);
-
+ btnUnregister.setOnClickListener(onClickListenerButtonClicked);
+ LocalNotification.startPolling(context);
+
}
-
+
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
- case DialogInterface.BUTTON_POSITIVE:
- dialog.dismiss();
- break;
+ case DialogInterface.BUTTON_POSITIVE:
+ dialog.dismiss();
+ break;
- case DialogInterface.BUTTON_NEGATIVE:
- startUnRegistration();
- break;
+ case DialogInterface.BUTTON_NEGATIVE:
+ startUnRegistration();
+ break;
}
}
};
- OnClickListener onClickListener_BUTTON_CLICKED = new OnClickListener() {
+ OnClickListener onClickListenerButtonClicked = new OnClickListener() {
@Override
public void onClick(View view) {
@@ -172,51 +177,56 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
switch (iTag) {
- case TAG_BTN_UNREGISTER:
- AlertDialog.Builder builder = new AlertDialog.Builder(
- AlreadyRegisteredActivity.this);
- builder.setMessage(getResources().getString(R.string.dialog_unregister))
- .setNegativeButton(getResources().getString(R.string.yes), dialogClickListener)
- .setPositiveButton(getResources().getString(R.string.no), dialogClickListener).show();
- break;
-
- case TAG_BTN_OPTIONS:
- break;
- case TAG_BTN_RE_REGISTER:
- Intent intent = new Intent(AlreadyRegisteredActivity.this,
- ServerDetails.class);
- intent.putExtra(
- getResources().getString(R.string.intent_extra_regid),
- regId);
- startActivity(intent);
- finish();
- break;
-
- default:
- break;
+ case TAG_BTN_UNREGISTER:
+ AlertDialog.Builder builder = new AlertDialog.Builder(
+ AlreadyRegisteredActivity.this);
+ builder.setMessage(getResources().getString(R.string.dialog_unregister))
+ .setNegativeButton(getResources().getString(R.string.yes),
+ dialogClickListener)
+ .setPositiveButton(getResources().getString(R.string.no),
+ dialogClickListener).show();
+ break;
+
+ case TAG_BTN_OPTIONS:
+ break;
+ case TAG_BTN_RE_REGISTER:
+ Intent intent = new Intent(AlreadyRegisteredActivity.this,
+ ServerDetails.class);
+ intent.putExtra(
+ getResources().getString(R.string.intent_extra_regid),
+ regId);
+ startActivity(intent);
+ finish();
+ break;
+
+ default:
+ break;
}
}
};
-
- DialogInterface.OnClickListener isRegisteredFailedOKBtnClickListerner = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
-
- Intent intent = new Intent(AlreadyRegisteredActivity.this,
- ServerDetails.class);
- intent.putExtra(
- getResources().getString(
- R.string.intent_extra_regid), regId);
- intent.putExtra(
- getResources().getString(
- R.string.intent_extra_from_activity),
- AlreadyRegisteredActivity.class.getSimpleName());
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
-
- }
- };
+
+ DialogInterface.OnClickListener isRegisteredFailedOKBtnClickListerner =
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface arg0, int arg1) {
+
+ Intent intent = new Intent(AlreadyRegisteredActivity.this,
+ ServerDetails.class);
+ intent.putExtra(
+ getResources().getString(
+ R.string.intent_extra_regid), regId
+ );
+ intent.putExtra(
+ getResources().getString(
+ R.string.intent_extra_from_activity),
+ AlreadyRegisteredActivity.class.getSimpleName()
+ );
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+
+ }
+ };
public void startUnRegistration() {
final Context context = AlreadyRegisteredActivity.this;
@@ -224,13 +234,14 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
progressDialog = ProgressDialog
.show(AlreadyRegisteredActivity.this,
- getResources().getString(
- R.string.dialog_message_unregistering),
- getResources().getString(
- R.string.dialog_message_please_wait), true);
+ getResources().getString(
+ R.string.dialog_message_unregistering),
+ getResources().getString(
+ R.string.dialog_message_please_wait), true
+ );
regId = CommonUtilities.getPref(context, context.getResources()
- .getString(R.string.shared_pref_regId));
+ .getString(R.string.shared_pref_regId));
Map requestParams = new HashMap();
requestParams.put("regid", regId);
@@ -238,10 +249,10 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
// Check network connection availability before calling the API.
if (PhoneState.isNetworkAvailable(context)) {
// Call device unregister API.
- ServerUtils.callSecuredAPI(AlreadyRegisteredActivity.this, CommonUtilities.UNREGISTER_ENDPOINT,
- CommonUtilities.POST_METHOD, requestParams,
- AlreadyRegisteredActivity.this,
- CommonUtilities.UNREGISTER_REQUEST_CODE);
+ // ServerUtils.callSecuredAPI(AlreadyRegisteredActivity.this, CommonUtilities.UNREGISTER_ENDPOINT,
+ // CommonUtilities.POST_METHOD, requestParams,
+ // AlreadyRegisteredActivity.this,
+ // CommonUtilities.UNREGISTER_REQUEST_CODE);
} else {
CommonDialogUtils.stopProgressDialog(progressDialog);
CommonDialogUtils
@@ -252,9 +263,9 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- if(CommonUtilities.DEBUG_MODE_ENABLED){
+ if (CommonUtilities.DEBUG_MODE_ENABLED) {
getSupportMenuInflater().inflate(R.menu.sherlock_menu_debug, menu);
- }else{
+ } else {
getSupportMenuInflater().inflate(R.menu.sherlock_menu, menu);
}
return true;
@@ -263,47 +274,50 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.info_setting:
- Intent intentIN = new Intent(AlreadyRegisteredActivity.this,
- DisplayDeviceInfoActivity.class);
- intentIN.putExtra(
- getResources().getString(
- R.string.intent_extra_from_activity),
- AlreadyRegisteredActivity.class.getSimpleName());
- startActivity(intentIN);
- return true;
- case R.id.pin_setting:
- Intent intentPIN = new Intent(AlreadyRegisteredActivity.this,
- PinCodeActivity.class);
- intentPIN.putExtra(
- getResources().getString(
- R.string.intent_extra_from_activity),
- AlreadyRegisteredActivity.class.getSimpleName());
- startActivity(intentPIN);
- return true;
- case R.id.ip_setting:
- SharedPreferences mainPref = AlreadyRegisteredActivity.this
- .getSharedPreferences("com.mdm", Context.MODE_PRIVATE);
- Editor editor = mainPref.edit();
- editor.putString(getResources().getString(R.string.shared_pref_ip),
- "");
- editor.commit();
-
- Intent intentIP = new Intent(AlreadyRegisteredActivity.this,
- ServerDetails.class);
- intentIP.putExtra(
- getResources().getString(
- R.string.intent_extra_from_activity),
- AlreadyRegisteredActivity.class.getSimpleName());
- startActivity(intentIP);
- return true;
- case R.id.debug_log:
- Intent intentDebug = new Intent(AlreadyRegisteredActivity.this,
- LogActivity.class);
- startActivity(intentDebug);
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ case R.id.info_setting:
+ Intent intentIN = new Intent(AlreadyRegisteredActivity.this,
+ DisplayDeviceInfoActivity.class);
+ intentIN.putExtra(
+ getResources().getString(
+ R.string.intent_extra_from_activity),
+ AlreadyRegisteredActivity.class.getSimpleName()
+ );
+ startActivity(intentIN);
+ return true;
+ case R.id.pin_setting:
+ Intent intentPIN = new Intent(AlreadyRegisteredActivity.this,
+ PinCodeActivity.class);
+ intentPIN.putExtra(
+ getResources().getString(
+ R.string.intent_extra_from_activity),
+ AlreadyRegisteredActivity.class.getSimpleName()
+ );
+ startActivity(intentPIN);
+ return true;
+ case R.id.ip_setting:
+ SharedPreferences mainPref = AlreadyRegisteredActivity.this
+ .getSharedPreferences("com.mdm", Context.MODE_PRIVATE);
+ Editor editor = mainPref.edit();
+ editor.putString(getResources().getString(R.string.shared_pref_ip),
+ "");
+ editor.commit();
+
+ Intent intentIP = new Intent(AlreadyRegisteredActivity.this,
+ ServerDetails.class);
+ intentIP.putExtra(
+ getResources().getString(
+ R.string.intent_extra_from_activity),
+ AlreadyRegisteredActivity.class.getSimpleName()
+ );
+ startActivity(intentIP);
+ return true;
+ case R.id.debug_log:
+ Intent intentDebug = new Intent(AlreadyRegisteredActivity.this,
+ LogActivity.class);
+ startActivity(intentDebug);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
}
}
@@ -320,7 +334,6 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
- // finish();
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
@@ -331,7 +344,6 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
this.startActivity(i);
- // finish();
return true;
}
return super.onKeyDown(keyCode, event);
@@ -346,16 +358,16 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
// Call isRegistered API.
Map requestParams = new HashMap();
requestParams.put("regid", regId);
- ServerUtils.callSecuredAPI(AlreadyRegisteredActivity.this,
- CommonUtilities.IS_REGISTERED_ENDPOINT,
- CommonUtilities.POST_METHOD, requestParams,
- AlreadyRegisteredActivity.this,
- CommonUtilities.IS_REGISTERED_REQUEST_CODE);
+ // ServerUtils.callSecuredAPI(AlreadyRegisteredActivity.this,
+ // CommonUtilities.IS_REGISTERED_ENDPOINT,
+ // CommonUtilities.POST_METHOD, requestParams,
+ // AlreadyRegisteredActivity.this,
+ // CommonUtilities.IS_REGISTERED_REQUEST_CODE);
} else {
CommonDialogUtils
.showNetworkUnavailableMessage(AlreadyRegisteredActivity.this);
}
-
+
}
}
@@ -366,20 +378,21 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
builder.setTitle(title);
builder.setCancelable(true);
builder.setPositiveButton(getResources().getString(R.string.button_ok),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- //cancelEntry();
- dialog.cancel();
- }
- });
-
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ //cancelEntry();
+ dialog.cancel();
+ }
+ }
+ );
+
AlertDialog alert = builder.create();
alert.show();
}
public void cancelEntry() {
Intent intentIP = new Intent(AlreadyRegisteredActivity.this,
- ServerDetails.class);
+ ServerDetails.class);
intentIP.putExtra(
getResources().getString(R.string.intent_extra_from_activity),
AlreadyRegisteredActivity.class.getSimpleName());
@@ -403,9 +416,9 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
btnUnregister.setText(R.string.register_button_text);
btnUnregister.setTag(TAG_BTN_RE_REGISTER);
btnUnregister
- .setOnClickListener(onClickListener_BUTTON_CLICKED);
+ .setOnClickListener(onClickListenerButtonClicked);
ServerUtils.clearAppData(context);
-
+
} else if (responseStatus
.equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
Log.e(TAG, "The value of status is : " + responseStatus);
@@ -417,7 +430,8 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
getResources().getString(
R.string.error_internal_server),
getResources().getString(R.string.button_ok),
- null);
+ null
+ );
} else {
Log.e(TAG, "The result is : " + result);
Log.e(TAG, "The responseStatus is : " + responseStatus);
@@ -428,7 +442,6 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
Log.e(TAG, "The responseStatus is : " + responseStatus);
loadAuthenticationErrorActivity();
}
-
} else {
Log.e(TAG, "The result is null in onReceiveAPIResult().");
@@ -437,7 +450,7 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
}
}
-
+
if (requestCode == CommonUtilities.IS_REGISTERED_REQUEST_CODE) {
stopProgressDialog();
if (result != null) {
@@ -454,13 +467,14 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
getResources().getString(
R.string.error_internal_server),
getResources().getString(R.string.button_ok),
- null);
+ null
+ );
alertDialog.show();
} else if (!responseStatus
.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
Log.e(TAG, "The value of status is : " + responseStatus);
ServerUtils.clearAppData(context);
-
+
alertDialog = CommonDialogUtils
.getAlertDialogWithOneButtonAndTitle(
context,
@@ -469,14 +483,15 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
getResources().getString(
R.string.error_for_all_unknown_registration_failures),
getResources().getString(R.string.button_ok),
- isRegisteredFailedOKBtnClickListerner);
+ isRegisteredFailedOKBtnClickListerner
+ );
alertDialog.show();
ServerUtils.clearAppData(context);
}
- } else {
+ } else {
Log.e(TAG, "The result is null in onReceiveAPIResult()");
ServerUtils.clearAppData(context);
-
+
alertDialog = CommonDialogUtils
.getAlertDialogWithOneButtonAndTitle(
context,
@@ -485,15 +500,15 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
getResources().getString(
R.string.error_for_all_unknown_registration_failures),
getResources().getString(R.string.button_ok),
- isRegisteredFailedOKBtnClickListerner);
+ isRegisteredFailedOKBtnClickListerner
+ );
alertDialog.show();
}
-
-
+
} else {
Log.e(TAG, "The responseStatus is null in onReceiveAPIResult()");
ServerUtils.clearAppData(context);
-
+
alertDialog = CommonDialogUtils
.getAlertDialogWithOneButtonAndTitle(
context,
@@ -502,27 +517,30 @@ public class AlreadyRegisteredActivity extends SherlockActivity implements APIRe
getResources().getString(
R.string.error_for_all_unknown_registration_failures),
getResources().getString(R.string.button_ok),
- null);
+ null
+ );
alertDialog.show();
}
}
-
+
}
private void loadAuthenticationErrorActivity() {
Intent intent = new Intent(AlreadyRegisteredActivity.this,
- AuthenticationErrorActivity.class);
+ AuthenticationErrorActivity.class);
intent.putExtra(
getResources().getString(
- R.string.intent_extra_regid), regId);
+ R.string.intent_extra_regid), regId
+ );
intent.putExtra(
getResources().getString(
R.string.intent_extra_from_activity),
- AlreadyRegisteredActivity.class.getSimpleName());
+ AlreadyRegisteredActivity.class.getSimpleName()
+ );
startActivity(intent);
}
-
+
private void stopProgressDialog() {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AuthenticationActivity.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AuthenticationActivity.java
index c47ba6167..e48cecbf8 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AuthenticationActivity.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/AuthenticationActivity.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,28 +15,21 @@
*/
package org.wso2.cdm.agent;
-import java.util.HashMap;
import java.util.Map;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.wso2.cdm.agent.R;
import org.wso2.cdm.agent.api.PhoneState;
import org.wso2.cdm.agent.proxy.APIAccessCallBack;
import org.wso2.cdm.agent.proxy.APIResultCallBack;
import org.wso2.cdm.agent.proxy.IdentityProxy;
-import org.wso2.cdm.agent.services.AlarmReceiver;
import org.wso2.cdm.agent.utils.CommonDialogUtils;
import org.wso2.cdm.agent.utils.CommonUtilities;
import org.wso2.cdm.agent.utils.Constant;
-import org.wso2.cdm.agent.utils.HTTPConnectorUtils;
import org.wso2.cdm.agent.utils.Preference;
import org.wso2.cdm.agent.utils.ServerUtils;
-import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -44,11 +37,8 @@ import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
-import android.os.SystemClock;
-import android.provider.Settings.Secure;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
@@ -64,14 +54,12 @@ import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
-import com.google.android.gcm.GCMRegistrar;
/**
* Activity that captures username, password and device ownership details.
*/
public class AuthenticationActivity extends SherlockActivity implements APIAccessCallBack,
- APIResultCallBack {
-
+ APIResultCallBack {
private String TAG = AuthenticationActivity.class.getSimpleName();
@@ -98,10 +86,11 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
getSupportActionBar().setCustomView(R.layout.custom_sherlock_bar);
getSupportActionBar().setTitle(R.string.empty_app_title);
View homeIcon =
- (View) findViewById(
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
- ? android.R.id.home
- : R.id.abs__home).getParent();
+ (View) findViewById(
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
+ ? android.R.id.home
+ : R.id.abs__home
+ ).getParent();
homeIcon.setVisibility(View.GONE);
context = AuthenticationActivity.this;
@@ -160,11 +149,13 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
public void onClick(View view) {
if (etUsername.getText() != null &&
!etUsername.getText().toString().trim().equals("") &&
- etPassword.getText() != null && !etPassword.getText().toString().trim().equals("")) {
+ etPassword.getText() != null &&
+ !etPassword.getText().toString().trim().equals("")) {
passwordVal = etPassword.getText().toString().trim();
usernameVal = etUsername.getText().toString().trim();
- if (etDomain.getText() != null && !etDomain.getText().toString().trim().equals("")) {
+ if (etDomain.getText() != null &&
+ !etDomain.getText().toString().trim().equals("")) {
usernameVal += "@" + etDomain.getText().toString().trim();
}
@@ -180,13 +171,21 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
messageBuilder.append(" ");
messageBuilder.append(getResources().getString(R.string.dialog_init_end));
alertDialog =
- CommonDialogUtils.getAlertDialogWithTwoButtonAndTitle(context,
- getResources().getString(R.string.dialog_init_device_type),
- messageBuilder.toString(),
- getResources().getString(R.string.yes),
- getResources().getString(R.string.no),
- dialogClickListener,
- dialogClickListener);
+ CommonDialogUtils.getAlertDialogWithTwoButtonAndTitle(context,
+ getResources()
+ .getString(
+ R.string.dialog_init_device_type),
+ messageBuilder
+ .toString(),
+ getResources()
+ .getString(
+ R.string.yes),
+ getResources()
+ .getString(
+ R.string.no),
+ dialogClickListener,
+ dialogClickListener
+ );
alertDialog.show();
} else {
if (etUsername.getText() != null &&
@@ -209,12 +208,12 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
+ startAuthentication();
dialog.dismiss();
break;
case DialogInterface.BUTTON_NEGATIVE:
dialog.dismiss();
- startAuthentication();
break;
}
}
@@ -224,10 +223,12 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
* Start authentication process.
*/
public void startAuthentication() {
- Preference.put(context, getResources().getString(R.string.shared_pref_reg_type), deviceType);
+ Preference
+ .put(context, getResources().getString(R.string.shared_pref_reg_type), deviceType);
// Check network connection availability before calling the API.
if (PhoneState.isNetworkAvailable(context)) {
- authenticate();
+ initializeIDPLib(getResources().getString(R.string.client_id),
+ getResources().getString(R.string.client_secret));
} else {
CommonDialogUtils.stopProgressDialog(progressDialog);
CommonDialogUtils.showNetworkUnavailableMessage(context);
@@ -236,93 +237,85 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
}
/**
- * Communicating with the server to authenticate user.
+ * Initialize the Android IDP SDK by passing credentials,client ID and
+ * client secret.
+ *
+ * @param clientKey client id value to access APIs..
+ * @param clientSecret client secret value to access APIs.
*/
- private void authenticate() {
-
- AsyncTask> mLicenseTask =
- new AsyncTask>() {
-
- @Override
- protected Map doInBackground(Void... params) {
- Map response =
- null;
-
- Map requestParametres =
- new HashMap();
+ private void initializeIDPLib(String clientKey, String clientSecret) {
+ String serverIP =
+ CommonUtilities.getPref(AuthenticationActivity.this,
+ context.getResources()
+ .getString(R.string.shared_pref_ip)
+ );
+ String serverURL =
+ CommonUtilities.SERVER_PROTOCOL + serverIP + ":" +
+ CommonUtilities.SERVER_PORT + CommonUtilities.OAUTH_ENDPOINT;
+ if (etDomain.getText() != null && !etDomain.getText().toString().trim().equals("")) {
+ usernameForRegister =
+ etUsername.getText().toString().trim() + "@" +
+ etDomain.getText().toString().trim();
- requestParametres.put(Constant.USERNAME,
- usernameVal);
- requestParametres.put(Constant.PASSWORD,
- passwordVal);
- response =
- HTTPConnectorUtils.postData(context,
- CommonUtilities.SERVER_URL +
- CommonUtilities.SERVER_AUTHENTICATION_ENDPOINT,
- requestParametres);
- return response;
- }
+ } else {
+ usernameForRegister = etUsername.getText().toString().trim();
+ }
+ IdentityProxy.getInstance().init(clientKey, clientSecret, usernameForRegister, passwordVal,
+ serverURL, AuthenticationActivity.this,
+ this.getApplicationContext());
+ }
- @Override
- protected void onPreExecute() {
- progressDialog =
- ProgressDialog.show(context,
- getResources().getString(R.string.dialog_authenticate),
- getResources().getString(R.string.dialog_please_wait),
- true);
+ @Override
+ public void onAPIAccessRecive(String status) {
+ if (status != null) {
+ if (status.trim().equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
- };
+ SharedPreferences mainPref =
+ this.getSharedPreferences(
+ getResources().getString(R.string.shared_pref_package),
+ Context.MODE_PRIVATE);
+ Editor editor = mainPref.edit();
+ editor.putString(getResources().getString(R.string.shared_pref_username),
+ usernameForRegister);
+ editor.commit();
- @Override
- protected void onPostExecute(Map result) {
- authenticateResponse(result);
+ // Check network connection availability before calling the API.
+ if (PhoneState.isNetworkAvailable(context)) {
+ getLicense();
+ } else {
+ CommonDialogUtils.stopProgressDialog(progressDialog);
+ CommonDialogUtils.showNetworkUnavailableMessage(AuthenticationActivity.this);
+ }
- }
+ } else if (status.trim().equals(CommonUtilities.AUTHENTICATION_FAILED)) {
+ CommonDialogUtils.stopProgressDialog(progressDialog);
+ alertDialog =
+ CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
+ getResources()
+ .getString(
+ R.string.title_head_authentication_error),
+ getResources()
+ .getString(
+ R.string.error_authentication_failed),
+ getResources()
+ .getString(
+ R.string.button_ok),
+ dialogClickListener
+ );
+ } else if (status.trim().equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
+ showInternalServerErrorMessage();
- };
+ } else {
+ Log.e(TAG, "Status: " + status);
+ showAuthCommonErrorMessage();
+ }
- mLicenseTask.execute();
+ } else {
+ Log.e(TAG, "The value of status is null in onAPIAccessRecive()");
+ showAuthCommonErrorMessage();
+ }
}
-
- /**
- * Handles the response received from server for the authentication request.
- * @param result Received response from server.
- */
- private void authenticateResponse(Map result){
- if (result != null) {
- String responseStatus =
- result.get(Constant.STATUS);
- if (responseStatus != null) {
- if (responseStatus.equalsIgnoreCase(CommonUtilities.REQUEST_SUCCESSFUL)) {
- getLicense();
- } else if (responseStatus.equalsIgnoreCase(CommonUtilities.UNAUTHORIZED_ACCESS)) {
- CommonDialogUtils.stopProgressDialog(progressDialog);
- alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.title_head_authentication_error),
- getResources().getString(R.string.error_authentication_failed),
- getResources().getString(R.string.button_ok),
- dialogClickListener);
- } else if (responseStatus.trim()
- .equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
- Log.e(TAG, "Error: Internal server error");
- showInternalServerErrorMessage();
-
- } else {
- Log.e(TAG, "Status: " + responseStatus);
- showAuthCommonErrorMessage();
- }
- } else {
- Log.e(TAG, "The value of status is null in authenticating");
- showAuthCommonErrorMessage();
- }
-
- } else {
- Log.e(TAG, "The result is null in authenticating");
- showAuthCommonErrorMessage();
- }
- }
/**
* Initialize get device license agreement. Check if the user has already
@@ -330,11 +323,11 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
*/
private void getLicense() {
String licenseAgreedResponse =
- Preference.get(context,
- getResources().getString(R.string.shared_pref_isagreed));
+ Preference.get(context,
+ getResources().getString(R.string.shared_pref_isagreed));
String type =
- Preference.get(context,
- getResources().getString(R.string.shared_pref_reg_type));
+ Preference.get(context,
+ getResources().getString(R.string.shared_pref_reg_type));
// No need to display license for COPE devices
if (type.trim().equals(getResources().getString(R.string.device_enroll_type_byod))) {
@@ -346,18 +339,28 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
@Override
public void onCancel(DialogInterface arg0) {
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.error_enrollment_failed_detail),
- getResources().getString(R.string.error_enrollment_failed),
- getResources().getString(R.string.button_ok),
- null);
+ getResources()
+ .getString(
+ R.string.error_enrollment_failed_detail),
+ getResources()
+ .getString(
+ R.string.error_enrollment_failed),
+ getResources()
+ .getString(
+ R.string.button_ok),
+ null
+ );
}
};
progressDialog =
- CommonDialogUtils.showPrgressDialog(context,
- getResources().getString(R.string.dialog_license_agreement),
- getResources().getString(R.string.dialog_please_wait),
- cancelListener);
+ CommonDialogUtils.showPrgressDialog(context,
+ getResources().getString(
+ R.string.dialog_license_agreement),
+ getResources().getString(
+ R.string.dialog_please_wait),
+ cancelListener
+ );
// Check network connection availability before calling the API.
if (PhoneState.isNetworkAvailable(context)) {
@@ -377,46 +380,31 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
}
/**
- * Retriever license agreement details from the server
+ * Retriever license agreement details from the server.
*/
private void getLicenseFromServer() {
+ ServerUtils.callSecuredAPI(AuthenticationActivity.this,
+ CommonUtilities.API_SERVER_URL +
+ CommonUtilities.LICENSE_ENDPOINT,
+ CommonUtilities.GET_METHOD, null,
+ AuthenticationActivity.this,
+ CommonUtilities.LICENSE_REQUEST_CODE
+ );
+ }
- AsyncTask> mLicenseTask =
- new AsyncTask>() {
-
- @Override
- protected Map doInBackground(Void... params) {
- Map response =
- null;
- response =
- HTTPConnectorUtils.postData(context,
- CommonUtilities.SERVER_URL +
- CommonUtilities.LICENSE_ENDPOINT,
- null);
- return response;
- }
-
- @Override
- protected void onPreExecute() {
- };
-
- @Override
- protected void onPostExecute(Map result) {
- CommonDialogUtils.stopProgressDialog(progressDialog);
- manipulateLicenseResponse(result);
- }
-
- };
-
- mLicenseTask.execute();
-
+ @Override
+ public void onReceiveAPIResult(Map result, int requestCode) {
+ if (requestCode == CommonUtilities.SENDER_ID_REQUEST_CODE) {
+ //manipulateSenderIdResponse(result);
+ } else if (requestCode == CommonUtilities.LICENSE_REQUEST_CODE) {
+ manipulateLicenseResponse(result);
+ }
}
/**
* Manipulates the License agreement response received from server.
- *
- * @param result
- * the result of the license agreement request
+ *
+ * @param result the result of the license agreement request
*/
private void manipulateLicenseResponse(Map result) {
String responseStatus;
@@ -432,8 +420,9 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
licenseAgreement);
showAgreement(licenseAgreement, CommonUtilities.EULA_TITLE);
} else {
- showErrorMessage(getResources().getString(R.string.error_enrollment_failed_detail),
- getResources().getString(R.string.error_enrollment_failed));
+ showErrorMessage(
+ getResources().getString(R.string.error_enrollment_failed_detail),
+ getResources().getString(R.string.error_enrollment_failed));
}
} else if (responseStatus.equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
@@ -460,11 +449,18 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
cancelEntry();
dialog.dismiss();
}
- });
+ }
+ );
AlertDialog alert = builder.create();
alert.show();
}
+ /**
+ * Show the license text retrieved from the server.
+ *
+ * @param message Message text to be shown as the license.
+ * @param title Title of the license.
+ */
public void showAgreement(String message, String title) {
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom_terms_popup);
@@ -523,8 +519,8 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
public void cancelEntry() {
SharedPreferences mainPref =
- context.getSharedPreferences(getResources().getString(R.string.shared_pref_package),
- Context.MODE_PRIVATE);
+ context.getSharedPreferences(getResources().getString(R.string.shared_pref_package),
+ Context.MODE_PRIVATE);
Editor editor = mainPref.edit();
editor.putString(getResources().getString(R.string.shared_pref_policy), "");
editor.putString(getResources().getString(R.string.shared_pref_isagreed), "0");
@@ -551,7 +547,8 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
// cancelEntry();
dialog.cancel();
}
- });
+ }
+ );
AlertDialog alert = builder.create();
alert.show();
}
@@ -566,44 +563,15 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
- });
+ }
+ );
AlertDialog alert = builder.create();
alert.show();
}
/**
- * Initialize the Android IDP sdk by passing user credentials,client ID and
- * client secret.
+ * Validation done to see if the username and password fields are properly entered.
*/
- private void initializeIDPLib(String clientKey, String clientSecret) {
- Log.e("", "initializeIDPLib");
- String serverIP =
- CommonUtilities.getPref(AuthenticationActivity.this,
- context.getResources()
- .getString(R.string.shared_pref_ip));
- String serverURL =
- CommonUtilities.SERVER_PROTOCOL + serverIP + ":" +
- CommonUtilities.SERVER_PORT + CommonUtilities.OAUTH_ENDPOINT;
- if (etDomain.getText() != null && !etDomain.getText().toString().trim().equals("")) {
- usernameForRegister =
- etUsername.getText().toString().trim() + "@" +
- etDomain.getText().toString().trim();
-
- IdentityProxy.getInstance().init(clientKey, clientSecret, usernameForRegister,
- etPassword.getText().toString().trim(), serverURL,
- AuthenticationActivity.this,
- this.getApplicationContext());
-
- } else {
- usernameForRegister = etUsername.getText().toString().trim();
-
- IdentityProxy.getInstance().init(clientKey, clientSecret, usernameForRegister,
- etPassword.getText().toString().trim(), serverURL,
- AuthenticationActivity.this,
- this.getApplicationContext());
- }
- }
-
public void enableSubmitIfReady() {
boolean isReady = false;
@@ -626,7 +594,6 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- // TODO Auto-generated method stub
getSupportMenuInflater().inflate(R.menu.auth_sherlock_menu, menu);
return true;
}
@@ -636,8 +603,9 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
switch (item.getItemId()) {
case R.id.ip_setting:
SharedPreferences mainPref =
- AuthenticationActivity.this.getSharedPreferences(getResources().getString(R.string.shared_pref_package),
- Context.MODE_PRIVATE);
+ AuthenticationActivity.this.getSharedPreferences(
+ getResources().getString(R.string.shared_pref_package),
+ Context.MODE_PRIVATE);
Editor editor = mainPref.edit();
editor.putString(getResources().getString(R.string.shared_pref_ip), "");
editor.commit();
@@ -668,222 +636,62 @@ public class AuthenticationActivity extends SherlockActivity implements APIAcces
}
DialogInterface.OnClickListener senderIdFailedClickListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- etUsername.setText(CommonUtilities.EMPTY_STRING);
- etPassword.setText(CommonUtilities.EMPTY_STRING);
- etDomain.setText(CommonUtilities.EMPTY_STRING);
- btnRegister.setEnabled(false);
- btnRegister.setBackground(getResources().getDrawable(R.drawable.btn_grey));
- btnRegister.setTextColor(getResources().getColor(R.color.black));
- }
- };
-
- @Override
- public void onReceiveAPIResult(Map result, int requestCode) {
- if (requestCode == CommonUtilities.SENDER_ID_REQUEST_CODE) {
- Log.e("sender", "rec" + result);
- manipulateSenderIdResponse(result);
- } else if (requestCode == CommonUtilities.LICENSE_REQUEST_CODE) {
- manipulateLicenseResponse(result);
- }
- }
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ etUsername.setText(CommonUtilities.EMPTY_STRING);
+ etPassword.setText(CommonUtilities.EMPTY_STRING);
+ etDomain.setText(CommonUtilities.EMPTY_STRING);
+ btnRegister.setEnabled(false);
+ btnRegister.setBackground(getResources().getDrawable(R.drawable.btn_grey));
+ btnRegister.setTextColor(getResources().getColor(R.color.black));
+ }
+ };
private void showEnrollementFailedErrorMessage() {
CommonDialogUtils.stopProgressDialog(progressDialog);
alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.error_enrollment_failed),
- getResources().getString(R.string.error_enrollment_failed_detail),
- getResources().getString(R.string.button_ok),
- senderIdFailedClickListener);
- }
-
- private void managePushNotification(String mode, float interval, Editor editor) {
- if (mode.trim().toUpperCase().contains("LOCAL")) {
- CommonUtilities.LOCAL_NOTIFICATIONS_ENABLED = true;
- CommonUtilities.GCM_ENABLED = false;
- String androidID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
- // if (senderId == null || senderId.equals("")) {
- editor.putString(getResources().getString(R.string.shared_pref_regId), androidID);
- // }
- editor.commit();
-
- startLocalNotification(interval);
- } else if (mode.trim().toUpperCase().contains("GCM")) {
- CommonUtilities.LOCAL_NOTIFICATIONS_ENABLED = false;
- CommonUtilities.GCM_ENABLED = true;
- // editor.commit();
- GCMRegistrar.register(context, CommonUtilities.SENDER_ID);
- }
-
- // if (senderId!=null && !senderId.equals("")) {
- // CommonUtilities.GCM_ENABLED = true;
- // GCMRegistrar.register(context, CommonUtilities.SENDER_ID);
- // }
- }
-
- @Override
- public void onAPIAccessRecive(String status) {
- if (status != null) {
- if (status.trim().equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
-
- SharedPreferences mainPref =
- this.getSharedPreferences(getResources().getString(R.string.shared_pref_package),
- Context.MODE_PRIVATE);
- Editor editor = mainPref.edit();
- editor.putString(getResources().getString(R.string.shared_pref_username),
- usernameForRegister);
- editor.commit();
-
- Map requestParams = new HashMap();
- requestParams.put("domain", etDomain.getText().toString().trim());
- // Check network connection availability before calling the API.
- if (PhoneState.isNetworkAvailable(context)) {
- // Call get sender ID API.
- Log.e("sender id ", "call");
- ServerUtils.callSecuredAPI(AuthenticationActivity.this,
- CommonUtilities.SENDER_ID_ENDPOINT,
- CommonUtilities.GET_METHOD, requestParams,
- AuthenticationActivity.this,
- CommonUtilities.SENDER_ID_REQUEST_CODE);
- } else {
- CommonDialogUtils.stopProgressDialog(progressDialog);
- CommonDialogUtils.showNetworkUnavailableMessage(AuthenticationActivity.this);
- }
-
- } else if (status.trim().equals(CommonUtilities.AUTHENTICATION_FAILED)) {
- CommonDialogUtils.stopProgressDialog(progressDialog);
- alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.title_head_authentication_error),
- getResources().getString(R.string.error_authentication_failed),
- getResources().getString(R.string.button_ok),
- dialogClickListener);
- } else if (status.trim().equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
- showInternalServerErrorMessage();
-
- } else {
- Log.e(TAG, "Status: " + status);
- showAuthCommonErrorMessage();
- }
-
- } else {
- Log.e(TAG, "The value of status is null in onAPIAccessRecive()");
- showAuthCommonErrorMessage();
- }
-
+ CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
+ getResources().getString(
+ R.string.error_enrollment_failed),
+ getResources().getString(
+ R.string.error_enrollment_failed_detail),
+ getResources().getString(
+ R.string.button_ok),
+ senderIdFailedClickListener
+ );
}
private void showInternalServerErrorMessage() {
CommonDialogUtils.stopProgressDialog(progressDialog);
alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.title_head_connection_error),
- getResources().getString(R.string.error_internal_server),
- getResources().getString(R.string.button_ok),
- null);
+ CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
+ getResources().getString(
+ R.string.title_head_connection_error),
+ getResources().getString(
+ R.string.error_internal_server),
+ getResources().getString(
+ R.string.button_ok),
+ null
+ );
}
/**
* Shows common error message for authentication.
- *
*/
private void showAuthCommonErrorMessage() {
CommonDialogUtils.stopProgressDialog(progressDialog);
alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.title_head_authentication_error),
- getResources().getString(R.string.error_for_all_unknown_authentication_failures),
- getResources().getString(R.string.button_ok),
- null);
+ CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
+ getResources().getString(
+ R.string.title_head_authentication_error),
+ getResources().getString(
+ R.string.error_for_all_unknown_authentication_failures),
+ getResources().getString(
+ R.string.button_ok),
+ null
+ );
}
-
- private void startLocalNotification(Float interval) {
- long firstTime = SystemClock.elapsedRealtime();
- firstTime += 1 * 1000;
-
- Intent downloader = new Intent(context, AlarmReceiver.class);
- PendingIntent recurringDownload =
- PendingIntent.getBroadcast(context,
- 0,
- downloader,
- PendingIntent.FLAG_CANCEL_CURRENT);
- AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- Float seconds = interval;
- if (interval < 1.0) {
-
- alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime,
- seconds.intValue(), recurringDownload);
- } else {
- alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime,
- seconds.intValue(), recurringDownload);
- }
-
- }
-
- /**
- * Manipulates the sender ID response.
- *
- * @param result
- * the result of the sender ID request
- */
- private void manipulateSenderIdResponse(Map result) {
- String responseStatus;
- JSONObject response;
-
- String mode = "";
- Float interval = (float) 1.0;
-
- CommonDialogUtils.stopProgressDialog(progressDialog);
-
- if (result != null) {
- responseStatus = result.get(CommonUtilities.STATUS_KEY);
- if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
- try {
- response = new JSONObject(result.get(Constant.RESPONSE));
- senderId = response.getString("sender_id");
- mode = response.getString("notifier");
- interval = (float) Float.parseFloat(response.getString("notifierInterval"));
-
- } catch (JSONException e) {
- e.printStackTrace();
- }
- SharedPreferences mainPref =
- context.getSharedPreferences(getResources().getString(R.string.shared_pref_package),
- Context.MODE_PRIVATE);
- Editor editor = mainPref.edit();
-
- if (senderId != null && !senderId.equals("")) {
- CommonUtilities.setSENDER_ID(senderId);
- GCMRegistrar.register(context, senderId);
- editor.putString(getResources().getString(R.string.shared_pref_sender_id),
- senderId);
- }
- editor.putString(getResources().getString(R.string.shared_pref_message_mode), mode);
-
- editor.putFloat(getResources().getString(R.string.shared_pref_interval), interval);
- editor.commit();
-
- managePushNotification(mode, interval, editor);
- getLicense();
-
- } else if (responseStatus.equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
- Log.e(TAG, "The result is : " + result);
- showInternalServerErrorMessage();
-
- } else {
- Log.e(TAG, "The result is : " + result);
- showEnrollementFailedErrorMessage();
- }
- } else {
- Log.e(TAG, "The result is null in manipulateSenderIdResponse()");
- showEnrollementFailedErrorMessage();
- }
-
- }
-
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/GCMIntentService.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/GCMIntentService.java
index 2cc95e2a7..c4a20257d 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/GCMIntentService.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/GCMIntentService.java
@@ -19,7 +19,7 @@ package org.wso2.cdm.agent;
import org.wso2.cdm.agent.R;
import org.wso2.cdm.agent.api.ApplicationManager;
import org.wso2.cdm.agent.services.Config;
-import org.wso2.cdm.agent.services.ProcessMessage;
+import org.wso2.cdm.agent.services.MessageProcessor;
import org.wso2.cdm.agent.utils.CommonUtilities;
import android.app.Notification;
@@ -41,7 +41,7 @@ public class GCMIntentService extends GCMBaseIntentService {
DevicePolicyManager devicePolicyManager;
ApplicationManager appList;
static final int ACTIVATION_REQUEST = 47;
- ProcessMessage processMsg = null;
+ MessageProcessor processMsg = null;
@SuppressWarnings("hiding")
private static final String TAG = "GCMIntentService";
@@ -89,8 +89,8 @@ public class GCMIntentService extends GCMBaseIntentService {
String mode=CommonUtilities.getPref(context, context.getResources().getString(R.string.shared_pref_message_mode));
if(mode.trim().toUpperCase().equals("GCM")){
Log.e("onmsg","GCM");
- ProcessMessage msg=new ProcessMessage(context);
- msg.getOperations(null);
+ MessageProcessor msg=new MessageProcessor(context);
+ msg.getMessages();
}
else{
Log.e("onmsg","mode");
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/PinCodeActivity.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/PinCodeActivity.java
index 6b9ec77eb..6ea13b09f 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/PinCodeActivity.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/PinCodeActivity.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +15,6 @@
*/
package org.wso2.cdm.agent;
-
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
@@ -23,7 +22,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -35,8 +33,12 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
+import android.text.InputType;
+import android.text.method.PasswordTransformationMethod;
+import android.util.Log;
import org.wso2.cdm.agent.R;
+import org.wso2.cdm.agent.utils.CommonDialogUtils;
import org.wso2.cdm.agent.utils.Preference;
public class PinCodeActivity extends Activity {
@@ -45,62 +47,62 @@ public class PinCodeActivity extends Activity {
private EditText txtOldPin;
private Button btnPin;
private String username = null;
- private String REG_ID = "";
+ private String regId = "";
private final int TAG_BTN_SET_PIN = 0;
- private String FROM_ACTIVITY = null;
- private String MAIN_ACTIVITY = null;
+ private String fromActivity = null;
Context context;
+ AlertDialog.Builder alertDialog;
+ EditText input;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pin_code);
- context=PinCodeActivity.this;
+ context = PinCodeActivity.this;
Bundle extras = getIntent().getExtras();
if (extras != null) {
if (extras.containsKey(getResources().getString(R.string.intent_extra_username))) {
- username = extras.getString(getResources().getString(R.string.intent_extra_username));
+ username =
+ extras.getString(getResources().getString(R.string.intent_extra_username));
}
if (extras.containsKey(getResources().getString(R.string.intent_extra_regid))) {
- REG_ID = extras.getString(getResources().getString(R.string.intent_extra_regid));
- }
-
- if(extras.containsKey(getResources().getString(R.string.intent_extra_from_activity))){
- FROM_ACTIVITY = extras.getString(getResources().getString(R.string.intent_extra_from_activity));
+ regId = extras.getString(getResources().getString(R.string.intent_extra_regid));
}
-
- if(extras.containsKey(getResources().getString(R.string.intent_extra_main_activity))){
- MAIN_ACTIVITY = extras.getString(getResources().getString(R.string.intent_extra_main_activity));
+
+ if (extras.containsKey(getResources().getString(R.string.intent_extra_from_activity))) {
+ fromActivity = extras.getString(
+ getResources().getString(R.string.intent_extra_from_activity));
}
}
-
+
lblPin = (TextView) findViewById(R.id.lblPin);
txtPin = (EditText) findViewById(R.id.txtPinCode);
txtOldPin = (EditText) findViewById(R.id.txtOldPinCode);
btnPin = (Button) findViewById(R.id.btnSetPin);
btnPin.setTag(TAG_BTN_SET_PIN);
- btnPin.setOnClickListener(onClickListener_BUTTON_CLICKED);
+ btnPin.setOnClickListener(onClickListenerButtonClicked);
btnPin.setEnabled(false);
btnPin.setBackground(getResources().getDrawable(R.drawable.btn_grey));
btnPin.setTextColor(getResources().getColor(R.color.black));
-
- if(FROM_ACTIVITY != null && FROM_ACTIVITY.equals(AlreadyRegisteredActivity.class.getSimpleName())){
+
+ if (fromActivity != null &&
+ fromActivity.equals(AlreadyRegisteredActivity.class.getSimpleName())) {
lblPin.setVisibility(View.GONE);
txtOldPin.setVisibility(View.VISIBLE);
txtPin.setHint(getResources().getString(R.string.hint_new_pin));
txtPin.setEnabled(true);
-
+
txtPin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
+ int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
- int count) {
+ int count) {
enableNewPINSubmitIfReady();
}
@@ -109,16 +111,16 @@ public class PinCodeActivity extends Activity {
enableSubmitIfReady();
}
});
-
+
txtOldPin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
+ int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
- int count) {
+ int count) {
enableNewPINSubmitIfReady();
}
@@ -127,16 +129,16 @@ public class PinCodeActivity extends Activity {
enableSubmitIfReady();
}
});
- }else{
+ } else {
txtPin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
+ int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
- int count) {
+ int count) {
enableSubmitIfReady();
}
@@ -148,26 +150,48 @@ public class PinCodeActivity extends Activity {
}
}
- OnClickListener onClickListener_BUTTON_CLICKED = new OnClickListener() {
+ OnClickListener onClickListenerButtonClicked = new OnClickListener() {
@Override
public void onClick(View view) {
- int iTag = (Integer) view.getTag();
-
- switch (iTag) {
-
- case TAG_BTN_SET_PIN:
- AlertDialog.Builder builder = new AlertDialog.Builder(
- PinCodeActivity.this);
- builder.setMessage(
- getResources().getString(R.string.dialog_pin_confirmation)
- + " " +txtPin.getText().toString() + " "
- + getResources().getString(R.string.dialog_pin_confirmation_end))
- .setPositiveButton(getResources().getString(R.string.yes), dialogClickListener)
- .setNegativeButton(getResources().getString(R.string.no), dialogClickListener).show();
- break;
- default:
- break;
+ int viewTag = (Integer) view.getTag();
+
+ switch (viewTag) {
+
+ case TAG_BTN_SET_PIN:
+ input = new EditText(PinCodeActivity.this);
+ alertDialog = CommonDialogUtils
+ .getAlertDialogWithTwoButtonAndEditView(PinCodeActivity.this,
+ getResources().getString(
+ R.string.title_head_confirm_pin)
+ , getResources().getString(R.string.button_ok),
+ getResources().getString(
+ R.string.button_cancel),
+ dialogClickListener,
+ dialogClickListener, input);
+
+ final AlertDialog dialog = alertDialog.create();
+ dialog.show();
+ //Overriding default positive button behavior to keep the dialog open, if PINS don't match
+ dialog.getButton(AlertDialog.BUTTON_POSITIVE)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (txtPin.getText().toString()
+ .equals(input.getText().toString())) {
+ savePin();
+ dialog.dismiss();
+ } else {
+ input.setError(getResources().getString(
+ R.string.validation_pin_confirm));
+ }
+ }
+ });
+ input.setInputType(InputType.TYPE_CLASS_NUMBER);
+ input.setTransformationMethod(new PasswordTransformationMethod());
+ break;
+ default:
+ break;
}
}
@@ -177,29 +201,34 @@ public class PinCodeActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
- case DialogInterface.BUTTON_POSITIVE:
- savePin();
- break;
+ case DialogInterface.BUTTON_POSITIVE:
+ savePin();
+ break;
- case DialogInterface.BUTTON_NEGATIVE:
- dialog.dismiss();
- break;
+ case DialogInterface.BUTTON_NEGATIVE:
+ dialog.dismiss();
+ break;
}
}
};
public void savePin() {
- Preference.put(context, getResources().getString(R.string.shared_pref_pin), txtPin.getText().toString().trim());
-
- if(FROM_ACTIVITY != null && (FROM_ACTIVITY.equals(AlreadyRegisteredActivity.class.getSimpleName()))){
- Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_message_pin_change_success), Toast.LENGTH_SHORT).show();
- Intent intent = new Intent(PinCodeActivity.this,AlreadyRegisteredActivity.class);
- intent.putExtra(getResources().getString(R.string.intent_extra_from_activity), PinCodeActivity.class.getSimpleName());
- intent.putExtra(getResources().getString(R.string.intent_extra_regid), REG_ID);
- startActivity(intent);
- }else{
+ Preference.put(context, getResources().getString(R.string.shared_pref_pin),
+ txtPin.getText().toString().trim());
+
+ if (fromActivity != null &&
+ (fromActivity.equals(AlreadyRegisteredActivity.class.getSimpleName()))) {
+ Toast.makeText(getApplicationContext(),
+ getResources().getString(R.string.toast_message_pin_change_success),
+ Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(PinCodeActivity.this, AlreadyRegisteredActivity.class);
+ intent.putExtra(getResources().getString(R.string.intent_extra_from_activity),
+ PinCodeActivity.class.getSimpleName());
+ intent.putExtra(getResources().getString(R.string.intent_extra_regid), regId);
+ startActivity(intent);
+ } else {
Intent intent = new Intent(PinCodeActivity.this, RegistrationActivity.class);
- intent.putExtra(getResources().getString(R.string.intent_extra_regid), REG_ID);
+ intent.putExtra(getResources().getString(R.string.intent_extra_regid), regId);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(getResources().getString(R.string.intent_extra_username), username);
startActivity(intent);
@@ -225,29 +254,34 @@ public class PinCodeActivity extends Activity {
btnPin.setEnabled(false);
}
}
-
+
@SuppressLint("NewApi")
public void enableNewPINSubmitIfReady() {
boolean isReady = false;
- SharedPreferences mainPref = this.getSharedPreferences(getResources().getString(R.string.shared_pref_package),
- Context.MODE_PRIVATE);
+ SharedPreferences mainPref =
+ this.getSharedPreferences(getResources().getString(R.string.shared_pref_package),
+ Context.MODE_PRIVATE);
String pin = mainPref.getString(getResources().getString(R.string.shared_pref_pin), "");
- if(txtOldPin.getText().toString().trim().length() >= 4 && txtOldPin.getText().toString().trim().equals(pin.trim())){
+ if (txtOldPin.getText().toString().trim().length() >= 4 &&
+ txtOldPin.getText().toString().trim().equals(pin.trim())) {
txtPin.setEnabled(true);
- }else{
+ } else {
txtPin.setEnabled(false);
}
-
- if (txtPin.getText().toString().trim().length() >= 4 && txtOldPin.getText().toString().trim().length() >= 4) {
- if(txtOldPin.getText().toString().trim().equals(pin.trim())){
+
+ if (txtPin.getText().toString().trim().length() >= 4 &&
+ txtOldPin.getText().toString().trim().length() >= 4) {
+ if (txtOldPin.getText().toString().trim().equals(pin.trim())) {
isReady = true;
- }else{
+ } else {
isReady = false;
- Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_message_pin_change_failed), Toast.LENGTH_SHORT).show();
+ Toast.makeText(getApplicationContext(),
+ getResources().getString(R.string.toast_message_pin_change_failed),
+ Toast.LENGTH_SHORT).show();
}
}
-
+
if (isReady) {
btnPin.setBackground(getResources().getDrawable(R.drawable.btn_orange));
btnPin.setTextColor(getResources().getColor(R.color.white));
@@ -258,30 +292,30 @@ public class PinCodeActivity extends Activity {
btnPin.setEnabled(false);
}
}
-
+
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && FROM_ACTIVITY != null && FROM_ACTIVITY.equals(AlreadyRegisteredActivity.class.getSimpleName())) {
- Intent intent = new Intent(PinCodeActivity.this,AlreadyRegisteredActivity.class);
- intent.putExtra(getResources().getString(R.string.intent_extra_from_activity), PinCodeActivity.class.getSimpleName());
- intent.putExtra(getResources().getString(R.string.intent_extra_regid), REG_ID);
- startActivity(intent);
- return true;
- }else if (keyCode == KeyEvent.KEYCODE_BACK) {
- Intent i = new Intent();
- i.setAction(Intent.ACTION_MAIN);
- i.addCategory(Intent.CATEGORY_HOME);
- this.startActivity(i);
- this.finish();
- return true;
- }
- return super.onKeyDown(keyCode, event);
+ if (keyCode == KeyEvent.KEYCODE_BACK && fromActivity != null &&
+ fromActivity.equals(AlreadyRegisteredActivity.class.getSimpleName())) {
+ Intent intent = new Intent(PinCodeActivity.this, AlreadyRegisteredActivity.class);
+ intent.putExtra(getResources().getString(R.string.intent_extra_from_activity),
+ PinCodeActivity.class.getSimpleName());
+ intent.putExtra(getResources().getString(R.string.intent_extra_regid), regId);
+ startActivity(intent);
+ return true;
+ } else if (keyCode == KeyEvent.KEYCODE_BACK) {
+ Intent i = new Intent();
+ i.setAction(Intent.ACTION_MAIN);
+ i.addCategory(Intent.CATEGORY_HOME);
+ this.startActivity(i);
+ this.finish();
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- // getMenuInflater().inflate(R.menu.pin_code, menu);
return true;
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/RegistrationActivity.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/RegistrationActivity.java
index 4b005e1fc..98ea93944 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/RegistrationActivity.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/RegistrationActivity.java
@@ -15,9 +15,9 @@
*/
package org.wso2.cdm.agent;
-import java.util.HashMap;
import java.util.Map;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.wso2.cdm.agent.R;
@@ -26,25 +26,21 @@ import org.wso2.cdm.agent.api.PhoneState;
import org.wso2.cdm.agent.proxy.APIResultCallBack;
import org.wso2.cdm.agent.utils.CommonDialogUtils;
import org.wso2.cdm.agent.utils.CommonUtilities;
-import org.wso2.cdm.agent.utils.HTTPConnectorUtils;
import org.wso2.cdm.agent.utils.Preference;
import org.wso2.cdm.agent.utils.ServerUtils;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
-import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
-import android.widget.TextView;
public class RegistrationActivity extends Activity implements APIResultCallBack {
@@ -77,7 +73,6 @@ public class RegistrationActivity extends Activity implements APIResultCallBack
DeviceInfo deviceInfo = new DeviceInfo(RegistrationActivity.this);
JSONObject jsObject = new JSONObject();
- String osVersion = "";
SharedPreferences mainPref =
RegistrationActivity.this.getSharedPreferences(RegistrationActivity.this.getResources()
.getString(R.string.shared_pref_package),
@@ -86,33 +81,54 @@ public class RegistrationActivity extends Activity implements APIResultCallBack
mainPref.getString(RegistrationActivity.this.getResources()
.getString(R.string.shared_pref_reg_type),
"");
+ String username =
+ mainPref.getString(RegistrationActivity.this.getResources()
+ .getString(R.string.username),
+ "");
- osVersion = deviceInfo.getOsVersion();
try {
- jsObject.put("device", deviceInfo.getDevice());
- jsObject.put("imei", deviceInfo.getDeviceId());
- jsObject.put("imsi", deviceInfo.getIMSINumber());
- jsObject.put("model", deviceInfo.getDeviceModel());
-
- Map requestParams = new HashMap();
- requestParams.put("regid", regId);
- requestParams.put("properties", jsObject.toString());
- requestParams.put("osversion", osVersion);
- requestParams.put("username", username);
- requestParams.put("platform", "Android");
- requestParams.put("vendor", deviceInfo.getDeviceManufacturer());
- requestParams.put("type", type);
- requestParams.put("mac", deviceInfo.getMACAddress());
+ jsObject.put("deviceIdentifier", deviceInfo.getMACAddress());
+ jsObject.put("description", deviceInfo.getDevice());
+ jsObject.put("ownership", type);
+ JSONArray propertiesArray=new JSONArray();
+ JSONObject property= new JSONObject();
+ property.put("name", "username");
+ property.put("value", username);
+ propertiesArray.put(property);
+ property= new JSONObject();
+ property.put("name", "device");
+ property.put("value", deviceInfo.getDevice());
+ propertiesArray.put(property);
+ property= new JSONObject();
+ property.put("name", "imei");
+ property.put("value", deviceInfo.getDeviceId());
+ propertiesArray.put(property);
+ property= new JSONObject();
+ property.put("name", "imsi");
+ property.put("value", deviceInfo.getIMSINumber());
+ propertiesArray.put(property);
+ property= new JSONObject();
+ property.put("name", "model");
+ property.put("value", deviceInfo.getDeviceModel());
+ propertiesArray.put(property);
+ property= new JSONObject();
+ property.put("name", "vendor");
+ property.put("value", deviceInfo.getOsVersion());
+ propertiesArray.put(property);
+ property= new JSONObject();
+ property.put("name", "osVersion");
+ property.put("value", deviceInfo.getOsVersion());
+ propertiesArray.put(property);
+ jsObject.put("properties", propertiesArray);
// Check network connection availability before calling the API.
if (PhoneState.isNetworkAvailable(context)) {
// Call device registration API.
- sendDeviceDetails(requestParams);
-// ServerUtils.callSecuredAPI(RegistrationActivity.this,
-// CommonUtilities.REGISTER_ENDPOINT,
-// CommonUtilities.POST_METHOD, requestParams,
-// RegistrationActivity.this,
-// CommonUtilities.REGISTER_REQUEST_CODE);
+ ServerUtils.callSecuredAPI(RegistrationActivity.this,
+ CommonUtilities.API_SERVER_URL + CommonUtilities.REGISTER_ENDPOINT,
+ CommonUtilities.POST_METHOD, jsObject,
+ RegistrationActivity.this,
+ CommonUtilities.REGISTER_REQUEST_CODE);
} else {
CommonDialogUtils.stopProgressDialog(progressDialog);
CommonDialogUtils.showNetworkUnavailableMessage(RegistrationActivity.this);
@@ -123,83 +139,6 @@ public class RegistrationActivity extends Activity implements APIResultCallBack
}
}
-
- private void sendDeviceDetails(final Map requestParams) {
-
- AsyncTask> mLicenseTask =
- new AsyncTask>() {
-
- @Override
- protected Map doInBackground(Void... params) {
- Map response;
- response =
- HTTPConnectorUtils.postData(context,CommonUtilities.SERVER_URL+CommonUtilities.REGISTER_ENDPOINT,requestParams
- );
- return response;
- }
-
- @Override
- protected void onPreExecute() {};
-
- @Override
- protected void onPostExecute(Map result) {
- CommonDialogUtils.stopProgressDialog(progressDialog);
- manipulateDeviceDetails(result);
- }
-
- };
-
- mLicenseTask.execute();
-
- }
-
- private void manipulateDeviceDetails(Map result){
- CommonDialogUtils.stopProgressDialog(progressDialog);
- String responseStatus = "";
- if (result != null) {
- responseStatus = result.get(CommonUtilities.STATUS_KEY);
-
- if (responseStatus.equals(CommonUtilities.REGISTERATION_SUCCESSFUL)) {
- Intent intent =
- new Intent(RegistrationActivity.this,
- AlreadyRegisteredActivity.class);
- intent.putExtra(getResources().getString(R.string.intent_extra_fresh_reg_flag),
- true);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- } else if (responseStatus.equals(CommonUtilities.INTERNAL_SERVER_ERROR)) {
- Log.e(TAG, "The value of status is : " + responseStatus);
- alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.title_head_connection_error),
- getResources().getString(R.string.error_internal_server),
- getResources().getString(R.string.button_ok),
- registrationFailedOKBtnClickListerner);
- } else {
- Log.e(TAG, "The value of status is : " + responseStatus);
- Log.e(TAG, "The responseStatus is : " + responseStatus);
- alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.title_head_registration_error),
- getResources().getString(R.string.error_for_all_unknown_registration_failures),
- getResources().getString(R.string.button_ok),
- registrationFailedOKBtnClickListerner);
- alertDialog.show();
- }
-
- } else {
- Log.e(TAG, "The result is null in onReceiveAPIResult(). ");
- Log.e(TAG, "The responseStatus is : " + responseStatus);
- alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.title_head_registration_error),
- getResources().getString(R.string.error_for_all_unknown_registration_failures),
- getResources().getString(R.string.button_ok),
- registrationFailedOKBtnClickListerner);
- alertDialog.show();
-
- }
- }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
@@ -242,7 +181,7 @@ public class RegistrationActivity extends Activity implements APIResultCallBack
if (result != null) {
responseStatus = result.get(CommonUtilities.STATUS_KEY);
- if (responseStatus.equals(CommonUtilities.REGISTERATION_SUCCESSFUL)) {
+ if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
Intent intent =
new Intent(RegistrationActivity.this,
AlreadyRegisteredActivity.class);
@@ -261,8 +200,6 @@ public class RegistrationActivity extends Activity implements APIResultCallBack
registrationFailedOKBtnClickListerner);
alertDialog.show();
} else {
- Log.e(TAG, "The value of status is : " + responseStatus);
- Log.e(TAG, "The responseStatus is : " + responseStatus);
alertDialog =
CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
getResources().getString(R.string.title_head_registration_error),
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/ServerDetails.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/ServerDetails.java
index a9e28245a..13aee37ee 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/ServerDetails.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/ServerDetails.java
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,6 +30,7 @@ import android.widget.TextView;
import android.widget.Toast;
import org.wso2.cdm.agent.api.DeviceInfo;
+import org.wso2.cdm.agent.services.MessageProcessor;
import org.wso2.cdm.agent.utils.CommonDialogUtils;
import org.wso2.cdm.agent.utils.CommonUtilities;
import org.wso2.cdm.agent.utils.Preference;
@@ -73,18 +74,23 @@ public class ServerDetails extends Activity {
tvSeverAddress.setVisibility(View.GONE);
evServerIP.setVisibility(View.GONE);
alertDialog =
- CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- getResources().getString(R.string.error_authorization_failed),
- getResources().getString(compatibility.getDescriptionResourceID()),
- getResources().getString(R.string.button_ok),
- onRootedClickListner);
+ CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
+ getResources().getString(
+ R.string.error_authorization_failed),
+ getResources().getString(
+ compatibility
+ .getDescriptionResourceID()),
+ getResources().getString(
+ R.string.button_ok),
+ onRootedClickListner);
} else {
btnStartRegistration.setVisibility(View.VISIBLE);
evServerIP.setVisibility(View.VISIBLE);
String ipSaved =
- Preference.get(context.getApplicationContext(),
- getResources().getString(R.string.shared_pref_ip));
- regId = Preference.get(context.getApplicationContext(), getResources().getString(R.string.shared_pref_regId));
+ Preference.get(context.getApplicationContext(),
+ getResources().getString(R.string.shared_pref_ip));
+ regId = Preference.get(context.getApplicationContext(),
+ getResources().getString(R.string.shared_pref_regId));
//check if we have the IP saved previously.
if (ipSaved != null) {
@@ -94,23 +100,31 @@ public class ServerDetails extends Activity {
} else {
evServerIP.setText(CommonUtilities.SERVER_IP);
}
-
+
+ String deviceActive=Preference.get(context, context.getResources().getString(R.string.shared_pref_device_active));
+ if(deviceActive!=null && deviceActive.equals("1")){
+ Intent intent = new Intent(ServerDetails.this, AlreadyRegisteredActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ }
// on click handler for start registration
btnStartRegistration.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ServerDetails.this);
StringBuilder messageBuilder = new StringBuilder();
- messageBuilder.append(getResources().getString(R.string.dialog_init_confirmation));
+ messageBuilder
+ .append(getResources().getString(R.string.dialog_init_confirmation));
messageBuilder.append(" ");
messageBuilder.append(evServerIP.getText().toString());
messageBuilder.append(" ");
- messageBuilder.append(getResources().getString(R.string.dialog_init_end_general));
+ messageBuilder
+ .append(getResources().getString(R.string.dialog_init_end_general));
alertBuilder.setMessage(messageBuilder.toString())
- .setPositiveButton(getResources().getString(R.string.yes),
- dialogClickListener)
- .setNegativeButton(getResources().getString(R.string.no),
- dialogClickListener).show();
+ .setPositiveButton(getResources().getString(R.string.yes),
+ dialogClickListener)
+ .setNegativeButton(getResources().getString(R.string.no),
+ dialogClickListener).show();
}
});
@@ -120,7 +134,8 @@ public class ServerDetails extends Activity {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
if (!evServerIP.getText().toString().trim().equals("")) {
- CommonUtilities.setServerURL(evServerIP.getText().toString().trim());
+ CommonUtilities
+ .setServerURL(evServerIP.getText().toString().trim());
Preference.put(context.getApplicationContext(),
getResources().getString(R.string.shared_pref_ip),
evServerIP.getText().toString().trim());
@@ -128,7 +143,8 @@ public class ServerDetails extends Activity {
} else {
Toast.makeText(context.getApplicationContext(),
- getResources().getString(R.string.toast_message_enter_server_address),
+ getResources().getString(
+ R.string.toast_message_enter_server_address),
Toast.LENGTH_LONG).show();
}
break;
@@ -151,7 +167,7 @@ public class ServerDetails extends Activity {
};
/**
- * This method is called to open AuthenticationActivity.
+ * This method is called to open AuthenticationActivity.
*/
private void startAuthenticationActivity() {
Intent intent = new Intent(ServerDetails.this, AuthenticationActivity.class);
@@ -169,190 +185,4 @@ public class ServerDetails extends Activity {
context = null;
super.onDestroy();
}
-
-
-
-
-
- // Old API manager communication code.
- //
- // Bundle extras = getIntent().getExtras();
- //
- // if (extras != null) {
- // if
- // (extras.containsKey(getResources().getString(R.string.intent_extra_from_activity)))
- // {
- // fromActivity =
- // extras.getString(
- // getResources().getString(R.string.intent_extra_from_activity));
- // }
- // }
- //
- //
- // public class ServerDetails extends Activity implements APIResultCallBack,
- // TokenCallBack {
- // @Override
- // public void onBackPressed() {
- // Intent i = new Intent();
- // i.setAction(Intent.ACTION_MAIN);
- // i.addCategory(Intent.CATEGORY_HOME);
- // this.startActivity(i);
- // super.onBackPressed();
- // }
- //
- // @Override
- // public boolean onKeyDown(int keyCode, KeyEvent event) {
- // if (keyCode == KeyEvent.KEYCODE_BACK && fromActivity != null &&
- // fromActivity.equals(AlreadyRegisteredActivity.class.getSimpleName())) {
- // Intent i = new Intent();
- // i.setAction(Intent.ACTION_MAIN);
- // i.addCategory(Intent.CATEGORY_HOME);
- // this.startActivity(i);
- // this.finish();
- // return true;
- // } else if (keyCode == KeyEvent.KEYCODE_BACK && fromActivity != null &&
- // fromActivity.equals(AuthenticationActivity.class.getSimpleName())) {
- // int pid = android.os.Process.myPid();
- // android.os.Process.killProcess(pid);
- // return true;
- // } else if (keyCode == KeyEvent.KEYCODE_BACK) {
- // Intent i = new Intent();
- // i.setAction(Intent.ACTION_MAIN);
- // i.addCategory(Intent.CATEGORY_HOME);
- // this.startActivity(i);
- // this.finish();
- // return true;
- // }
- // return super.onKeyDown(keyCode, event);
- // }
- //
- // @Override
- // public boolean onCreateOptionsMenu(Menu menu) {
- // // Inflate the menu; this adds items to the action bar if it is present.
- // getMenuInflater().inflate(R.menu.settings, menu);
- // return true;
- // }
- //
- // public void onReceiveAPIResult(Map result, int
- // requestCode) {
- // String responseStatus = CommonUtilities.EMPTY_STRING;
- // if (result != null) {
- // responseStatus = result.get(CommonUtilities.STATUS_KEY);
- //
- // if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL) &&
- // requestCode == CommonUtilities.IS_REGISTERED_REQUEST_CODE) {
- // Intent intent = null;
- // if (progressDialog != null) {
- // progressDialog.dismiss();
- // }
- // intent = new Intent(ServerDetails.this, AlreadyRegisteredActivity.class);
- // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- // startActivity(intent);
- //
- // } else if (responseStatus.equals(CommonUtilities.INTERNAL_SERVER_ERROR))
- // {
- // Log.e(TAG, "The value of status is null in onAPIAccessRecive()");
- //
- // String isRegistered =
- // CommonUtilities.getPref(context,
- // context.getResources()
- // .getString(R.string.shared_pref_registered)
- // );
- // if (isRegistered.equals("1")) {
- // Intent intent = null;
- // intent = new Intent(ServerDetails.this, AlreadyRegisteredActivity.class);
- // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- // startActivity(intent);
- // } else {
- // alertDialog =
- // CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- // getResources()
- // .getString(
- // R.string.title_head_connection_error),
- // getResources()
- // .getString(
- // R.string.error_internal_server),
- // getResources()
- // .getString(
- // R.string.button_ok),
- // null);
- // Log.e("null", alertDialog.getClass().getPackage().toString());
- // alertDialog.show();
- // }
- // // ServerUtils.clearAppData(context);
- // } else {
- // Log.e(TAG, "The value of status is : " + responseStatus);
- // ServerUtils.clearAppData(context);
- //
- // alertDialog =
- // CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- // getResources()
- // .getString(
- // R.string.title_head_registration_error),
- // getResources()
- // .getString(
- // R.string.error_internal_server),
- // getResources()
- // .getString(
- // R.string.button_ok),
- // null);
- // alertDialog.show();
- // }
- // } else {
- // Log.e(TAG, "The result is null in onReceiveAPIResult()");
- // ServerUtils.clearAppData(context);
- //
- // alertDialog =
- // CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
- // getResources().getString(
- // R.string.title_head_registration_error),
- // getResources().getString(
- // R.string.error_for_all_unknown_registration_failures),
- // getResources().getString(
- // R.string.button_ok),
- // null);
- // alertDialog.show();
- // }
- // }
- //
- // @Override
- // public void onReceiveTokenResult(Token token, String status) {
- // if (token != null) {
- // if (regId != null && !regId.equals("")) {
- // // Check registration.
- // isRegistered();
- //
- // progressDialog =
- // ProgressDialog.show(ServerDetails.this,
- // getResources().getString(R.string.dialog_sender_id),
- // getResources().getString(R.string.dialog_please_wait),
- // true);
- // }
- // }
- // }
- //
- // /**
- // * Checks whether device is registered or NOT.
- // */
- // private void isRegistered() {
- // Log.e("isReg", "isReg");
- // Map requestParams = new HashMap();
- // requestParams.put("regid", regId);
- // Log.e("regID", regId);
- //
- // // Check network connection availability before calling the API.
- // if (PhoneState.isNetworkAvailable(context)) {
- // // Call isRegistered API.
- // ServerUtils.callSecuredAPI(ServerDetails.this,
- // CommonUtilities.IS_REGISTERED_ENDPOINT,
- // CommonUtilities.POST_METHOD, requestParams,
- // ServerDetails.this,
- // CommonUtilities.IS_REGISTERED_REQUEST_CODE);
- // } else {
- // CommonDialogUtils.stopProgressDialog(progressDialog);
- // CommonDialogUtils.showNetworkUnavailableMessage(ServerDetails.this);
- // }
- //
- // }
-
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIController.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIController.java
index 0be47ef68..12662dfaf 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIController.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIController.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.wso2.cdm.agent.proxy;
import java.util.HashMap;
@@ -61,16 +76,16 @@ public class APIController implements TokenCallBack {
protected Map doInBackground(APIUtilities... params) {
APIUtilities apiUtilities = params[0];
- Map response_params = null;
+ Map responseParams = null;
try {
String accessToken = token.getAccessToken();
Map headers = new HashMap();
- headers.put("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+ headers.put("Content-Type", "application/json");
headers.put("Accept", "*/*");
headers.put("User-Agent", "Mozilla/5.0 ( compatible ), Android");
headers.put("Authorization", "Bearer " + accessToken);
- response_params = ServerUtilitiesTemp.postData(apiUtilities, headers);
- return response_params;
+ responseParams = ServerApiAccess.postData(apiUtilities, headers);
+ return responseParams;
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIUtilities.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIUtilities.java
index 08b65f3a8..fe518d50a 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIUtilities.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/APIUtilities.java
@@ -1,15 +1,39 @@
+/**
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.wso2.cdm.agent.proxy;
import java.util.Map;
+import org.json.JSONObject;
+
public class APIUtilities {
private String httpMethod;
private String endPoint;
- private Map requestParams;
- public Map getRequestParams() {
+ private JSONObject requestParams;
+ private Map requestParamsMap;
+ public Map getRequestParamsMap() {
+ return requestParamsMap;
+ }
+ public void setRequestParamsMap(Map requestParams) {
+ this.requestParamsMap = requestParams;
+ }
+ public JSONObject getRequestParams() {
return requestParams;
}
- public void setRequestParams(Map requestParams) {
+ public void setRequestParams(JSONObject requestParams) {
this.requestParams = requestParams;
}
public String getHttpMethod() {
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/AccessTokenHandler.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/AccessTokenHandler.java
index 30c55e385..af46c60b8 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/AccessTokenHandler.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/AccessTokenHandler.java
@@ -60,14 +60,14 @@ public class AccessTokenHandler extends Activity {
APIUtilities apiUtilities = new APIUtilities();
apiUtilities.setEndPoint(tokenEndPoint);
apiUtilities.setHttpMethod("POST");
- apiUtilities.setRequestParams(request_params);
+ apiUtilities.setRequestParamsMap(request_params);
Map headers = new HashMap();
String authorizationString = "Basic " + new String(Base64.encodeBase64((clientID + ":" + clientSecret).getBytes()));
headers.put("Authorization", authorizationString);
headers.put("Content-Type", "application/x-www-form-urlencoded");
- Map response_params = ServerUtilitiesTemp.postData(apiUtilities,headers);
+ Map response_params = ServerApiAccess.postDataAPI(apiUtilities,headers);
response = response_params.get("response");
responseCode = response_params.get("status");
return response;
@@ -84,7 +84,7 @@ public class AccessTokenHandler extends Activity {
if (responseCode != null && responseCode.equals("200")) {
JSONObject response = new JSONObject(result);
-
+ Log.d("sdf",response.toString());
try{
accessToken = response.getString("access_token");
refreshToken = response.getString("refresh_token");
@@ -99,6 +99,7 @@ public class AccessTokenHandler extends Activity {
Editor editor = mainPref.edit();
editor.putString("access_token", accessToken);
editor.putString("refresh_token",refreshToken);
+ editor.putString("username", username);
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date date = new Date();
long expiresIN=date.getTime()+(timeToExpireSecond*1000);
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/RefreshTokenHandler.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/RefreshTokenHandler.java
index c62372def..6d96f15c2 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/RefreshTokenHandler.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/RefreshTokenHandler.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.wso2.cdm.agent.proxy;
import android.annotation.SuppressLint;
@@ -52,7 +67,7 @@ public class RefreshTokenHandler {
apiUtilities.setEndPoint(IdentityProxy.getInstance()
.getAccessTokenURL());
apiUtilities.setHttpMethod("POST");
- apiUtilities.setRequestParams(request_params);
+ apiUtilities.setRequestParamsMap(request_params);
Map headers = new HashMap();
Log.e("proxy",IdentityProxy.clientID + ":" + IdentityProxy.clientSecret);
@@ -60,7 +75,7 @@ public class RefreshTokenHandler {
headers.put("Authorization", authorizationString);
headers.put("Content-Type", "application/x-www-form-urlencoded");
- Map response_params = ServerUtilitiesTemp.postData(apiUtilities,headers);
+ Map response_params = ServerApiAccess.postDataAPI(apiUtilities,headers);
response = response_params.get("response");
responseCode = response_params.get("status");
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/ServerUtilitiesTemp.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/ServerApiAccess.java
similarity index 74%
rename from product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/ServerUtilitiesTemp.java
rename to product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/ServerApiAccess.java
index 301d14644..5835dde03 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/ServerUtilitiesTemp.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/proxy/ServerApiAccess.java
@@ -1,14 +1,26 @@
+/**
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.wso2.cdm.agent.proxy;
-import android.content.Context;
import android.util.Log;
-import org.apache.commons.codec.binary.Base64;
import org.apache.http.*;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
@@ -19,11 +31,13 @@ import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
+import org.json.JSONObject;
import org.wso2.cdm.agent.R;
import org.wso2.cdm.agent.utils.CommonUtilities;
@@ -31,6 +45,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.security.KeyStore;
import java.util.HashMap;
import java.util.Iterator;
@@ -40,7 +55,7 @@ import java.util.Map.Entry;
/**
* Handle network communication between SDK and authorization server
*/
-public class ServerUtilitiesTemp {
+public class ServerApiAccess {
private final static String TAG = "ServerUtilities";
private static boolean isSSLEnable = false;
private static InputStream inputStream;
@@ -84,91 +99,93 @@ public class ServerUtilitiesTemp {
public static Map postData(APIUtilities apiUtilities, Map headers) {
String httpMethod = apiUtilities.getHttpMethod();
String url = apiUtilities.getEndPoint();
- Map params = apiUtilities.getRequestParams();
-
- Map response_params = new HashMap();
+ JSONObject params = apiUtilities.getRequestParams();
+ Map responseParams = new HashMap();
HttpClient httpclient = getCertifiedHttpClient();
- String payload = buildPayload(params);
+
if(httpMethod.equals("POST")){
HttpPost httpPost = new HttpPost(url);
+ if(params!=null){
+ try {
+ httpPost.setEntity(new StringEntity(params.toString()));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ }else{
+ httpPost.setEntity(null);
+ }
Log.e("url",""+url);
HttpPost httpPostWithHeaders = (HttpPost)buildHeaders(httpPost,headers,httpMethod);
- byte[] postData = payload.getBytes();
try {
- httpPostWithHeaders.setEntity(new ByteArrayEntity(postData));
HttpResponse response = httpclient.execute(httpPostWithHeaders);
String status = String.valueOf(response.getStatusLine().getStatusCode());
Log.d(TAG,status);
- response_params.put("response", getResponseBody(response));
- response_params.put("status", status);
- return response_params;
+ responseParams.put("response", getResponseBody(response));
+ responseParams.put("status", status);
+ return responseParams;
} catch (ClientProtocolException e) {
Log.d(TAG, "ClientProtocolException :"+e.toString());
return null;
} catch (IOException e) {
Log.d(TAG, e.toString());
- response_params.put("response", "Internal Server Error");
- response_params.put("status", "500");
- return response_params;
+ responseParams.put("response", "Internal Server Error");
+ responseParams.put("status", "500");
+ return responseParams;
}
- }else if(httpMethod.equals("PUT")){
- HttpPut httpPut = new HttpPut(url);
- HttpPut httpPutWithHeaders = (HttpPut)buildHeaders(httpPut,headers,httpMethod);
- byte[] putData = payload.getBytes();
- try {
- httpPutWithHeaders.setEntity(new ByteArrayEntity(putData));
- HttpResponse response = httpclient.execute(httpPutWithHeaders);
- response_params.put("response", getResponseBody(response));
- response_params.put("status", String.valueOf(response.getStatusLine().getStatusCode()));
- return response_params;
- } catch (ClientProtocolException e) {
- Log.d(TAG, "ClientProtocolException :"+e.toString());
- return null;
- } catch (IOException e) {
- Log.d(TAG, e.toString());
- response_params.put("response", "Internal Server Error");
- response_params.put("status", "500");
- return response_params;
- }
- }else if(httpMethod.equals("GET")){
- if(payload!=null){
- url = url+"?"+payload;
- }
+ }
+ else if(httpMethod.equals("GET")){
+// if(payload!=null){
+// url = url+"?"+payload;
+// }
HttpGet httpGet = new HttpGet(url);
HttpGet httpGetWithHeaders = (HttpGet) buildHeaders(httpGet,headers,httpMethod);
- Log.d(TAG,httpGetWithHeaders.toString());
+ Log.d(TAG,httpGetWithHeaders.toString()+" GET");
try {
HttpResponse response = httpclient.execute(httpGetWithHeaders);
- response_params.put("response", getResponseBody(response));
- response_params.put("status", String.valueOf(response.getStatusLine().getStatusCode()));
- return response_params;
+ responseParams.put("response", getResponseBody(response));
+ responseParams.put("status", String.valueOf(response.getStatusLine().getStatusCode()));
+ return responseParams;
} catch (ClientProtocolException e) {
Log.d(TAG, "ClientProtocolException :"+e.toString());
return null;
} catch (IOException e) {
Log.d(TAG, e.toString());
- response_params.put("response", "Internal Server Error");
- response_params.put("status", "500");
- return response_params;
+ responseParams.put("response", "Internal Server Error");
+ responseParams.put("status", "500");
+ return responseParams;
}
- }else if(httpMethod.equals("Delete")){
- if(payload!=null){
- url = url+"?"+payload;
- }
- HttpDelete httpDelete = new HttpDelete(url);
- HttpDelete httpDeleteWithHeaders = (HttpDelete) buildHeaders(httpDelete,headers,httpMethod);
- Log.d(TAG,httpDeleteWithHeaders.toString());
+ }
+ return null;
+ }
+
+ public static Map postDataAPI(APIUtilities apiUtilities, Map headers) {
+ String httpMethod = apiUtilities.getHttpMethod();
+ String url = apiUtilities.getEndPoint();
+ Map params = apiUtilities.getRequestParamsMap();
+
+ Map response_params = new HashMap();
+ HttpClient httpclient = getCertifiedHttpClient();
+ String payload = buildPayload(params);
+
+ if(httpMethod.equals("POST")){
+ HttpPost httpPost = new HttpPost(url);
+ Log.e("url",""+url);
+ HttpPost httpPostWithHeaders = (HttpPost)buildHeaders(httpPost,headers,httpMethod);
+ byte[] postData = payload.getBytes();
try {
- HttpResponse response = httpclient.execute(httpDeleteWithHeaders);
+ httpPostWithHeaders.setEntity(new ByteArrayEntity(postData));
+ HttpResponse response = httpclient.execute(httpPostWithHeaders);
+ String status = String.valueOf(response.getStatusLine().getStatusCode());
+ Log.d(TAG,status);
response_params.put("response", getResponseBody(response));
- response_params.put("status", String.valueOf(response.getStatusLine().getStatusCode()));
+ response_params.put("status", status);
return response_params;
} catch (ClientProtocolException e) {
Log.d(TAG, "ClientProtocolException :"+e.toString());
return null;
} catch (IOException e) {
- Log.d(TAG, e.toString());
+ Log.d(TAG, e.toString());
response_params.put("response", "Internal Server Error");
response_params.put("status", "500");
return response_params;
@@ -215,7 +232,7 @@ public class ServerUtilitiesTemp {
HttpEntity entity = null;
try {
entity = response.getEntity();
- response_text = _getResponseBody(entity);
+ response_text = getResponseBodyContent(entity);
} catch (ParseException e) {
Log.d(TAG, e.toString());
} catch (IOException e) {
@@ -230,7 +247,7 @@ public class ServerUtilitiesTemp {
return response_text;
}
- public static String _getResponseBody(final HttpEntity entity) throws IOException, ParseException {
+ public static String getResponseBodyContent(final HttpEntity entity) throws IOException, ParseException {
if (entity == null) {
throw new IllegalArgumentException("HTTP entity may not be null");
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/AlarmReceiver.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/AlarmReceiver.java
index 51807f350..ab02601dc 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/AlarmReceiver.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/AlarmReceiver.java
@@ -1,24 +1,23 @@
-/*
- ~ Copyright (c) 2014, WSO2 Inc. (http://wso2.com/) All Rights Reserved.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
-*/
+/**
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.wso2.cdm.agent.services;
-import java.util.Map;
-
import org.wso2.cdm.agent.R;
import org.wso2.cdm.agent.utils.CommonUtilities;
+import org.wso2.cdm.agent.utils.Constant;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -27,19 +26,16 @@ import android.util.Log;
public class AlarmReceiver extends BroadcastReceiver {
- private static final String DEBUG_TAG = "AlarmReceiver";
- Map server_res = null;
- Context context;
- ProcessMessage processMsg = null;
+ private static final String DEBUG_TAG = "AlarmReceiver";
+
@Override
public void onReceive(Context context, Intent intent) {
Log.d(DEBUG_TAG, "Recurring alarm; requesting download service.");
- this.context = context;
String mode=CommonUtilities.getPref(context, context.getResources().getString(R.string.shared_pref_message_mode));
- if(mode.trim().toUpperCase().equals("LOCAL")){
- ProcessMessage msg=new ProcessMessage(context);
- msg.getOperations(null);
- }
+ //if(mode.trim().toUpperCase().equals(Constant.LOCAL)){
+ MessageProcessor messageProcessor=new MessageProcessor(context);
+ messageProcessor.getMessages();
+ //}
}
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/LocalNotification.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/LocalNotification.java
index 177cde225..8f86e54a5 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/LocalNotification.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/LocalNotification.java
@@ -26,20 +26,22 @@ import android.os.SystemClock;
* polls to server based on a predefined to retrieve pending data.
*/
public class LocalNotification {
+ public static boolean localNoticicationInvoked=false;
+
public static void startPolling(Context context) {
int interval=10000;
-// int interval=Preference.getInt(context, context.getResources().getString(R.string.shared_pref_interval));
- //TODO:remove hard coded value
long firstTime = SystemClock.elapsedRealtime();
firstTime += 1000;
-
- Intent downloader = new Intent(context, AlarmReceiver.class);
- PendingIntent recurringDownload = PendingIntent.getBroadcast(context,
- 0, downloader, PendingIntent.FLAG_CANCEL_CURRENT);
- AlarmManager alarms = (AlarmManager) context
- .getSystemService(Context.ALARM_SERVICE);
- alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime,
- interval, recurringDownload);
+ if(localNoticicationInvoked==false){
+ localNoticicationInvoked=true;
+ Intent downloader = new Intent(context, AlarmReceiver.class);
+ PendingIntent recurringDownload = PendingIntent.getBroadcast(context,
+ 0, downloader, PendingIntent.FLAG_CANCEL_CURRENT);
+ AlarmManager alarms = (AlarmManager) context
+ .getSystemService(Context.ALARM_SERVICE);
+ alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime,
+ interval, recurringDownload);
+ }
}
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/MessageProcessor.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/MessageProcessor.java
new file mode 100644
index 000000000..506f9650a
--- /dev/null
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/MessageProcessor.java
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.cdm.agent.services;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Map;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.wso2.cdm.agent.R;
+import org.wso2.cdm.agent.RegistrationActivity;
+import org.wso2.cdm.agent.api.DeviceInfo;
+import org.wso2.cdm.agent.proxy.APIResultCallBack;
+import org.wso2.cdm.agent.utils.CommonUtilities;
+import org.wso2.cdm.agent.utils.Constant;
+import org.wso2.cdm.agent.utils.Preference;
+import org.wso2.cdm.agent.utils.ServerUtils;
+
+import android.content.Context;
+import android.util.Log;
+
+/**
+ * Used to coordinate the retrieval and processing of messages from the server.
+ */
+public class MessageProcessor implements APIResultCallBack {
+
+ private String TAG = MessageProcessor.class.getSimpleName();
+ private Context context;
+ String deviceId;
+
+ /**
+ * Local notification message handler.
+ *
+ * @param context
+ * Context of the application.
+ */
+ public MessageProcessor(Context context) {
+ this.context = context;
+
+ deviceId=Preference.get(context, "deviceId");
+ if(deviceId ==null){
+ DeviceInfo deviceInfo = new DeviceInfo(context);
+ deviceId=deviceInfo.getMACAddress();
+ Preference.put(context, "deviceId", deviceId);
+ }
+ }
+
+ /**
+ * @param response
+ * Response received from the server that needs to be processed
+ * and applied to the device
+ */
+ public void performOperation(String response) {
+ try {
+ JSONArray operations = new JSONArray(response);
+ for (int x = 0; x < operations.length(); x++) {
+ String featureCode = operations.getJSONObject(x).getString(Constant.CODE);
+ String properties = operations.getJSONObject(x).getString(Constant.PROPERTIES);
+ Operation operation = new Operation(context);
+ operation.doTask(featureCode, properties, 0);
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Call the message retrieval end point of the server to get messages
+ * pending.
+ */
+ public void getMessages() {
+ String ipSaved =
+ Preference.get(context.getApplicationContext(),
+ context.getResources().getString(R.string.shared_pref_ip));
+ CommonUtilities.setServerURL(ipSaved);
+ String deviceIdentifier = "";
+ try {
+ deviceIdentifier = URLEncoder.encode(deviceId, "utf-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ ServerUtils.callSecuredAPI(context, CommonUtilities.API_SERVER_URL +
+ CommonUtilities.NOTIFICATION_ENDPOINT+File.separator+deviceIdentifier,
+ CommonUtilities.GET_METHOD, new JSONObject(), MessageProcessor.this,
+ CommonUtilities.NOTIFICATION_REQUEST_CODE);
+ }
+
+ @Override
+ public void onReceiveAPIResult(Map result, int requestCode) {
+ String responseStatus;
+ String response;
+ if (requestCode == CommonUtilities.NOTIFICATION_REQUEST_CODE) {
+ if (result != null) {
+ responseStatus = result.get(CommonUtilities.STATUS_KEY);
+ if (responseStatus != null &&
+ responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
+ response = result.get(Constant.RESPONSE);
+ if (response != null && !response.equals("")) {
+ if (CommonUtilities.DEBUG_MODE_ENABLED) {
+ Log.e(TAG, "onReceiveAPIResult- " + response);
+ }
+ performOperation(response);
+ }
+ }
+
+ }
+ }
+
+ }
+}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/Operation.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/Operation.java
index 680d32835..f7d7fbc36 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/Operation.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/Operation.java
@@ -402,11 +402,11 @@ public class Operation {
@SuppressWarnings("static-access")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
- public JSONArray doTask(String code_in, String data_in, int req_mode) {
+ public JSONArray doTask(String codeIn, String dataIn, int req_mode) {
- Log.e("doTask","code:"+code_in+"\n"+data_in);
- String data_input=data_in;
- String code_input = code_in;
+ Log.e("doTask","code:"+codeIn+"\n"+dataIn);
+ String dataInput=dataIn;
+ String codeInput = codeIn;
String notification = "";
String ssid = "";
String password = "";
@@ -421,7 +421,7 @@ public class Operation {
JSONArray resultArr= new JSONArray();
JSONObject result= new JSONObject();
- if (code_input.equals(CommonUtilities.OPERATION_DEVICE_INFO)) {
+ if (codeInput.equals(CommonUtilities.OPERATION_DEVICE_INFO)) {
PhoneState phoneState = new PhoneState(context);
JSONObject obj = new JSONObject();
@@ -459,7 +459,7 @@ public class Operation {
obj.put("operator", deviceInfo.getNetworkOperatorName());
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
params.put("data", obj.toString());
@@ -467,7 +467,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", obj);
Map as = new HashMap();
@@ -500,7 +500,7 @@ public class Operation {
e1.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_DEVICE_LOCATION)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_DEVICE_LOCATION)) {
LocationServices ls = new LocationServices(context);
Log.v("Latitude", ls.getLatitude());
@@ -520,10 +520,10 @@ public class Operation {
params.put("data", obj.toString());
- //for local notification\
+ //for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", obj);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
@@ -540,7 +540,7 @@ public class Operation {
e1.printStackTrace();
}
- } else if (code_input
+ } else if (codeInput
.equals(CommonUtilities.OPERATION_GET_APPLICATION_LIST)) {
ArrayList apps = appList.getInstalledApps(false); /*
* false =
@@ -572,7 +572,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", jsonArray);
@@ -588,7 +588,7 @@ public class Operation {
params.put("status", "200");
//params.put("data", Uri.encode(jsonArray.toString()));
Log.e("PASSING MSG ID : ",token);
- Log.e("PASSING CODE : ",code_input);
+ Log.e("PASSING CODE : ",codeInput);
@@ -604,19 +604,19 @@ public class Operation {
e1.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_LOCK_DEVICE)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_LOCK_DEVICE)) {
Log.d(TAG, "Locking device now");
try {
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (req_mode == REQUEST_MODE_NORMAL) {
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
@@ -639,7 +639,7 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_WIPE_DATA)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_WIPE_DATA)) {
Log.d(TAG,
@@ -650,10 +650,10 @@ public class Operation {
String pinSaved = mainPref.getString("pin", "");
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
pin = (String) jobj.get("pin");
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
@@ -670,7 +670,7 @@ public class Operation {
}
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(params, context);
@@ -703,20 +703,20 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_CLEAR_PASSWORD)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_CLEAR_PASSWORD)) {
ComponentName demoDeviceAdmin = new ComponentName(context,
WSO2DeviceAdminReceiver.class);
try {
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (req_mode == REQUEST_MODE_NORMAL) {
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
@@ -745,11 +745,11 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_NOTIFICATION)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_NOTIFICATION)) {
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
if (jobj.get("notification").toString() != null
|| jobj.get("notification").toString().equals("")) {
notification = jobj.get("notification").toString();
@@ -762,14 +762,14 @@ public class Operation {
Log.v("Notification", notification);
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(params, context);
@@ -787,12 +787,12 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_WIFI)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_WIFI)) {
boolean wifistatus = false;
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
if (!jobj.isNull("ssid")) {
ssid = (String) jobj.get("ssid");
}
@@ -804,7 +804,7 @@ public class Operation {
e.printStackTrace();
}
Map inparams = new HashMap();
- inparams.put("code", code_input);
+ inparams.put("code", codeInput);
inparams.put("msgID", token);
WiFiConfig config = new WiFiConfig(context);
@@ -812,7 +812,7 @@ public class Operation {
try {
//for local notification
resultArr.put(result);
- result.put("code", code_input);
+ result.put("code", codeInput);
wifistatus = config.saveWEPConfig(ssid, password);
if (wifistatus) {
@@ -841,12 +841,12 @@ public class Operation {
}
}
- } else if (code_input.equals(CommonUtilities.OPERATION_DISABLE_CAMERA)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_DISABLE_CAMERA)) {
boolean camFunc = false;
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
if (!jobj.isNull("function")
&& jobj.get("function").toString()
.equalsIgnoreCase("enable")) {
@@ -863,14 +863,14 @@ public class Operation {
ComponentName cameraAdmin = new ComponentName(context,
WSO2DeviceAdminReceiver.class);
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
String cammode = "Disabled";
@@ -904,29 +904,29 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input
+ } else if (codeInput
.equals(CommonUtilities.OPERATION_INSTALL_APPLICATION)
- || code_input
+ || codeInput
.equals(CommonUtilities.OPERATION_INSTALL_APPLICATION_BUNDLE)) {
try {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
- if (code_input
+ if (codeInput
.equals(CommonUtilities.OPERATION_INSTALL_APPLICATION)) {
- JSONObject jobj = new JSONObject(data_input);
- installApplication(jobj, code_input);
- } else if (code_input
+ JSONObject jobj = new JSONObject(dataInput);
+ installApplication(jobj, codeInput);
+ } else if (codeInput
.equals(CommonUtilities.OPERATION_INSTALL_APPLICATION_BUNDLE)) {
JSONArray jArray = null;
- jArray = new JSONArray(data_input);
+ jArray = new JSONArray(dataInput);
for (int i = 0; i < jArray.length(); i++) {
JSONObject appObj = (JSONObject) jArray
.getJSONObject(i);
- installApplication(appObj, code_input);
+ installApplication(appObj, codeInput);
}
}
@@ -935,18 +935,18 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input
+ } else if (codeInput
.equals(CommonUtilities.OPERATION_UNINSTALL_APPLICATION)) {
String packageName = "";
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
packageName = (String) jobj.get("identity");
Log.v("Package Name : ", packageName);
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
@@ -954,7 +954,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(params, context);
@@ -968,13 +968,13 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_ENCRYPT_STORAGE)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_ENCRYPT_STORAGE)) {
boolean encryptFunc = true;
String pass = "";
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
if (!jobj.isNull("function")
&& jobj.get("function").toString()
.equalsIgnoreCase("encrypt")) {
@@ -991,7 +991,7 @@ public class Operation {
ComponentName admin = new ComponentName(context,
WSO2DeviceAdminReceiver.class);
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
if (encryptFunc
@@ -1020,7 +1020,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (devicePolicyManager.getStorageEncryptionStatus() != devicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED) {
params.put("status", "200");
result.put("status", "true");
@@ -1045,19 +1045,19 @@ public class Operation {
// TODO Auto-generated catch block
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_MUTE)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_MUTE)) {
Log.d(TAG, "Muting Device");
try {
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (req_mode == REQUEST_MODE_NORMAL) {
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
@@ -1079,7 +1079,7 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_TRACK_CALLS)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_TRACK_CALLS)) {
try {
Map params = new HashMap();
@@ -1091,7 +1091,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", new JSONObject(conversations.getCallDetails().toString()));
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
@@ -1104,7 +1104,7 @@ public class Operation {
// TODO Auto-generated catch block
e1.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_TRACK_SMS)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_TRACK_SMS)) {
int MESSAGE_TYPE_INBOX = 1;
int MESSAGE_TYPE_SENT = 2;
JSONObject smsObj = new JSONObject();
@@ -1123,7 +1123,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", smsObj);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
@@ -1136,7 +1136,7 @@ public class Operation {
// TODO Auto-generated catch block
e1.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_DATA_USAGE)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_DATA_USAGE)) {
JSONObject dataObj = new JSONObject();
try {
@@ -1152,7 +1152,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", new JSONObject(deviceState.takeDataUsageSnapShot()
.toString()));
@@ -1166,7 +1166,7 @@ public class Operation {
// TODO Auto-generated catch block
e1.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_STATUS)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_STATUS)) {
boolean encryptStatus = false;
boolean passCodeStatus = false;
try {
@@ -1195,7 +1195,7 @@ public class Operation {
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
params.put("data", dataObj.toString());
@@ -1203,7 +1203,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", dataObj);
if (req_mode == REQUEST_MODE_NORMAL) {
@@ -1224,26 +1224,26 @@ public class Operation {
e1.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_WEBCLIP)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_WEBCLIP)) {
String appUrl = "";
String title = "";
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
Log.v("WEBCLIP DATA : ", data.toString());
appUrl = (String) jobj.get("identity");
title = (String) jobj.get("title");
Log.v("Web App URL : ", appUrl);
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(params, context);
@@ -1256,7 +1256,7 @@ public class Operation {
// TODO Auto-generated catch block
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_PASSWORD_POLICY)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_PASSWORD_POLICY)) {
ComponentName demoDeviceAdmin = new ComponentName(context,
WSO2DeviceAdminReceiver.class);
@@ -1273,8 +1273,8 @@ public class Operation {
try {
- result.put("code", code_input);
- JSONObject jobj = new JSONObject(data_input);
+ result.put("code", codeInput);
+ JSONObject jobj = new JSONObject(dataInput);
if (!jobj.isNull("maxFailedAttempts")
&& jobj.get("maxFailedAttempts") != null) {
attempts = Integer.parseInt((String) jobj
@@ -1356,7 +1356,7 @@ public class Operation {
String policy = mainPref.getString("policy", "");
- inparams.put("code", code_input);
+ inparams.put("code", codeInput);
inparams.put("msgID", token);
inparams.put("status", "200");
result.put("status", "true");
@@ -1393,7 +1393,7 @@ public class Operation {
}
}
- } else if (code_input.equals(CommonUtilities.OPERATION_EMAIL_CONFIGURATION)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_EMAIL_CONFIGURATION)) {
String emailname="", emailtype="", ic_username="", ic_password="", ic_hostname="";
long timout;
Map inparams = new HashMap();
@@ -1404,8 +1404,8 @@ public class Operation {
JSONParser jp = new JSONParser();
try {
- result.put("code", code_input);
- JSONObject jobj = new JSONObject(data_input);
+ result.put("code", codeInput);
+ JSONObject jobj = new JSONObject(dataInput);
if (!jobj.isNull("type")
&& jobj.get("type") != null) {
emailtype = (String) jobj
@@ -1438,7 +1438,7 @@ public class Operation {
ic_hostname = "";
}
- inparams.put("code", code_input);
+ inparams.put("code", codeInput);
inparams.put("msgID", token);
inparams.put("status", "200");
result.put("status", "true");
@@ -1475,25 +1475,25 @@ public class Operation {
}
}
- }else if (code_input
+ }else if (codeInput
.equals(CommonUtilities.OPERATION_INSTALL_GOOGLE_APP)) {
String packageName = "";
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
packageName = (String) jobj.get("package");
Log.v("Package Name : ", packageName);
Map params = new HashMap();
- params.put("code", code_input);
+ params.put("code", codeInput);
params.put("msgID", token);
params.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(params, context);
} else if (mode == CommonUtilities.MESSAGE_MODE_SMS) {
@@ -1509,7 +1509,7 @@ public class Operation {
e.printStackTrace();
}
- } else if (code_input
+ } else if (codeInput
.equals(CommonUtilities.OPERATION_CHANGE_LOCK_CODE)) {
ComponentName demoDeviceAdmin = new ComponentName(context,
WSO2DeviceAdminReceiver.class);
@@ -1519,19 +1519,19 @@ public class Operation {
JSONParser jp = new JSONParser();
try {
- JSONObject jobj = new JSONObject(data_input);
+ JSONObject jobj = new JSONObject(dataInput);
if (!jobj.isNull("password")) {
pass = (String) jobj.get("password");
}
- inparams.put("code", code_input);
+ inparams.put("code", codeInput);
inparams.put("msgID", token);
inparams.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(inparams, context);
@@ -1570,7 +1570,7 @@ public class Operation {
}
}
- } else if (code_input.equals(CommonUtilities.OPERATION_POLICY_BUNDLE)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_POLICY_BUNDLE)) {
Map params = new HashMap();
try {
params.put("code", code);
@@ -1581,7 +1581,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", new JSONObject(bundle_params.toString()));
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
@@ -1593,7 +1593,7 @@ public class Operation {
} catch (Exception ex) {
ex.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_POLICY_MONITOR)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_POLICY_MONITOR)) {
JSONArray sendjArray;
JSONObject jobj=null;
try {
@@ -1610,7 +1610,7 @@ public class Operation {
}
Log.e("PASSING MSG ID : ",policy_token);
- Log.e("PASSING CODE : ",code_input);
+ Log.e("PASSING CODE : ",codeInput);
Log.e("PASSING TYPE : ",String.valueOf(type));
PolicyTester tester = new PolicyTester(context, sendjArray,
type, policy_token);
@@ -1620,19 +1620,19 @@ public class Operation {
// TODO Auto-generated catch block
e.printStackTrace();
}
- } else if (code_input.equals(CommonUtilities.OPERATION_POLICY_REVOKE)) {
+ } else if (codeInput.equals(CommonUtilities.OPERATION_POLICY_REVOKE)) {
try {
Map inparams = new HashMap();
- inparams.put("code", code_input);
+ inparams.put("code", codeInput);
inparams.put("msgID", token);
inparams.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(inparams, context);
} else if (mode == CommonUtilities.MESSAGE_MODE_SMS) {
@@ -1644,19 +1644,19 @@ public class Operation {
// TODO Auto-generated catch block
e.printStackTrace();
}
- }else if (code_input.equals(CommonUtilities.OPERATION_ENTERPRISE_WIPE_DATA)) {
+ }else if (codeInput.equals(CommonUtilities.OPERATION_ENTERPRISE_WIPE_DATA)) {
try {
Map inparams = new HashMap();
- inparams.put("code", code_input);
+ inparams.put("code", codeInput);
inparams.put("msgID", token);
inparams.put("status", "200");
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
//ServerUtilities.pushData(inparams, context);
} else if (mode == CommonUtilities.MESSAGE_MODE_SMS) {
@@ -1674,7 +1674,7 @@ public class Operation {
e.printStackTrace();
}
}
- else if (code_input
+ else if (codeInput
.equals(CommonUtilities.OPERATION_BLACKLIST_APPS)) {
ArrayList apps = appList.getInstalledApps(false); /*
* false =
@@ -1692,7 +1692,7 @@ public class Operation {
try{
- JSONObject appsObj = new JSONObject(data_input);
+ JSONObject appsObj = new JSONObject(dataInput);
if (!appsObj.isNull("data")) {
appsObj = (JSONObject) appsObj.get("data");
}
@@ -1737,7 +1737,7 @@ public class Operation {
//for local notification
resultArr.put(result);
result.put("status", "true");
- result.put("code", code_input);
+ result.put("code", codeInput);
result.put("data", jsonArray);
if (mode == CommonUtilities.MESSAGE_MODE_GCM) {
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/ProcessMessage.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/ProcessMessage.java
deleted file mode 100644
index 3f5659edd..000000000
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/services/ProcessMessage.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- ~ Copyright (c) 2014, WSO2 Inc. (http://wso2.com/) All Rights Reserved.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
-*/
-package org.wso2.cdm.agent.services;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.wso2.cdm.agent.R;
-import org.wso2.cdm.agent.parser.PayloadParser;
-import org.wso2.cdm.agent.proxy.APIResultCallBack;
-import org.wso2.cdm.agent.utils.CommonDialogUtils;
-import org.wso2.cdm.agent.utils.CommonUtilities;
-import org.wso2.cdm.agent.utils.LoggerCustom;
-import org.wso2.cdm.agent.utils.ServerUtils;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.os.AsyncTask;
-import android.util.Log;
-
-public class ProcessMessage implements APIResultCallBack{
-
- private String TAG = ProcessMessage.class.getSimpleName();
-
-
- Operation operation;
- Map params;
- AsyncTask sendReply;
- Map responsePayload;
- Context context;
- String replyPayload;
- public static boolean stillProcessing=false;
- AlertDialog.Builder alertDialog;
-
- public ProcessMessage(Context context, int mode, String message, String recepient) {
- // TODO Auto-generated constructor stub
- JSONParser jp = new JSONParser();
- params = new HashMap();
- try {
-
- JSONObject jobj = new JSONObject(message);
- params.put("code", (String)jobj.get("message"));
- if(jobj.has("data")){
- params.put("data", ((JSONObject)jobj.get("data")).toString());
- }
-
- operation = new Operation(context, mode, params, recepient);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
-
-
- // local notification message handler
- public ProcessMessage(Context context) {
- this.context = context;
- }
-
- public void getOperations(String replyData) {
- String isRegistered=CommonUtilities.getPref(context, context.getResources().getString(R.string.shared_pref_registered));
- if(isRegistered.equals("1")){
- if(stillProcessing==false){
- String isActive = CommonUtilities.getPref(context, context.getResources().getString(R.string.shared_pref_device_active));
- if (isActive.equals("1")) {
- try {
- SharedPreferences mainPref =
- context.getSharedPreferences(context.getResources()
- .getString(R.string.shared_pref_package),
- Context.MODE_PRIVATE);
- String regId =
- mainPref.getString(context.getResources()
- .getString(R.string.shared_pref_regId), "");
- Map requestParams = new HashMap();
- if (replyData != null) {
- requestParams.put("data", replyPayload);
- }
- requestParams.put("regId", regId);
-
- ServerUtils.callSecuredAPI(context,
- CommonUtilities.NOTIFICATION_ENDPOINT,
- CommonUtilities.POST_METHOD, requestParams,
- ProcessMessage.this,
- CommonUtilities.NOTIFICATION_REQUEST_CODE);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- }
- }
-
- }
-
- @Override
- public void onReceiveAPIResult(Map result, int requestCode) {
- String responseStatus = "";
- String response = "";
- if (requestCode == CommonUtilities.NOTIFICATION_REQUEST_CODE) {
- if (result != null) {
- responseStatus = result.get(CommonUtilities.STATUS_KEY);
- if (responseStatus != null) {
- if (responseStatus.equals(CommonUtilities.REQUEST_SUCCESSFUL)) {
- response = result.get("response");
- //processMsg = new ProcessMessage(context, CommonUtilities.MESSAGE_MODE_LOCAL, response);
- if(response!=null && !response.equals("") && !response.equals("null")){
- if(CommonUtilities.DEBUG_MODE_ENABLED){
- Log.e(TAG, "onReceiveAPIResult- "+response);
- }
- messageExecute(response);
- }
- }
- }
-
- }
- }
-
- }
-
-
-
-
-
-
-
- private void messageExecute(String msg) {
- stillProcessing=true;
- JSONArray repArray =new JSONArray();
- JSONObject jsReply=null;
- String msgId="";
-
-
- JSONArray dataReply=null;
- try {
- JSONArray jArr=new JSONArray(msg.trim());
- for(int i=0;i requestParams = new HashMap();
- requestParams.put("regid", regId);
+ JSONObject requestParams = new JSONObject();
+ try {
+ requestParams.put("regid", regId);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
ServerUtils.clearAppData(app_context);
ServerUtils.callSecuredAPI(app_context,
CommonUtilities.UNREGISTER_ENDPOINT,
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonDialogUtils.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonDialogUtils.java
index e6ec35107..91d369cda 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonDialogUtils.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonDialogUtils.java
@@ -22,30 +22,37 @@ import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+
/**
*
* The CommonDialogUtils class contains the all dialog templates.
- *
+ *
*/
public abstract class CommonDialogUtils {
-
+
/**
* Return an Alert Dialog with one button.
*
- * @param context the Activity which needs this alert dialog
- * @param message the message in the alert
- * @param positiveBtnLabel the label of the positive button
- * @param positiveClickListener the onClickListener of the positive button
+ * @param context
+ * the Activity which needs this alert dialog
+ * @param message
+ * the message in the alert
+ * @param positiveBtnLabel
+ * the label of the positive button
+ * @param positiveClickListener
+ * the onClickListener of the positive button
*
* @return the generated Alert Dialog
*/
public static AlertDialog.Builder getAlertDialogWithOneButton(Context context,
- String message, String positiveBtnLabel,
- DialogInterface.OnClickListener positiveClickListener) {
-
+ String message,
+ String positiveBtnLabel,
+ DialogInterface.OnClickListener positiveClickListener) {
+
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setMessage(message)
- .setPositiveButton(positiveBtnLabel, positiveClickListener);
+ builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener);
return builder;
}
@@ -53,99 +60,119 @@ public abstract class CommonDialogUtils {
/**
* Return an Alert Dialog with two buttons.
*
- * @param context
- * @param context the Activity which needs this alert dialog
- * @param message the message in the alert
- * @param positiveBtnLabel the label of the positive button
- * @param negetiveBtnLabel the label of the negative button
- * @param positiveClickListener the onClickListener of the positive button
- * @param negativeClickListener the onClickListener of the negative button
+ * @param context
+ * @param context
+ * the Activity which needs this alert dialog
+ * @param message
+ * the message in the alert
+ * @param positiveBtnLabel
+ * the label of the positive button
+ * @param negetiveBtnLabel
+ * the label of the negative button
+ * @param positiveClickListener
+ * the onClickListener of the positive button
+ * @param negativeClickListener
+ * the onClickListener of the negative button
*
* @return the generated Alert Dialog.
*/
public static AlertDialog.Builder getAlertDialogWithTwoButton(Context context,
- String message, String positiveBtnLabel, String negetiveBtnLabel,
- DialogInterface.OnClickListener positiveClickListener,
- DialogInterface.OnClickListener negativeClickListener) {
-
+ String message,
+ String positiveBtnLabel,
+ String negetiveBtnLabel,
+ DialogInterface.OnClickListener positiveClickListener,
+ DialogInterface.OnClickListener negativeClickListener) {
+
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setMessage(message)
- .setPositiveButton(positiveBtnLabel, positiveClickListener)
- .setNegativeButton(negetiveBtnLabel, negativeClickListener);
+ builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener)
+ .setNegativeButton(negetiveBtnLabel, negativeClickListener);
return builder;
}
-
+
/**
* Shows the Network unavailable message.
*
- * @param context the Activity where checking the network availability.
+ * @param context
+ * the Activity where checking the network availability.
*/
public static void showNetworkUnavailableMessage(Context context) {
- AlertDialog.Builder builder = CommonDialogUtils
- .getAlertDialogWithOneButton(
- context,
- context.getResources().getString(R.string.error_network_unavailable),
- context.getResources().getString(R.string.button_ok), null);
+ AlertDialog.Builder builder =
+ CommonDialogUtils.getAlertDialogWithOneButton(context,
+ context.getResources()
+ .getString(R.string.error_network_unavailable),
+ context.getResources()
+ .getString(R.string.button_ok),
+ null);
builder.show();
}
-
+
public static AlertDialog.Builder getAlertDialogWithTwoButtonAndTitle(Context context,
- String title, String message,
- String positiveBtnLabel, String negetiveBtnLabel,
- DialogInterface.OnClickListener positiveClickListener,
- DialogInterface.OnClickListener negativeClickListener) {
-
+ String title,
+ String message,
+ String positiveBtnLabel,
+ String negetiveBtnLabel,
+ DialogInterface.OnClickListener positiveClickListener,
+ DialogInterface.OnClickListener negativeClickListener) {
+
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
- builder.setMessage(message)
- .setPositiveButton(positiveBtnLabel, positiveClickListener)
- .setNegativeButton(negetiveBtnLabel, negativeClickListener);
+ builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener)
+ .setNegativeButton(negetiveBtnLabel, negativeClickListener);
return builder;
}
-
+
/**
* Returns an Alert Dialog with one button and title.
*
- * @param context the activity which need this alert.
- * @param title the alert title
- * @param message the alert message
- * @param positiveBtnLabel the positive button label
- * @param positiveClickListener the positive button listener
+ * @param context
+ * the activity which need this alert.
+ * @param title
+ * the alert title
+ * @param message
+ * the alert message
+ * @param positiveBtnLabel
+ * the positive button label
+ * @param positiveClickListener
+ * the positive button listener
*
* @return an alert dialog
*/
public static AlertDialog.Builder getAlertDialogWithOneButtonAndTitle(Context context,
- String title, String message,
- String positiveBtnLabel, DialogInterface.OnClickListener positiveClickListener) {
-
+ String title,
+ String message,
+ String positiveBtnLabel,
+ DialogInterface.OnClickListener positiveClickListener) {
+
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
- builder.setMessage(message)
- .setPositiveButton(positiveBtnLabel, positiveClickListener);
+ builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener);
builder.show();
return builder;
}
-
+
/**
* Shows the ProgressDialog.
*
- * @param context the Activity which needs the ProgressDialog
- * @param title the title
- * @param message the message
- * @param cancelListener the OnCancelListener
+ * @param context
+ * the Activity which needs the ProgressDialog
+ * @param title
+ * the title
+ * @param message
+ * the message
+ * @param cancelListener
+ * the OnCancelListener
*/
- public static ProgressDialog showPrgressDialog (Context context, String title, String message, OnCancelListener cancelListener) {
- ProgressDialog progressDialog = ProgressDialog.show(context,
- title,
- message, true);
+ public static ProgressDialog showPrgressDialog(Context context, String title, String message,
+ OnCancelListener cancelListener) {
+ ProgressDialog progressDialog = ProgressDialog.show(context, title, message, true);
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(cancelListener);
-
+
return progressDialog;
}
-
+
/**
* Stops progressDialog.
*
@@ -156,4 +183,26 @@ public abstract class CommonDialogUtils {
}
}
+ public static AlertDialog.Builder getAlertDialogWithTwoButtonAndEditView(Context context,
+ String message,
+ String positiveBtnLabel,
+ String negetiveBtnLabel,
+ DialogInterface.OnClickListener positiveClickListener,
+ DialogInterface.OnClickListener negativeClickListener,
+ EditText input) {
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener)
+ .setNegativeButton(negetiveBtnLabel, negativeClickListener);
+
+ LinearLayout.LayoutParams lp =
+ new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.MATCH_PARENT);
+ input.setLayoutParams(lp);
+ builder.setView(input);
+
+ return builder;
+ }
+
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonUtilities.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonUtilities.java
index 2ec7def0d..9b58f1528 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonUtilities.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/CommonUtilities.java
@@ -36,20 +36,22 @@ public class CommonUtilities {
public static String SERVER_PORT = "9763";
public static String SERVER_PROTOCOL = "http://";
public static String API_VERSION = "1.0.0";
+ public static String API_SERVER_PORT = "8280";
public static String SERVER_APP_ENDPOINT = "/cdm-android-api/";
public static String SERVER_AUTHENTICATION_ENDPOINT="register/authenticate/device";
- public static String LICENSE_ENDPOINT = "register/authenticate/device/license";
- public static String REGISTER_ENDPOINT = "enrollment/authenticate/device/enroll";
+ public static String LICENSE_ENDPOINT = "/license/"+API_VERSION;
+ public static String REGISTER_ENDPOINT = "/enroll/"+API_VERSION;
public static String OAUTH_ENDPOINT = "/oauth2/token";
public static String SENDER_ID_ENDPOINT = "devices/sender_id/";
public static String IS_REGISTERED_ENDPOINT = "devices/isregistered/";
public static String UNREGISTER_ENDPOINT = "devices/unregister/";
- public static String NOTIFICATION_ENDPOINT = "notifications/pendingOperations/";
+ public static String NOTIFICATION_ENDPOINT = "/operation/"+API_VERSION;
public static String SERVER_URL = SERVER_PROTOCOL + SERVER_IP + ":"
- + SERVER_PORT + SERVER_APP_ENDPOINT;
+ + SERVER_PORT ;
+ public static String API_SERVER_URL;
public static final String TRUSTSTORE_PASSWORD = "wso2carbon";
@@ -86,7 +88,7 @@ public class CommonUtilities {
SERVER_IP = serverIP;
SERVER_URL = SERVER_PROTOCOL + serverIP + ":" + SERVER_PORT
+SERVER_APP_ENDPOINT;
-
+ API_SERVER_URL=SERVER_PROTOCOL + SERVER_IP + ":" + API_SERVER_PORT ;
}
/**
@@ -140,7 +142,7 @@ public class CommonUtilities {
public static final String OPERATION_DEVICE_INFO = "500A";
public static final String OPERATION_DEVICE_LOCATION = "501A";
public static final String OPERATION_GET_APPLICATION_LIST = "502A";
- public static final String OPERATION_LOCK_DEVICE = "503A";
+ public static final String OPERATION_LOCK_DEVICE = "DEVICE_LOCK";
public static final String OPERATION_WIPE_DATA = "504A";//reset device
public static final String OPERATION_CLEAR_PASSWORD = "505A";
public static final String OPERATION_NOTIFICATION = "506A";
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/Constant.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/Constant.java
index 8e551e336..fd7dfcafb 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/Constant.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/Constant.java
@@ -23,5 +23,8 @@ public class Constant {
public static final String PASSWORD = "password";
public static final String STATUS = "status";
public static final String RESPONSE = "response";
+ public static final String PROPERTIES = "properties";
+ public static final String CODE = "code";
+ public static final String LOCAL = "LOCAL";
}
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/HTTPConnectorUtils.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/HTTPConnectorUtils.java
index 3f8d5afdc..046529144 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/HTTPConnectorUtils.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/HTTPConnectorUtils.java
@@ -44,7 +44,6 @@ import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.wso2.cdm.agent.R;
import android.content.Context;
-import android.content.SharedPreferences;
import android.net.ParseException;
import android.util.Log;
@@ -54,25 +53,6 @@ public class HTTPConnectorUtils {
private static final int MAX_ATTEMPTS = 2;
- // public static Map getClientKey(String username, String
- // password, Context context) {
- // Map params = new HashMap();
- // Map response = new HashMap();
- //
- // params.put("username", username);
- // params.put("password", password);
- //
- // try {
- // response =
- // postData("services/register/authenticate/device", params,
- // context);
- // } catch (Exception ex) {
- // ex.printStackTrace();
- // return response;
- // }
- // return response;
- // }
-
public static Map postData(Context context, String url,
Map params) {
Map response = null;
@@ -121,7 +101,6 @@ public class HTTPConnectorUtils {
}
String body = bodyBuilder.toString();
- Log.v(TAG, "Posting '" + body + "' to " + url);
byte[] postData = body.getBytes();
HttpPost httppost = new HttpPost(url);
diff --git a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/ServerUtils.java b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/ServerUtils.java
index 3019ff876..12a13787e 100644
--- a/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/ServerUtils.java
+++ b/product/modules/tools/mdm-android-agent-archetype/src/main/resources/archetype-resources/src/org/wso2/cdm/agent/utils/ServerUtils.java
@@ -1,34 +1,23 @@
+/**
+ * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.wso2.cdm.agent.utils;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.security.KeyStore;
-import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HTTP;
+import org.json.JSONObject;
import org.wso2.cdm.agent.R;
import org.wso2.cdm.agent.proxy.APIController;
import org.wso2.cdm.agent.proxy.APIResultCallBack;
@@ -40,16 +29,11 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
-import android.net.ParseException;
import android.util.Log;
public class ServerUtils {
public static String TAG = ServerUtils.class.getSimpleName();
-
- private static final int MAX_ATTEMPTS = 2;
- private static final int BACKOFF_MILLI_SECONDS = 2000;
- private static final Random random = new Random();
/**
* calls the secured API
@@ -69,18 +53,13 @@ public class ServerUtils {
* @param requestCode
* the request code
*/
- public static void callSecuredAPI(Context context, String endpoint,
- String methodType, Map requestParams,
+ public static void callSecuredAPI(Context context, String endpoint,
+ String methodType, JSONObject requestParams,
APIResultCallBack apiResultCallBack, int requestCode) {
- String serverIP = CommonUtilities.getPref(context, context
- .getResources().getString(R.string.shared_pref_ip));
- String serverURL = CommonUtilities.SERVER_PROTOCOL + serverIP + ":"
- + CommonUtilities.SERVER_PORT
- + CommonUtilities.SERVER_APP_ENDPOINT;
-
+
+ Log.e("",endpoint);
APIUtilities apiUtilities = new APIUtilities();
- apiUtilities.setEndPoint(serverURL + endpoint
- + CommonUtilities.API_VERSION);
+ apiUtilities.setEndPoint(endpoint);
apiUtilities.setHttpMethod(methodType);
if (requestParams != null) {
apiUtilities.setRequestParams(requestParams);