Exemplo n.º 1
0
 private void handleDeactivationIntent(Intent intent)
 {
     lock (this)
     {
         SapaApp sapaApp = SapaAppInfo.getApp(intent);
         this.mActionsList.Remove(sapaApp.InstanceId);
         foreach (KeyValuePair <string, SapaProcessor> entry in this.mProcessorList.SetOfKeyValuePairs())
         {
             Log.d(TAG, "kakakaka " + entry.Key + " -> " + entry.Value);
         }
         SapaProcessor processor = this.mProcessorList[sapaApp.InstanceId];
         Log.d(TAG, "kakakaka instanceId " + sapaApp.InstanceId + " processor " + processor);
         processor.deactivate();
         this.mSapaService.unregister(this.mProcessorList[sapaApp.InstanceId]);
         this.mProcessorList.Remove(sapaApp.InstanceId);
         try
         {
             this.mSapaAppService.removeFromActiveApps(sapaApp);
         }
         catch (SapaConnectionNotSetException e)
         {
             Log.e(TAG, "Instance could not be removed from active list because of connection exception.");
         }
         this.mAppInfoList.Remove(sapaApp.InstanceId);
     }
 }
Exemplo n.º 2
0
 internal ActionsPack(MainService outerInstance, SapaApp sapaApp)
 {
     this.outerInstance = outerInstance;
     this.mSapaApp      = sapaApp;
     this.mVolDown      = null;
     this.mVolUp        = null;
 }
Exemplo n.º 3
0
            public override void onAppDeactivated(SapaApp sapaApp)
            {
                Log.d(TAG, "onAppDeactivated: " + sapaApp.InstanceId + " was deactivated.");

                if (outerInstance.mCallerPackageNameList.Count > 0)
                {
                    ISet <KeyValuePair <string, string> >             entrySet = outerInstance.mCallerPackageNameList.SetOfKeyValuePairs();
                    ISet <KeyValuePair <string, string> > .Enumerator iterator = entrySet.GetEnumerator();
                    while (iterator.MoveNext())
                    {
                        KeyValuePair <string, string> entry = iterator.Current;

                        if (sapaApp.PackageName.contentEquals(entry.Value))
                        {
                            Log.d(TAG, "Caller is closed.");
                            // Close this instance. because the caller is closed by unknow reason. So,
                            // It will be not used anymore.
                            outerInstance.closeAnInstance(entry.Key);
                        }
                    }
                }

                if (outerInstance.mCallerPackageNameList.Count == 0)
                {
                    stopSelf();
                }
            }
Exemplo n.º 4
0
 internal ActionsPack(MainService outerInstance, SapaApp sapaApp)
 {
     this.outerInstance = outerInstance;
     this.mSapaApp      = sapaApp;
     this.mPlayAction   = null;
     this.mStopAction   = null;
     this.mIsPlaying    = false;
 }
Exemplo n.º 5
0
 public override void onAppDeactivated(SapaApp sapaApp)
 {
     Log.d(TAG, "onAppDeactivated: " + sapaApp.InstanceId + " was deactivated.");
     if (sapaApp.PackageName.contentEquals(outerInstance.mCallerPackageName))
     {
         Log.d(TAG, "Caller is closed.");
         stopSelf();
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// This method saves current configuration in AppInfo of this application
        ///
        /// </summary>
        private void setConfiguration(SapaApp sapaApp, int volume)
        {
            Bundle bundle = new Bundle();

            bundle.putInt("CONFIG", volume);
            SapaAppInfo info = this.mAppInfoList[sapaApp.InstanceId];

            Log.d(TAG, "kaka volume[" + volume + "] was set in " + sapaApp.InstanceId);
            info.Configuration = bundle;
        }
Exemplo n.º 7
0
        private int getCurrectVolume(SapaApp sapaApp)
        {
            Bundle bundle = this.mAppInfoList[sapaApp.InstanceId].Configuration;

            if (bundle != null)
            {
                return(bundle.getInt("CONFIG"));
            }
            return(-1);
        }
Exemplo n.º 8
0
        // void setVolume(SapaApp sapaApp, int volume) {
        // try {
        // boolean wasMaxVolume = isMaxVolume(sapaApp);
        // boolean wasMinVolume = isMinVolume(sapaApp);
        // setConfiguration(sapaApp, volume);
        // boolean isMaxVolume = isMaxVolume(sapaApp);
        // boolean isMinVolume = isMinVolume(sapaApp);
        //
        // if (wasMaxVolume && !isMaxVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_UP,
        // R.drawable.ctrl_btn_volume_up_default, true);
        // } else if (isMaxVolume && !wasMaxVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_UP,
        // R.drawable.ctrl_btn_volume_up_disabled, false);
        // }
        //
        // if (wasMinVolume && !isMinVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_DOWN,
        // R.drawable.ctrl_btn_volume_down_default, true);
        // } else if (isMinVolume && !wasMinVolume) {
        // modifyAction(sapaApp, MainActivity.VOLUME_DOWN,
        // R.drawable.ctrl_btn_volume_down_disabled, false);
        // }
        //
        // this.mSapaAppService.changeAppInfo(mAppInfoList.get(sapaApp.getInstanceId()));
        //
        // showVolume(volume);
        // } catch (SapaConnectionNotSetException e) {
        // Log.w(TAG,
        // "State of application could not be changed due to connection exception");
        // }
        //

        private bool isVisibieView(SapaApp sapaApp)
        {
            if (mActivity != null && mActivity.get() != null && mActivity.get().VisibleApp != null && mActivity.get().VisibleApp.App != null && mActivity.get().VisibleApp.App.InstanceId != null && sapaApp != null && mActivity.get().VisibleApp.App.InstanceId.Equals(sapaApp.InstanceId) == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 9
0
 public override Runnable getActionDefinition(SapaApp sapaApp, string actionId)
 {
     Log.d(TAG, "getActionDefinition: actionId=" + actionId);
     if (actionId.Equals(COMMAND_SHUSH))
     {
         return(() =>
         {
             MainService.this.shush();
         });
     }
     return(null);
 }
Exemplo n.º 10
0
 public override void onAppChanged(SapaApp sapaApp)
 {
     Log.d(TAG, "Changed app: " + sapaApp.InstanceId);
     try
     {
         mFcSapaModel.updateApp(mSapaAppService.getActiveApp(sapaApp), getAppType(sapaApp));
     }
     catch (SapaConnectionNotSetException)
     {
         Log.w(TAG, "Cannot update app: sapa connection not set");
     }
 }
Exemplo n.º 11
0
 private void modifyAction(SapaApp sapaApp, string actionKey, int iconResId, bool isEnabled)
 {
     if (this.mAppInfoList[sapaApp.InstanceId] != null && mSapaAppService != null)
     {
         // Obtaining current SapaActionInfo.
         SapaActionInfo action = this.mAppInfoList[sapaApp.InstanceId].getActionInfo(actionKey);
         if (action != null)
         {
             // Settling state.
             action.Enabled = isEnabled;
             // Settling icon of action by setting id of the resource.
             action.Icon = iconResId;
         }
     }
 }
Exemplo n.º 12
0
 public override Runnable getActionDefinition(SapaApp sapaApp, string actionId)
 {
     lock (this)
     {
         // Basing on actionId appropriate action definition is returned.
         Log.d(TAG, "instanceid " + sapaApp.InstanceId + " actionId " + actionId);
         if (actionId.Equals(MainActivity.VOLUME_DOWN))
         {
             return(this.mActionsList[sapaApp.InstanceId].VolumeDownAction);
         }
         else if (actionId.Equals(MainActivity.VOLUME_UP))
         {
             return(this.mActionsList[sapaApp.InstanceId].VolumeUpAction);
         }
         return(null);
     }
 }
Exemplo n.º 13
0
 public override Runnable getActionDefinition(SapaApp sapaApp, string actionId)
 {
     lock (this)
     {
         // Basing on actionId appropriate action definition is returned.
         Log.d(TAG, "instanceid " + sapaApp.InstanceId + " actionId " + actionId);
         if (actionId.Equals(MainActivity.ACTION_PLAY))
         {
             return(this.mActionsList[sapaApp.InstanceId].PlayAction);
         }
         else if (actionId.Equals(MainActivity.ACTION_STOP))
         {
             return(this.mActionsList[sapaApp.InstanceId].StopAction);
         }
         return(null);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// @brief Construct model item from SapaAppInfo structure
        /// </summary>
        /// <param name="info">  Data structure with information retrieved from SAPA </param>
        /// <param name="type">  Type of the item (main or ordinal) </param>
        internal FcModelItem(FcContext fcContext, SapaAppInfo info, int type)
        {
            SapaApp app = info.App;

            try
            {
                mIcon = info.getIcon(fcContext.Context);
            }
            catch (NameNotFoundException e)
            {
                LogUtils.throwable(TAG, "Drawable not set: name not found", e);
            }
            mInstanceId  = app.InstanceId;
            mPackageName = app.PackageName;
            mType        = type;

            prepareActions(fcContext, info);
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void showVolume(final int volume, com.samsung.android.sdk.professionalaudio.app.SapaApp sapaApp)
        private void showVolume(int volume, SapaApp sapaApp)
        {
            mHandler.post(() =>
            {
                // Toast.makeText(MainService.this, volume + " dB", Toast.LENGTH_SHORT).show();
                if (mActivity != null && mActivity.get() != null)
                {
                    try
                    {
                        mActivity.get().updateVolumeTextView(volume + " dB");
                    }
                    catch (System.NullReferenceException)
                    {
                        ;
                    }
                }
            });
        }
Exemplo n.º 16
0
        internal virtual void increaseVolume(SapaApp sapaApp)
        {
            lock (this)
            {
                if (isMinVolume(sapaApp))
                {
                    modifyAction(sapaApp, MainActivity.VOLUME_DOWN, R.drawable.ctrl_btn_volume_down_default, true);
                }
                int currentVolume = getCurrectVolume(sapaApp);
                currentVolume = Logic.increaseVolume(currentVolume);

                if (Logic.isMaxVolume(currentVolume))
                {
                    modifyAction(sapaApp, MainActivity.VOLUME_UP, R.drawable.ctrl_btn_volume_up_disabled, false);
                    if (isVisibieView(sapaApp) == true)
                    {
                        MainService.this.mActivity.get().onMaxVolume();
                        this.showVolume(currentVolume, sapaApp);
                    }
                }
                else
                {
                    if (isVisibieView(sapaApp) == true)
                    {
                        MainService.this.mActivity.get().onBetweenVolume();
                        this.showVolume(currentVolume, sapaApp);
                    }
                }
                try
                {
                    // Setting current configuration in AppInfo
                    setConfiguration(sapaApp, currentVolume);
                    // Notification that AppInfo has been changed is sent.
                    this.mSapaAppService.changeAppInfo(mAppInfoList[sapaApp.InstanceId]);
                }
                catch (SapaConnectionNotSetException)
                {
                    Log.w(TAG, "State of application could not be changed due to connection exception");
                }
                // Volume command is sent to native part.
                Logic.sendVolume(this.mProcessorList[sapaApp.InstanceId], currentVolume);
            }
        }
Exemplo n.º 17
0
        internal virtual void play(SapaApp sapaApp)
        {
            SapaAppInfo info = this.mAppInfoList[sapaApp.InstanceId];

            // Play action is being deactivated.
            modifyAction(info, MainActivity.ACTION_PLAY, R.drawable.ctrl_btn_play_disabled, false);
            // Stop action is being activated.
            modifyAction(info, MainActivity.ACTION_STOP, R.drawable.ctrl_btn_stop_default, true);
            try
            {
                // Notification that AppInfo has been changed is sent.
                this.mSapaAppService.changeAppInfo(info);
            }
            catch (SapaConnectionNotSetException)
            {
                Log.w(TAG, "State of application cound not be changed due to connection exception");
            }

            this.mIsPlaying = true;
            // Play command is sent to native part.
            Logic.startPlaying(this.mProcessorList[sapaApp.InstanceId]);
        }
Exemplo n.º 18
0
 private void handleDeactivationIntent(Intent intent)
 {
     lock (this)
     {
         SapaApp sapaApp = SapaAppInfo.getApp(intent);
         this.mActionsList.Remove(sapaApp.InstanceId);
         SapaProcessor processor = this.mProcessorList[sapaApp.InstanceId];
         if (processor != null)
         {
             processor.deactivate();
             this.mSapaService.unregister(processor);
         }
         this.mProcessorList.Remove(sapaApp.InstanceId);
         try
         {
             this.mSapaAppService.removeFromActiveApps(sapaApp);
         }
         catch (SapaConnectionNotSetException e)
         {
             Log.e(TAG, "Instance could not be removed from active list because of connection exception.");
         }
         this.mAppInfoList.Remove(sapaApp.InstanceId);
     }
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: DeviceActionsLayoutData(com.samsung.android.sdk.professionalaudio.app.SapaAppInfo info, android.content.Context context, boolean isMultiInstance) throws android.content.pm.PackageManager.NameNotFoundException
        internal DeviceActionsLayoutData(SapaAppInfo info, Context context, bool isMultiInstance)
        {
            mAppInfo                  = info;
            this.mInstanceIcon        = info.getIcon(context);
            this.mSapaApp             = info.App;
            this.mInstancePackageName = info.PackageName;
            this.mActionList          = info.Actions;
            if (this.mActionList == null)
            {
                this.mActionList = new SparseArray <SapaActionInfo>();
            }
            mActionMap = new Dictionary <string, SapaActionInfo>();
            loadActionMap();
            this.mIsMultiInstanceEnabled = info.MultiInstanceEnabled;
            if (this.mIsMultiInstanceEnabled && isMultiInstance)
            {
                char c = this.mSapaApp.InstanceId.charAt(this.mSapaApp.InstanceId.length() - 1);
                number = char.digit(c, 10);
                if (number > 0)
                {
                    mInstanceIcon = DrawableTool.getDefaultDrawableWithNumber(mInstanceIcon, number, context);
                }
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: DeviceActionsLayoutData(com.samsung.android.sdk.professionalaudio.app.SapaAppInfo info, android.content.Context context, boolean isMultiInstance) throws android.content.pm.PackageManager.NameNotFoundException
		internal DeviceActionsLayoutData(SapaAppInfo info, Context context, bool isMultiInstance)
		{
			mAppInfo = info;
			this.mInstanceIcon = info.getIcon(context);
			this.mSapaApp = info.App;
			this.mInstancePackageName = info.PackageName;
			this.mActionList = info.Actions;
			if (this.mActionList == null)
			{
				this.mActionList = new SparseArray<SapaActionInfo>();
			}
			mActionMap = new Dictionary<string, SapaActionInfo>();
			loadActionMap();
			this.mIsMultiInstanceEnabled = info.MultiInstanceEnabled;
			if (this.mIsMultiInstanceEnabled && isMultiInstance)
			{
				char c = this.mSapaApp.InstanceId.charAt(this.mSapaApp.InstanceId.length() - 1);
				number = char.digit(c, 10);
				if (number > 0)
				{
					mInstanceIcon = DrawableTool.getDefaultDrawableWithNumber(mInstanceIcon, number, context);
				}
			}
		}
Exemplo n.º 21
0
			public SapaProcessorStateListener(MainService outerInstance, SapaApp sapaApp)
			{
				this.outerInstance = outerInstance;
				mSapaApp = sapaApp;
			}
		public override void onTransportMasterChanged(SapaApp sapaApp)
		{
			// NO-OP
		}
Exemplo n.º 23
0
 public SapaProcessorStateListener(MainService outerInstance, SapaApp sapaApp)
 {
     this.outerInstance = outerInstance;
     mSapaApp           = sapaApp;
 }
Exemplo n.º 24
0
		internal virtual void stop(SapaApp sapaApp)
		{
			SapaAppInfo info = this.mAppInfoList[sapaApp.InstanceId];
			// Play action is being activated.
			modifyAction(info, MainActivity.ACTION_PLAY, R.drawable.ctrl_btn_play_default, true);
			// Stop action is being deactivated.
			modifyAction(info, MainActivity.ACTION_STOP, R.drawable.ctrl_btn_stop_disabled, false);
			try
			{
				// Notification that AppInfo has been changed is sent.
				this.mSapaAppService.changeAppInfo(info);
			}
			catch (SapaConnectionNotSetException)
			{
				Log.w(TAG, "State of application cound not be changed due to connection exception");
			}

			this.mIsPlaying = false;

			// Stop command is sent to native part.
			Logic.stopPlaying(this.mProcessorList[sapaApp.InstanceId]);
		}
Exemplo n.º 25
0
			public override void onAppChanged(SapaApp arg0)
			{
			}
Exemplo n.º 26
0
			public override void onAppDeactivated(SapaApp sapaApp)
			{
				Log.d(TAG, "onAppDeactivated: " + sapaApp.InstanceId + " was deactivated.");

				if (outerInstance.mCallerPackageNameList.Count > 0)
				{
					ISet<KeyValuePair<string, string>> entrySet = outerInstance.mCallerPackageNameList.SetOfKeyValuePairs();
					ISet<KeyValuePair<string, string>>.Enumerator iterator = entrySet.GetEnumerator();
					while (iterator.MoveNext())
					{
						KeyValuePair<string, string> entry = iterator.Current;

						if (sapaApp.PackageName.contentEquals(entry.Value))
						{
							Log.d(TAG, "Caller is closed.");
							// Close this instance. because the caller is closed by
							// unknow reason. So, It will be not used anymore.
							outerInstance.closeAnInstance(entry.Key);
						}
					}
				}

				if (outerInstance.mCallerPackageNameList.Count == 0)
				{
					stopSelf();
				}

			}
Exemplo n.º 27
0
			public override void onAppUninstalled(SapaApp arg0)
			{
				// TODO Auto-generated method stub

			}
Exemplo n.º 28
0
 private bool isMainApp(SapaApp sapaApp)
 {
     return(mMainAppPackageName.Equals(sapaApp.PackageName));
 }
Exemplo n.º 29
0
 public override void onAppChanged(SapaApp arg0)
 {
     // update bpm
     Log.d(TAG, "onAppChanged");
     outerInstance.updateBpm();
 }
Exemplo n.º 30
0
			public override void onAppDeactivated(SapaApp sapaApp)
			{
				Log.d(TAG, "onAppDeactivated: " + sapaApp.InstanceId + " was deactivated.");
				if (sapaApp.PackageName.contentEquals(outerInstance.mCallerPackageName))
				{
					Log.d(TAG, "Caller is closed.");
					stopSelf();
				}

			}
		public override void onAppInstalled(SapaApp sapaApp)
		{
			checkMainApp();
		}
Exemplo n.º 32
0
 public override void onAppChanged(SapaApp arg0)
 {
 }
		private bool isMainApp(SapaApp sapaApp)
		{
			return mMainAppPackageName.Equals(sapaApp.PackageName);
		}
		private int getAppType(SapaApp sapaApp)
		{
			return isMainApp(sapaApp) ? FcConstants.APP_TYPE_MAIN : FcConstants.APP_TYPE_ORDINAL;
		}
Exemplo n.º 35
0
			public override void onAppActivated(SapaApp arg0)
			{
				// TODO Auto-generated method stub

			}
Exemplo n.º 36
0
 private int getAppType(SapaApp sapaApp)
 {
     return(isMainApp(sapaApp) ? FcConstants.APP_TYPE_MAIN : FcConstants.APP_TYPE_ORDINAL);
 }
Exemplo n.º 37
0
			public override void onAppChanged(SapaApp arg0)
			{
				// update bpm
				Log.d(TAG, "onAppChanged");
				outerInstance.updateBpm();

			}
Exemplo n.º 38
0
 public override void onTransportMasterChanged(SapaApp sapaApp)
 {
     // NO-OP
 }
Exemplo n.º 39
0
 internal virtual bool isMaxVolume(SapaApp sapaApp)
 {
     return(Logic.isMaxVolume(this.getCurrectVolume(sapaApp)));
 }
Exemplo n.º 40
0
			internal ActionsPack(MainService outerInstance, SapaApp sapaApp)
			{
				this.outerInstance = outerInstance;
				this.mSapaApp = sapaApp;
				this.mPlayAction = null;
				this.mStopAction = null;
				this.mIsPlaying = false;
			}
Exemplo n.º 41
0
			public override void onTransportMasterChanged(SapaApp arg0)
			{
				// TODO Auto-generated method stub

			}
Exemplo n.º 42
0
 public override void onAppUninstalled(SapaApp arg0)
 {
     // TODO Auto-generated method stub
 }
Exemplo n.º 43
0
		public override Runnable getActionDefinition(SapaApp sapaApp, string actionId)
		{
			lock (this)
			{
				// Basing on actionId appropriate action definition is returned.
				Log.d(TAG, "instanceid " + sapaApp.InstanceId + " actionId " + actionId);
				if (actionId.Equals(MainActivity.ACTION_PLAY))
				{
					return this.mActionsList[sapaApp.InstanceId].PlayAction;
				}
				else if (actionId.Equals(MainActivity.ACTION_STOP))
				{
					return this.mActionsList[sapaApp.InstanceId].StopAction;
				}
				return null;
			}
		}
		public override void onAppDeactivated(SapaApp sapaApp)
		{
			Log.d(TAG, "Deactivated app: " + sapaApp.InstanceId);
			mFcSapaModel.removeApp(sapaApp.InstanceId, getAppType(sapaApp));
		}
Exemplo n.º 45
0
 public override void onTransportMasterChanged(SapaApp arg0)
 {
     // TODO Auto-generated method stub
 }
		public override void onAppChanged(SapaApp sapaApp)
		{
			Log.d(TAG, "Changed app: " + sapaApp.InstanceId);
			try
			{
				mFcSapaModel.updateApp(mSapaAppService.getActiveApp(sapaApp), getAppType(sapaApp));

			}
			catch (SapaConnectionNotSetException)
			{
				Log.w(TAG, "Cannot update app: sapa connection not set");
			}
		}
Exemplo n.º 47
0
 /// <param name="sapaApp">
 ///             SapaApp object for instance of application to which chosen action belongs </param>
 /// <param name="actionId">
 ///            Id of action that is represented on button. </param>
 public OnActionClickListener(DeviceActionsLayout outerInstance, SapaApp sapaApp, string actionId)
 {
     this.outerInstance = outerInstance;
     this.actionId      = actionId;
     this.mSapaApp      = sapaApp;
 }
		public override void onAppUninstalled(SapaApp sapaApp)
		{
			// Assumption: onAppDeactivated should be called
		}
Exemplo n.º 49
0
 public override void onAppActivated(SapaApp arg0)
 {
     // TODO Auto-generated method stub
 }
Exemplo n.º 50
0
		public override Runnable getActionDefinition(SapaApp sapaApp, string actionId)
		{
			Log.d(TAG, "getActionDefinition: actionId=" + actionId);
			if (actionId.Equals(COMMAND_SHUSH))
			{
				return () =>
				{
					MainService.this.shush();
				};
			}
			return null;
		}