blob: 867da1c4ce29f22f2c5ea0db3fea0536dcab4072 [file] [log] [blame]
/*
* Copyright (C) 2022 The Android Open Source Project
*
* 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 android.security.cts.CVE_2022_20007_second;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
public class SecondPocActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
setSharedPreferenes(getResources().getInteger(R.integer.fail));
}
@Override
protected void onPause() {
super.onPause();
setSharedPreferenes(getResources().getInteger(R.integer.pass));
}
void setSharedPreferenes(int result) {
try {
Context testAppContext = createPackageContext(getString(R.string.testAppPackage),
Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences sh = testAppContext.getSharedPreferences(
getString(R.string.sharedPreferences), Context.MODE_PRIVATE);
SharedPreferences.Editor edit = sh.edit();
edit.putInt(getString(R.string.resultKey2), result);
edit.commit();
} catch (Exception e) {
// ignore exception here
}
}
}