Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerManagedPolicy"/> class.
        /// The server managed policy.
        /// </summary>
        /// <param name="context">
        /// The context for the current application
        /// </param>
        /// <param name="obfuscator">
        /// An obfuscator to be used with preferences.
        /// </param>
        public ServerManagedPolicy(Context context, IObfuscator obfuscator)
        {
            // Import old values
            ISharedPreferences sp = context.GetSharedPreferences(PreferencesFile, FileCreationMode.Private);

            this.Obfuscator = new PreferenceObfuscator(sp, obfuscator);

            this.lastResponse      = this.Obfuscator.GetValue <PolicyServerResponse>(Preferences.LastResponse, Preferences.DefaultLastResponse);
            this.validityTimestamp = this.Obfuscator.GetValue <long>(Preferences.ValidityTimestamp, Preferences.DefaultValidityTimestamp);
            this.retryUntil        = this.Obfuscator.GetValue <long>(Preferences.RetryUntil, Preferences.DefaultRetryUntil);
            this.maxRetries        = this.Obfuscator.GetValue <long>(Preferences.MaximumRetries, Preferences.DefaultMaxRetries);
            this.retryCount        = this.Obfuscator.GetValue <long>(Preferences.RetryCount, Preferences.DefaultRetryCount);
        }
        public override void SetUp()
        {
            var salt = new byte[] { 104, 12, 112, 82, 85, 10, 11, 61, 15, 54, 44, 66, 117, 89, 64, 110, 53, 123, 33 };

            // Prepare PreferenceObfuscator instance
            sp = Context.GetSharedPreferences(Filename, FileCreationMode.Private);
            string deviceId = Settings.Secure.GetString(Context.ContentResolver, Settings.Secure.AndroidId);
            IObfuscator o = new AesObfuscator(salt, Context.PackageName, deviceId);
            op = new PreferenceObfuscator(sp, o);

            // Populate with test data
            op.PutString("testString", "Hello world");
            op.Commit();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApkExpansionPolicy"/> class.
        /// </summary>
        /// <param name="context">
        /// The context for the current application
        /// </param>
        /// <param name="obfuscator">
        /// An obfuscator to be used when reading/writing to shared preferences.
        /// </param>
        public ApkExpansionPolicy(Context context, IObfuscator obfuscator)
        {
            this.expansionFiles = new[] { new ExpansionFile(), new ExpansionFile() };

            // Import old values
            ISharedPreferences sp = context.GetSharedPreferences(Preferences.File, FileCreationMode.Private);

            this.obfuscator = new PreferenceObfuscator(sp, obfuscator);

            this.lastResponse      = this.obfuscator.GetValue(Preferences.LastResponse, PolicyServerResponse.Retry);
            this.validityTimestamp = this.obfuscator.GetValue <long>(Preferences.ValidityTimestamp);
            this.retryUntil        = this.obfuscator.GetValue <long>(Preferences.RetryUntil);
            this.maxRetries        = this.obfuscator.GetValue <long>(Preferences.MaximumRetries);
            this.retryCount        = this.obfuscator.GetValue <long>(Preferences.RetryCount);
        }
Example #4
0
        public override void SetUp()
        {
            var salt = new byte[] { 104, 12, 112, 82, 85, 10, 11, 61, 15, 54, 44, 66, 117, 89, 64, 110, 53, 123, 33 };

            // Prepare PreferenceObfuscator instance
            sp = Context.GetSharedPreferences(Filename, FileCreationMode.Private);
            string      deviceId = Settings.Secure.GetString(Context.ContentResolver, Settings.Secure.AndroidId);
            IObfuscator o        = new AesObfuscator(salt, Context.PackageName, deviceId);

            op = new PreferenceObfuscator(sp, o);

            // Populate with test data
            op.PutString("testString", "Hello world");
            op.Commit();
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerManagedPolicy"/> class.
        /// The server managed policy.
        /// </summary>
        /// <param name="context">
        /// The context for the current application
        /// </param>
        /// <param name="obfuscator">
        /// An obfuscator to be used with preferences.
        /// </param>
        public ServerManagedPolicy(Context context, IObfuscator obfuscator)
        {
            // Import old values
            ISharedPreferences sp = context.GetSharedPreferences(PrefsFile, FileCreationMode.Private);

            this.preferences = new PreferenceObfuscator(sp, obfuscator);
            string lastResponse = this.preferences.GetString(
                PrefLastResponse, ((int)PolicyServerResponse.Retry).ToString());

            this.LastResponse      = (PolicyServerResponse)Enum.Parse(typeof(PolicyServerResponse), lastResponse);
            this.ValidityTimestamp =
                long.Parse(this.preferences.GetString(PrefValidityTimestamp, DefaultValidityTimestamp));
            this.RetryUntil = long.Parse(this.preferences.GetString(PrefRetryUntil, DefaultRetryUntil));
            this.MaxRetries = long.Parse(this.preferences.GetString(PrefMaxRetries, DefaultMaxRetries));
            this.RetryCount = long.Parse(this.preferences.GetString(PrefRetryCount, DefaultRetryCount));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerManagedPolicy"/> class. 
        /// The server managed policy.
        /// </summary>
        /// <param name="context">
        /// The context for the current application
        /// </param>
        /// <param name="obfuscator">
        /// An obfuscator to be used with preferences.
        /// </param>
        public ServerManagedPolicy(Context context, IObfuscator obfuscator)
        {
            // Import old values
            ISharedPreferences sp = context.GetSharedPreferences(PreferencesFile, FileCreationMode.Private);
			this.Obfuscator = new PreferenceObfuscator(sp, obfuscator);

			this.lastResponse = this.Obfuscator.GetValue<PolicyServerResponse>(Preferences.LastResponse, Preferences.DefaultLastResponse);
			this.validityTimestamp = this.Obfuscator.GetValue<long>(Preferences.ValidityTimestamp, Preferences.DefaultValidityTimestamp);
			this.retryUntil = this.Obfuscator.GetValue<long>(Preferences.RetryUntil, Preferences.DefaultRetryUntil);
			this.maxRetries = this.Obfuscator.GetValue<long>(Preferences.MaximumRetries, Preferences.DefaultMaxRetries);
			this.retryCount = this.Obfuscator.GetValue<long>(Preferences.RetryCount, Preferences.DefaultRetryCount);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ServerManagedPolicy"/> class. 
 /// The server managed policy.
 /// </summary>
 /// <param name="context">
 /// The context for the current application
 /// </param>
 /// <param name="obfuscator">
 /// An obfuscator to be used with preferences.
 /// </param>
 public ServerManagedPolicy(Context context, IObfuscator obfuscator)
 {
     // Import old values
     ISharedPreferences sp = context.GetSharedPreferences(PrefsFile, FileCreationMode.Private);
     this.preferences = new PreferenceObfuscator(sp, obfuscator);
     string lastResponse = this.preferences.GetString(
         PrefLastResponse, ((int)PolicyServerResponse.Retry).ToString());
     this.LastResponse = (PolicyServerResponse)Enum.Parse(typeof(PolicyServerResponse), lastResponse);
     this.ValidityTimestamp =
         long.Parse(this.preferences.GetString(PrefValidityTimestamp, DefaultValidityTimestamp));
     this.RetryUntil = long.Parse(this.preferences.GetString(PrefRetryUntil, DefaultRetryUntil));
     this.MaxRetries = long.Parse(this.preferences.GetString(PrefMaxRetries, DefaultMaxRetries));
     this.RetryCount = long.Parse(this.preferences.GetString(PrefRetryCount, DefaultRetryCount));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApkExpansionPolicy"/> class. 
        /// </summary>
        /// <param name="context">
        /// The context for the current application
        /// </param>
        /// <param name="obfuscator">
        /// An obfuscator to be used when reading/writing to shared preferences.
        /// </param>
        public ApkExpansionPolicy(Context context, IObfuscator obfuscator)
        {
            this.expansionFiles = new[] { new ExpansionFile(), new ExpansionFile() };

            // Import old values
            ISharedPreferences sp = context.GetSharedPreferences(Preferences.File, FileCreationMode.Private);
            this.obfuscator = new PreferenceObfuscator(sp, obfuscator);

            this.lastResponse = this.obfuscator.GetValue(Preferences.LastResponse, PolicyServerResponse.Retry);
            this.validityTimestamp = this.obfuscator.GetValue<long>(Preferences.ValidityTimestamp);
            this.retryUntil = this.obfuscator.GetValue<long>(Preferences.RetryUntil);
            this.maxRetries = this.obfuscator.GetValue<long>(Preferences.MaximumRetries);
            this.retryCount = this.obfuscator.GetValue<long>(Preferences.RetryCount);
        }